This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: scanf and spaces
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: scanf and spaces
- From: Andreas Schwab <schwab at suse dot de>
- Date: 28 Feb 2001 10:37:04 +0100
- Cc: Werner Riebesel <werner at jongl dot de>, libc-alpha at sources dot redhat dot com
- References: <hoofvnql0m.fsf@gee.suse.de>
Andreas Jaeger <aj@suse.de> writes:
|> 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)
This does not fit here. This is the paragraph that matches here:
[#6] A directive that is an ordinary multibyte character is
executed by reading the next characters of the stream. If
any of those characters differ from the ones composing the
directive, the directive fails and the differing and
subsequent characters remain unread.
|> + res = sscanf ("int=11 float=22.22", "int=%dfloat=%f", &i, &f);
sscanf reads "11" via %d, then tries to match "f", but the next character
is " " -> fail. The expected return values is 1.
Andreas.
--
Andreas Schwab "And now for something
SuSE Labs completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg