bin/181153: sscanf doesn't skip whitespace properly

Andrey Chernov ache at freebsd.org
Fri Aug 9 01:40:02 UTC 2013


The following reply was made to PR kern/181153; it has been noted by GNATS.

From: Andrey Chernov <ache at freebsd.org>
To: Garrett Cooper <yaneurabeya at gmail.com>
Cc: freebsd-gnats-submit at FreeBSD.org
Subject: Re: bin/181153: sscanf doesn't skip whitespace properly
Date: Fri, 09 Aug 2013 05:24:20 +0400

 On 09.08.2013 4:23, Garrett Cooper wrote:
 > ATF_TC_BODY(sscanf_whitespace, tc)
 > {
 >         const char str[] = "\f\n\r\t\v%z";
 >         char c;
 > 
 >         /* set of "white space" symbols from isspace(3) */
 >         c = 0;
 >         (void)sscanf(str, "%%%c", &c);
 >         ATF_REQUIRE(c == 'z');
 > }
 
 I doubt this exampe should skip whitespace. POSIX says:
 "A directive that is an ordinary character shall be executed as follows:
 the next byte shall be read from the input and compared with the byte
 that comprises the directive; if the comparison shows that they are not
 equivalent, the directive shall fail, and the differing and subsequent
 bytes shall remain unread."
 %% is the ordinary % character and no isspace(3) skipping mentioned in
 this explanation.
 
 -- 
 http://ache.vniz.net/
 bitcoin:1G6ugdNY6e5jx1GVnAU2ntj2NEfmjKG85r


More information about the freebsd-bugs mailing list