cosmopolitan/test/libc/fmt
Gabriel Ravier 9a5d69c842
Fix scanf x specifier with string of 0 (#793)
The C standard states that, in the context of an x conversion
specifier given to scanf:
> Matches an optionally signed hexadecimal integer, whose format is
> the same as expected for the subject sequence of the strtoul
> function with the value 16 for the base argument.
- C standard, 7.23.6.2.11. The fscanf function

Cosmopolitan fails to do this, as 0 should be parsed as a 0 by such an
invocation of strtoul. Instead, cosmopolitan errors out as though such
input is invalid, which is wrong.

This means that a program such as this:

 #include <stdio.h>
 #undef NDEBUG
 #include <assert.h>

int main()
{
    int v = 0;
    assert(sscanf("0", "%x", &v) == 1);
}

will not run correctly on cosmpolitan, instead failing the assertion.

This patch fixes this, along with the associated GitHub issue,
https://github.com/jart/cosmopolitan/issues/778
2023-04-15 06:25:35 -07:00
..
atoi_test.c Greatly expand system() shell code features 2022-10-11 21:30:31 -07:00
basename_test.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
dirname_test.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
encodenf32_test.c Fold LIBC_RAND into LIBC_STDIO/TINYMATH/INTRIN 2022-08-11 12:32:00 -07:00
fmt_test.c Fix printf precision/field width being limited by internal buffer size (#799) 2023-04-04 14:16:34 -04:00
formatbinary64_test.c Unbloat the build 2022-08-11 00:15:29 -07:00
formatflex64_test.c Unbloat the build 2022-08-11 00:15:29 -07:00
formathex64_test.c Unbloat the build 2022-08-11 00:15:29 -07:00
formatint64_test.c Do code cleanup use duff device linenoise i/o 2022-04-22 18:56:52 -07:00
formatint64thousands_test.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
formatoctal32_test.c Do code cleanup use duff device linenoise i/o 2022-04-22 18:56:52 -07:00
formatoctal64_test.c Polish redbean serialization 2022-04-29 06:10:10 -07:00
fprintf_test.c Fix vfprintf and derived functions not handling write errors (#798) 2023-03-31 09:57:29 -04:00
imaxdiv_test.c Add imaxdiv, wcscoll, getdtablesize (#639) 2022-10-05 07:14:58 -07:00
itoa64radix16_test.c Change license 2020-12-27 17:18:44 -08:00
joinpaths_test.c Make improvements 2022-07-21 03:36:42 -07:00
lengthuint64_test.c Unbloat the build 2022-08-11 00:15:29 -07:00
palandprintf_test.c Fix memcpy(size=0) ubsan warning in vsnprintf() 2023-03-29 01:28:10 -07:00
printf_uppercase_e_static_yoink_test.c Fix PFLINK mechanism for uppercase float conversion specifiers (#796) 2023-03-29 22:18:59 -04:00
printf_uppercase_f_static_yoink_test.c Fix PFLINK mechanism for uppercase float conversion specifiers (#796) 2023-03-29 22:18:59 -04:00
printf_uppercase_g_static_yoink_test.c Fix PFLINK mechanism for uppercase float conversion specifiers (#796) 2023-03-29 22:18:59 -04:00
sizetol_test.c Make improvements 2022-08-15 15:20:36 -07:00
sleb128_test.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
snprintf_test.c Fix printf precision/field width being limited by internal buffer size (#799) 2023-04-04 14:16:34 -04:00
sprintf_s.inc Further refine printf long double change (#66) 2021-02-27 13:30:17 -08:00
sprintf_s_test.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
sscanf_test.c Fix scanf x specifier with string of 0 (#793) 2023-04-15 06:25:35 -07:00
strerror_r_test.c Fold LIBC_BITS into LIBC_INTRIN 2022-08-11 12:13:18 -07:00
stripexts_test.c Pay off more technical debt 2022-09-12 23:36:56 -07:00
test.mk Fix vfprintf and derived functions not handling write errors (#798) 2023-03-31 09:57:29 -04:00
timevaltofiletime_test.c Get more Python tests passing (#141) 2021-08-16 15:26:31 -07:00
uleb64_test.c Add Compress() and Uncompress() to redbean 2022-05-16 16:49:20 -07:00
uleb128_test.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
zleb64_test.c Pay off more technical debt 2022-09-12 23:36:56 -07:00