aboutsummaryrefslogtreecommitdiff
path: root/stdio-common
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/Makefile5
-rw-r--r--stdio-common/bug10.c4
-rw-r--r--stdio-common/scanf1.c8
-rw-r--r--stdio-common/scanf10.c2
-rw-r--r--stdio-common/scanf11.c14
-rw-r--r--stdio-common/scanf3.c4
-rw-r--r--stdio-common/tstdiomisc.c2
-rw-r--r--stdio-common/vfscanf.c23
8 files changed, 40 insertions, 22 deletions
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index f4e49e6..e7c1cb8 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+# Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -43,7 +43,8 @@ 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
+ scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10 \
+ scanf11
include ../Rules
diff --git a/stdio-common/bug10.c b/stdio-common/bug10.c
index 5306471..5e8ae25 100644
--- a/stdio-common/bug10.c
+++ b/stdio-common/bug10.c
@@ -1,7 +1,7 @@
#include <stdio.h>
int
-main(int arc, char *argv)
+main (int arc, char *argv)
{
int n, res;
unsigned int val;
@@ -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 != 1 || val != 111 || n != 3;
+ result |= res != 2 || val != 111 || n != 3;
result |= sscanf ("", " %n", &n) == EOF;
diff --git a/stdio-common/scanf1.c b/stdio-common/scanf1.c
index 3adf532..58c78c2 100644
--- a/stdio-common/scanf1.c
+++ b/stdio-common/scanf1.c
@@ -2,14 +2,14 @@
#include <stdlib.h>
int
-main(int argc, char *argv[])
+main (int argc, char *argv[])
{
int i,n,r;
n = i = r = -1;
- r = sscanf("1234:567", "%d%n", &i, &n);
- printf("%d %d %d\n", r, n, i);
- if (r != 1 || i != 1234 || n != 4)
+ r = sscanf ("1234:567", "%d%n", &i, &n);
+ printf ("%d %d %d\n", r, n, i);
+ if (r != 2 || i != 1234 || n != 4)
abort ();
return 0;
}
diff --git a/stdio-common/scanf10.c b/stdio-common/scanf10.c
index f896137..27a5e66 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 == -1 && a == 6 && b == 12 ? 0 : 1;
+ return retc == 2 && a == 6 && b == 12 ? 0 : 1;
}
diff --git a/stdio-common/scanf11.c b/stdio-common/scanf11.c
new file mode 100644
index 0000000..50ef26a
--- /dev/null
+++ b/stdio-common/scanf11.c
@@ -0,0 +1,14 @@
+/* This test comes from ISO C Corrigendum 1. */
+#include <stdio.h>
+
+int
+main (int argc, char *argv[])
+{
+ int d1, n1, n2, i;
+#define NOISE 1234567
+ int d2 = NOISE;
+
+ i = sscanf ("123", "%d%n%n%d", &d1, &n1, &n2, &d2);
+
+ return i != 3 || d1 != 123 || n1 != 3 || n2 != 3 || d2 != NOISE;
+}
diff --git a/stdio-common/scanf3.c b/stdio-common/scanf3.c
index 33495cc..5bfa80b 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 != 1)
+ if (n != 3 || val != 111 || res != 2)
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 != 1)
+ if (n != 3 || val != 111 || res != 2)
abort ();
return 0;
diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c
index 8dac4f2..dbce623 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, 0, 4);
+ SCAN ("test ", "%*s%n", n, 1, 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 cb6d396..ef0dbee 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -452,15 +452,18 @@ __vfscanf (FILE *s, const char *format, va_list argptr)
/* Corrigendum 1 to ISO C 1990 describes the allowed flags
with the 'n' conversion specifier. */
if (!(flags & SUPPRESS))
- /* Don't count the read-ahead. */
- if (flags & LONGDBL)
- *ARG (long long int *) = read_in;
- else if (flags & LONG)
- *ARG (long int *) = read_in;
- else if (flags & SHORT)
- *ARG (short int *) = read_in;
- else
- *ARG (int *) = read_in;
+ {
+ /* Don't count the read-ahead. */
+ if (flags & LONGDBL)
+ *ARG (long long int *) = read_in;
+ else if (flags & LONG)
+ *ARG (long int *) = read_in;
+ else if (flags & SHORT)
+ *ARG (short int *) = read_in;
+ else
+ *ARG (int *) = read_in;
+ ++done;
+ }
break;
case 'c': /* Match characters. */