Date: Fri, 9 Aug 2013 02:10:02 GMT From: Garrett Cooper <yaneurabeya@gmail.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/181153: sscanf doesn't skip whitespace properly Message-ID: <201308090210.r792A21J042982@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/181153; it has been noted by GNATS. From: Garrett Cooper <yaneurabeya@gmail.com> To: Andrey Chernov <ache@freebsd.org> Cc: "FreeBSD-gnats-submit@FreeBSD.org" <freebsd-gnats-submit@freebsd.org> Subject: Re: bin/181153: sscanf doesn't skip whitespace properly Date: Thu, 8 Aug 2013 19:03:10 -0700 On Thu, Aug 8, 2013 at 6:24 PM, Andrey Chernov <ache@freebsd.org> wrote: > 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. What about this line [*]? " A directive composed of one or more white-space characters is executed by reading input until no more valid input can be read, or up to the first byte which is not a white-space character which remains unread. " I think this is what the NetBSD test developer was shooting for originally. FWIW I did print out the value previously and it was (char)0, or '\0'. Thanks! * http://pubs.opengroup.org/onlinepubs/7908799/xsh/fscanf.html
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308090210.r792A21J042982>