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/Makefile3
-rw-r--r--stdio-common/bug10.c2
-rw-r--r--stdio-common/scanf1.c2
-rw-r--r--stdio-common/scanf10.c2
-rw-r--r--stdio-common/scanf3.c4
-rw-r--r--stdio-common/tstdiomisc.c2
-rw-r--r--stdio-common/vfscanf.c28
7 files changed, 35 insertions, 8 deletions
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index e7c1cb8c52..814374b8ae 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -43,8 +43,7 @@ tests := tst-printf tstscanf test_rdwr test-popen tstgetln test-fseek \
 	 xbug errnobug \
 	 bug1 bug2 bug3 bug4 bug5 bug6 bug7 bug8 bug9 bug10 bug11 \
 	 tfformat tiformat tstdiomisc \
-	 scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10 \
-	 scanf11
+	 scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10
 
 
 include ../Rules
diff --git a/stdio-common/bug10.c b/stdio-common/bug10.c
index 5e8ae25021..3e15526a43 100644
--- a/stdio-common/bug10.c
+++ b/stdio-common/bug10.c
@@ -14,7 +14,7 @@ main (int arc, char *argv)
   printf("Result of sscanf = %d\n", res);
   printf("Scanned format %%u = %u\n", val);
   printf("Possibly scanned format %%n = %d\n", n);
-  result |= res != 2 || val != 111 || n != 3;
+  result |= res != 1 || val != 111 || n != 3;
 
 
   result |= sscanf ("", " %n", &n) == EOF;
diff --git a/stdio-common/scanf1.c b/stdio-common/scanf1.c
index 58c78c2292..be6d63e997 100644
--- a/stdio-common/scanf1.c
+++ b/stdio-common/scanf1.c
@@ -9,7 +9,7 @@ main (int argc, char *argv[])
   n = i = r = -1;
   r = sscanf ("1234:567", "%d%n", &i, &n);
   printf ("%d %d %d\n", r, n, i);
-  if (r != 2 || i != 1234 || n != 4)
+  if (r != 1 || i != 1234 || n != 4)
     abort ();
   return 0;
 }
diff --git a/stdio-common/scanf10.c b/stdio-common/scanf10.c
index 27a5e66a9e..f8961378ef 100644
--- a/stdio-common/scanf10.c
+++ b/stdio-common/scanf10.c
@@ -11,5 +11,5 @@ main (int argc, char *argv[])
 
   printf ("retc=%d a=%d b=%d\n", retc, a, b);
 
-  return retc == 2 && a == 6 && b == 12 ? 0 : 1;
+  return retc == -1 && a == 6 && b == 12 ? 0 : 1;
 }
diff --git a/stdio-common/scanf3.c b/stdio-common/scanf3.c
index 5bfa80b62f..33495cca79 100644
--- a/stdio-common/scanf3.c
+++ b/stdio-common/scanf3.c
@@ -13,7 +13,7 @@ main(int arc, char *argv[])
   printf("Result of sscanf = %d\n", res);
   printf("Scanned format %%u = %u\n", val);
   printf("Possibly scanned format %%n = %d\n", n);
-  if (n != 3 || val != 111 || res != 2)
+  if (n != 3 || val != 111 || res != 1)
     abort ();
 
   val = n = -1;
@@ -21,7 +21,7 @@ main(int arc, char *argv[])
   printf("Result of sscanf = %d\n", res);
   printf("Scanned format %%u = %u\n", val);
   printf("Possibly scanned format %%n = %d\n", n);
-  if (n != 3 || val != 111 || res != 2)
+  if (n != 3 || val != 111 || res != 1)
     abort ();
 
   return 0;
diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c
index dbce6237c9..8dac4f2039 100644
--- a/stdio-common/tstdiomisc.c
+++ b/stdio-common/tstdiomisc.c
@@ -27,7 +27,7 @@ t2 (void)
   SCAN ("12345", "%ld", N, 1, 12345);
   SCAN ("12345", "%llllld", N, 0, -1);
   SCAN ("12345", "%LLLLLd", N, 0, -1);
-  SCAN ("test ", "%*s%n",  n, 1, 4);
+  SCAN ("test ", "%*s%n",  n, 0, 4);
   SCAN ("test ",   "%2*s%n",  n, 0, -1);
   SCAN ("12 ",   "%l2d",  n, 0, -1);
   SCAN ("12 ",   "%2ld",  N, 1, 12);
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index ef0dbeea32..f201c46775 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -462,7 +462,35 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
 		*ARG (short int *) = read_in;
 	      else
 		*ARG (int *) = read_in;
+
+#ifdef NO_BUG_IN_ISO_C_CORRIGENDUM_1
+	      /* We have a severe problem here.  The ISO C standard
+		 contradicts itself in explaining the effect of the %n
+		 format in `scanf'.  While in ISO C:1990 and the ISO C
+		 Amendement 1:1995 the result is described as
+
+		   Execution of a %n directive does not effect the
+		   assignment count returned at the completion of
+		   execution of the f(w)scanf function.
+
+		 in ISO C Corrigendum 1:1994 the following was added:
+
+		   Subclause 7.9.6.2
+		   Add the following fourth example:
+		     In:
+		       #include <stdio.h>
+		       int d1, d2, n1, n2, i;
+		       i = sscanf("123", "%d%n%n%d", &d1, &n1, &n2, &d2);
+		     the value 123 is assigned to d1 and the value3 to n1.
+		     Because %n can never get an input failure the value
+		     of 3 is also assigned to n2.  The value of d2 is not
+		     affected.  The value 3 is assigned to i.
+
+		 We go for now with the historically correct code fro ISO C,
+		 i.e., we don't count the %n assignments.  When it ever
+		 should proof to be wrong just remove the #ifdef above.  */
 	      ++done;
+#endif
 	    }
 	  break;