bug fixes for scanf()
authoreck <none@none>
Wed, 28 Mar 1990 16:33:05 +0000 (16:33 +0000)
committereck <none@none>
Wed, 28 Mar 1990 16:33:05 +0000 (16:33 +0000)
lang/cem/libcc.ansi/stdio/doscan.c
lang/cem/libcc.ansi/stdio/ungetc.c

index 8ec2690..8c4fffb 100644 (file)
@@ -174,6 +174,8 @@ _doscan(register FILE *stream, const char *format, va_list ap)
        long double     ld_val;
 #endif
 
+       if (!*format) return 0;
+
        while (1) {
                if (isspace(*format)) {
                        while (isspace(*format))
index dfe5cb1..e78bf26 100644 (file)
@@ -19,6 +19,8 @@ ungetc(int ch, FILE *stream)
        }
        stream->_count++;
        p = --(stream->_ptr);           /* ??? Bloody vax assembler !!! */
-       *p = (unsigned char) ch;
+       /* ungetc() in sscanf() shouldn't write in rom */
+       if (*p != (unsigned char) ch)
+               *p = (unsigned char) ch;
        return ch;
 }