1
0
mirror of https://github.com/simh/simh.git synced 2026-02-10 10:11:20 +00:00

All LP and CD devices: Removed use of ftell for pipe compatibility

This commit is contained in:
Bob Supnik
2022-05-16 04:57:30 -07:00
committed by Mark Pizzolato
parent 5d04198757
commit e2d3a2ae70
17 changed files with 152 additions and 105 deletions

View File

@@ -1,6 +1,6 @@
/* i1401_cd.c: IBM 1402 card reader/punch
Copyright (c) 1993-2017, Robert M. Supnik
Copyright (c) 1993-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -35,6 +35,7 @@
Cards are represented as ASCII text streams terminated by newlines.
This allows cards to be created and edited as normal files.
09-Jun-21 RMS Removed use of ftell on output for pipe compatibility
09-Mar-17 RMS Protect character conversions from gargage files (COVERITY)
05-May-16 RMS Fixed calling sequence inconsistency (Mark Pizzolato)
28-Feb-15 RMS Added read from console
@@ -295,13 +296,13 @@ else uptr = &stack_unit[0]; /* then default */
if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return SCPE_OK;
fputs (cdr_buf, uptr->fileref); /* write card */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
perror ("Card stacker I/O error");
clearerr (uptr->fileref);
if (iochk)
return SCPE_IOERR;
}
uptr->pos = uptr->pos + strlen (cdr_buf); /* update position */
return SCPE_OK;
}
@@ -375,7 +376,6 @@ if ((uptr->flags & UNIT_ATT) == 0) /* attached? */
return SCPE_UNATT;
fputs (cdp_buf, uptr->fileref); /* output card */
fputc ('\n', uptr->fileref); /* plus new line */
uptr->pos = ftell (uptr->fileref); /* update position */
if (ferror (uptr->fileref)) { /* error? */
perror ("Card punch I/O error");
clearerr (uptr->fileref);
@@ -383,6 +383,7 @@ if (ferror (uptr->fileref)) { /* error? */
return SCPE_IOERR;
ind[IN_PNCH] = 1;
}
uptr->pos = uptr->pos + strlen (cdp_buf) + 1; /* update position */
return SCPE_OK;
}

View File

@@ -1,6 +1,6 @@
/* i1401_lp.c: IBM 1403 line printer simulator
Copyright (c) 1993-2015, Robert M. Supnik
Copyright (c) 1993-2021, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -25,6 +25,7 @@
lpt 1403 line printer
09-Jun-21 RMS Removed use of ftell for pipe compatibility
08-Mar-15 RMS Added print to console option
16-Apr-13 RMS Fixed printer chain selection
19-Jan-07 RMS Added UNIT_TEXT flag
@@ -248,19 +249,19 @@ if ((lpt_unit.flags & UNIT_ATT) != 0) { /* attached? */
ind[IN_LPT] = 1;
perror ("Line printer I/O error");
clearerr (lpt_unit.fileref);
if (iochk)
if (iochk != 0)
return SCPE_IOERR;
}
lpt_unit.pos = ftell (lpt_unit.fileref); /* update position */
lpt_unit.pos = lpt_unit.pos + strlen (buf); /* update position */
return SCPE_OK;
}
if ((lpt_unit.flags & UNIT_CONS) != 0) { /* default to cons? */
if (buf[0] == '\n') { /* bare lf? */
inq_puts ("\r"); /* cvt to crlf */
if ((lpt_unit.flags & UNIT_CONS) != 0) { /* default to cons? */
if (buf[0] == '\n') { /* bare lf? */
inq_puts ("\r"); /* cvt to crlf */
lpt_unit.pos = lpt_unit.pos + 1;
}
inq_puts (buf);
lpt_unit.pos = lpt_unit.pos + strlen (buf);
lpt_unit.pos = lpt_unit.pos + strlen (buf); /* update position */
return SCPE_OK;
}
return SCPE_UNATT;