diff options
Diffstat (limited to 'libc/stdio2')
-rw-r--r-- | libc/stdio2/printf.c | 6 | ||||
-rw-r--r-- | libc/stdio2/scanf.c | 15 | ||||
-rw-r--r-- | libc/stdio2/stdio.c | 16 |
3 files changed, 28 insertions, 9 deletions
diff --git a/libc/stdio2/printf.c b/libc/stdio2/printf.c index 45c4aa7..e41eca4 100644 --- a/libc/stdio2/printf.c +++ b/libc/stdio2/printf.c @@ -1,11 +1,15 @@ /* * This file based on printf.c from 'Dlibs' on the atari ST (RdeBath) * - * + * 19-OCT-88: Dale Schumacher + * > John Stanley has again been a great help in debugging, particularly + * > with the printf/scanf functions which are his creation. + * * Dale Schumacher 399 Beacon Ave. * (alias: Dalnefre') St. Paul, MN 55104 * dal@syntel.UUCP United States of America * "It's not reality that's important, but how you perceive things." + * */ /* Altered to use stdarg, made the core function vfprintf. diff --git a/libc/stdio2/scanf.c b/libc/stdio2/scanf.c index 2d61ab2..1e0f282 100644 --- a/libc/stdio2/scanf.c +++ b/libc/stdio2/scanf.c @@ -1,3 +1,17 @@ +/* + * This file based on scanf.c from 'Dlibs' on the atari ST (RdeBath) + * + * 19-OCT-88: Dale Schumacher + * > John Stanley has again been a great help in debugging, particularly + * > with the printf/scanf functions which are his creation. + * + * Dale Schumacher 399 Beacon Ave. + * (alias: Dalnefre') St. Paul, MN 55104 + * dal@syntel.UUCP United States of America + * "It's not reality that's important, but how you perceive things." + * + */ + #include <stdio.h> #include <ctype.h> #include <string.h> @@ -519,3 +533,4 @@ va_list ap; } #endif + diff --git a/libc/stdio2/stdio.c b/libc/stdio2/stdio.c index bc96100..c317859 100644 --- a/libc/stdio2/stdio.c +++ b/libc/stdio2/stdio.c @@ -130,11 +130,11 @@ FILE *fp; register int v; Inline_init; - v = fp->mode; - /* If last op was a read ... */ - if ((v & __MODE_READING) && fflush(fp)) + /* If last op was a read ... note fflush may change fp->mode and ret OK */ + if ((fp->mode & __MODE_READING) && fflush(fp)) return EOF; + v = fp->mode; /* Can't write if there's been an EOF or error then return EOF */ if ((v & (__MODE_WRITE | __MODE_EOF | __MODE_ERR)) != __MODE_WRITE) return EOF; @@ -304,7 +304,7 @@ FILE *f; register int ch; ret = s; - for (i = count; i > 0; i--) + for (i = count-1; i > 0; i--) { ch = getc(f); if (ch == EOF) @@ -456,11 +456,11 @@ FILE *fp; int len; unsigned bytes, put; - v = fp->mode; - /* If last op was a read ... */ - if ((v & __MODE_READING) && fflush(fp)) + /* If last op was a read ... note fflush may change fp->mode and ret OK */ + if ((fp->mode & __MODE_READING) && fflush(fp)) return 0; + v = fp->mode; /* Can't write or there's been an EOF or error then return 0 */ if ((v & (__MODE_WRITE | __MODE_EOF | __MODE_ERR)) != __MODE_WRITE) return 0; @@ -537,7 +537,6 @@ int ref; { #if 1 /* if __MODE_READING and no ungetc ever done can just move pointer */ - /* This needs testing! */ if ( (fp->mode &(__MODE_READING | __MODE_UNGOT)) == __MODE_READING && ( ref == SEEK_SET || ref == SEEK_CUR )) @@ -823,6 +822,7 @@ size_t size; { fp->bufstart = buf; fp->bufend = buf+size; + fp->mode &= ~__MODE_BUF; fp->mode |= mode; } } |