Re: bin/181152: %i fails with negative hex numbers with sscanf

看板FB_bugs作者時間12年前 (2013/08/09 10:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
The following reply was made to PR kern/181152; it has been noted by GNATS. From: Andrey Chernov <ache@freebsd.org> To: Garrett Cooper <yaneurabeya@gmail.com> 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 <stdio.h> 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 _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscribe@freebsd.org"
文章代碼(AID): #1I15IY_Y (FB_bugs)
文章代碼(AID): #1I15IY_Y (FB_bugs)