about summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/temptest.c14
-rw-r--r--stdio-common/tstscanf.c6
-rw-r--r--stdio-common/vfscanf.c13
3 files changed, 17 insertions, 16 deletions
diff --git a/stdio-common/temptest.c b/stdio-common/temptest.c
index 71868174db..35ea4dc808 100644
--- a/stdio-common/temptest.c
+++ b/stdio-common/temptest.c
@@ -6,21 +6,17 @@ char *files[500];
 int
 main (int argc, char *argv[])
 {
-  char buf[FILENAME_MAX];
-  char *fn;
   FILE *fp;
   int i;
 
   for (i = 0; i < 500; i++) {
-    fn = __stdio_gen_tempname(buf, sizeof (buf), (const char *) NULL,
-	"file", 0, (size_t *) NULL, (FILE **) NULL);
-    if (fn == NULL) {
-      printf ("__stdio_gen_tempname failed\n");
+    files[i] = tempnam (NULL, "file");
+    if (files[i] == NULL) {
+      printf ("tempnam failed\n");
       exit (1);
     }
-    files[i] = strdup (fn);
-    printf ("file: %s\n", fn);
-    fp = fopen (fn, "w");
+    printf ("file: %s\n", files[i]);
+    fp = fopen (files[i], "w");
     fclose (fp);
   }
 
diff --git a/stdio-common/tstscanf.c b/stdio-common/tstscanf.c
index eb2f30d0f9..d0ff6c8b41 100644
--- a/stdio-common/tstscanf.c
+++ b/stdio-common/tstscanf.c
@@ -166,6 +166,12 @@ main (int argc, char **argv)
 
     if (res != 1 || a != 0)
       exit (EXIT_FAILURE);
+
+    res = sscanf ("1e3", "%lg%n", &a, &n);
+    printf ("res = %d, a = %g, n = %d\n", res, a, n);
+
+    if (res != 1 || a != 1000 || n != 3)
+      exit (EXIT_FAILURE);
   }
 
   exit(EXIT_SUCCESS);
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 3738e44f0a..0b24b8bb52 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -54,8 +54,10 @@
 
 # undef va_list
 # define va_list	_IO_va_list
-# define ungetc(c, s)	(--read_in, _IO_ungetc (c, s))
-# define inchar()	((c = _IO_getc_unlocked (s)), (void) ++read_in, c)
+# define ungetc(c, s)	((void) ((int) c != EOF && --read_in),		      \
+			 _IO_ungetc (c, s))
+# define inchar()	((c = _IO_getc_unlocked (s)), \
+			 (void) (c != EOF && ++read_in), c)
 # define encode_error()	do {						      \
 			  if (errp != NULL) *errp |= 4;			      \
 			  _IO_funlockfile (s);				      \
@@ -98,8 +100,8 @@
   _IO_flockfile (S)
 # define UNLOCK_STREAM __libc_cleanup_region_end (1)
 #else
-# define ungetc(c, s)	(--read_in, ungetc (c, s))
-# define inchar()	((c = getc (s)), (void) ++read_in, c)
+# define ungetc(c, s)	((void) (c != EOF && --read_in), ungetc (c, s))
+# define inchar()	((c = getc (s)), (void) (c != EOF && ++read_in), c)
 # define encode_error()	do {						      \
 			  funlockfile (s);				      \
 			  __set_errno (EILSEQ);				      \
@@ -719,9 +721,6 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
 	      STRING_ADD_CHAR (str, c, char);
 	    } while ((width <= 0 || --width > 0) && inchar () != EOF);
 
-	  if (c == EOF)
-	    --read_in;
-
 	  if (!(flags & SUPPRESS))
 	    {
 	      *str = '\0';