about summary refs log tree commit diff
path: root/stdio-common/tstdiomisc.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-12-15 05:22:35 +0000
committerRoland McGrath <roland@gnu.org>1995-12-15 05:22:35 +0000
commit05be689b5734fb12b3e2f99bc6cb5db53da974fd (patch)
treea092c63ac633171a19ed589a7d69b80ba6fe0807 /stdio-common/tstdiomisc.c
parentfaf92f2a62ec5e48fac87a6ced0edfcaeb026459 (diff)
downloadglibc-05be689b5734fb12b3e2f99bc6cb5db53da974fd.tar.gz
glibc-05be689b5734fb12b3e2f99bc6cb5db53da974fd.tar.xz
glibc-05be689b5734fb12b3e2f99bc6cb5db53da974fd.zip
Fri Dec 15 04:41:22 1995 Ulrich Drepper <drepper@gnu.ai.mit.edu> cvs/libc-951215
	* stdio-common/Makefile (tests): Add bug10.
	* stdio-common/bug10.c: New file.  From HJ Lu.

	* stdio-common/tstdiomisc.c: Make more test-suite like: exit
	status tells about successful run.

	* stdio-common/vfscanf.c [!USE_IN_LIBIO]: Use `flags' to check
	format correctness.
	Correct handling of trailing white spaces in format + EOF.

Fri Dec 15 01:31:56 1995  Ulrich Drepper  <drepper@gnu.ai.mit.edu>

	* stdio-common/Makefile (tests): Add bug8 and bug9.
	* stdio-common/bug8.c, stdio-common/bug9.c: New tests.

	* stdio-common/vfscanf.c: Fix bug in dynamic buffer handling.

	* stdlib/strtod.c: Correct spelling: nominator -> numerator.
	Thanks to Jim Meyering.

Sat Nov 25 06:05:12 1995  H.J. Lu  <hjl@nynexst.com>

	* stdio-common/vfscanf.c: Always check width !=0.
	Correctly handle %%.
Diffstat (limited to 'stdio-common/tstdiomisc.c')
-rw-r--r--stdio-common/tstdiomisc.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c
index 0bd5515934..66e1fe3ec7 100644
--- a/stdio-common/tstdiomisc.c
+++ b/stdio-common/tstdiomisc.c
@@ -1,40 +1,49 @@
 #include <stdio.h>
 
-void
+int
 t1 ()
 {
   int n = -1;
   sscanf ("abc  ", "abc %n", &n);
   printf ("t1: count=%d\n", n);
+
+  return n != 5;
 }
 
-void
+int
 t2 ()
 {
+  int result = 0;
   int n;
   long N;
   int retval;
-#define SCAN(INPUT, FORMAT, VAR) \
+#define SCAN(INPUT, FORMAT, VAR, EXP_RES, EXP_VAL) \
   VAR = -1; \
   retval = sscanf (INPUT, FORMAT,  &VAR); \
   printf ("sscanf (\"%s\", \"%s\", &x) => %d, x = %ld\n", \
-	  INPUT, FORMAT, retval, VAR);
-
-  SCAN ("12345", "%ld", N);
-  SCAN ("12345", "%llllld", N);
-  SCAN ("12345", "%LLLLLd", N);
-  SCAN ("test ", "%*s%n",  n);
-  SCAN ("test ",   "%2*s%n",  n);
-  SCAN ("12 ",   "%l2d",  n);
-  SCAN ("12 ",   "%2ld",  N);
+	  INPUT, FORMAT, retval, VAR); \
+  result |= retval != EXP_RES || VAR != EXP_VAL
+
+  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 ",   "%2*s%n",  n, 0, -1);
+  SCAN ("12 ",   "%l2d",  n, 0, -1);
+  SCAN ("12 ",   "%2ld",  N, 1, 12);
+
+  return result;
 }
 
 int
 main ()
 {
-  t1 ();
-  t2 ();
+  int result = 0;
+
+  result |= t1 ();
+  result |= t2 ();
+
+  result |= fflush (stdout) == EOF;
 
-  fflush (stdout);
-  return 0;
+  return result;
 }