From owner-freebsd-bugs@FreeBSD.ORG Fri Aug 9 02:10:02 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D7BC93AB for ; Fri, 9 Aug 2013 02:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C58AA24A5 for ; Fri, 9 Aug 2013 02:10:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r792A2DU042983 for ; Fri, 9 Aug 2013 02:10:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r792A21J042982; Fri, 9 Aug 2013 02:10:02 GMT (envelope-from gnats) Date: Fri, 9 Aug 2013 02:10:02 GMT Message-Id: <201308090210.r792A21J042982@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Garrett Cooper Subject: Re: bin/181153: sscanf doesn't skip whitespace properly X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Garrett Cooper List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Aug 2013 02:10:02 -0000 The following reply was made to PR kern/181153; it has been noted by GNATS. From: Garrett Cooper To: Andrey Chernov Cc: "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 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