This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
scanf and spaces
- To: Werner Riebesel <werner at jongl dot de>
- Subject: scanf and spaces
- From: Andreas Jaeger <aj at suse dot de>
- Date: 28 Feb 2001 09:17:29 +0100
- Cc: libc-alpha at sources dot redhat dot com
Werner reported a problem to me that can be shown by the appended test
case for our testsuite. He claimed that this is broken in 2.2.x but
worked in older glibc releases.
ISO C 99 states for scanf:
[#8] Input white-space characters (as specified by the
isspace function) are skipped, unless the specification
includes a [, c, or n specifier.241)
Is the appended testcase correct - and glibc broken? Or why is glibc
correct in not parsing this?
Andreas
2001-02-28 Andreas Jaeger <aj@suse.de>
* stdio-common/tstscanf.c (main): Add new test case for a bug
report by Werner Riebesel <werner@jongl.de>.
============================================================
Index: stdio-common/tstscanf.c
--- stdio-common/tstscanf.c 2001/01/15 11:17:23 1.19
+++ stdio-common/tstscanf.c 2001/02/28 08:15:02
@@ -331,6 +331,20 @@
}
}
+ fputs ("Test 13:\n", stdout);
+ {
+ float f;
+ int i;
+ int res;
+
+ res = sscanf ("int=11 float=22.22", "int=%dfloat=%f", &i, &f);
+ if (res != 2)
+ {
+ fputs ("test failed!\n", stdout);
+ result = 1;
+ }
+ }
+
return result;
}
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj