From owner-freebsd-bugs@FreeBSD.ORG Fri Aug 9 02:10:01 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D11913AA for ; Fri, 9 Aug 2013 02:10:01 +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 BCBD824A4 for ; Fri, 9 Aug 2013 02:10:01 +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 r792A11U042977 for ; Fri, 9 Aug 2013 02:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r792A139042976; Fri, 9 Aug 2013 02:10:01 GMT (envelope-from gnats) Date: Fri, 9 Aug 2013 02:10:01 GMT Message-Id: <201308090210.r792A139042976@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Andrey Chernov Subject: Re: bin/181152: %i fails with negative hex numbers with sscanf X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Andrey Chernov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Aug 2013 02:10:01 -0000 The following reply was made to PR kern/181152; it has been noted by GNATS. From: Andrey Chernov To: Garrett Cooper Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: bin/181152: %i fails with negative hex numbers with sscanf Date: Fri, 09 Aug 2013 06:05:04 +0400 On 09.08.2013 4:15, Garrett Cooper wrote: > #define NUM -0x1234 > #define STRNUM __STRING(NUM) > > ATF_TC(sscanf_neghex); > ATF_TC_HEAD(sscanf_neghex, tc) > { > atf_tc_set_md_var(tc, "descr", > "PR lib/21691: %%i and %%x fail with negative hex numbers"); > } > > ATF_TC_BODY(sscanf_neghex, tc) > { > int i; > > sscanf(STRNUM, "%i", &i); > ATF_REQUIRE(i == NUM); > > sscanf(STRNUM, "%x", &i); > ATF_REQUIRE(i == NUM); > } Probably something is wrong with your ATF way, this example works: #include int main() { int i; i = 0; sscanf("-0x1234", "%i", &i); printf("%d\n", i); i = 0; sscanf("-0x1234", "%x", &i); printf("%d\n", i); } -4660 -4660 (which is -0x1234) Please do not post more ATF examples, use plain ones, many developers (including me) don't have ATF installed. -- http://ache.vniz.net/ bitcoin:1G6ugdNY6e5jx1GVnAU2ntj2NEfmjKG85r