cosmopolitan/test/libc/fmt
Gabriel Ravier 12e07798df
Fix printf precision/field width being limited by internal buffer size (#799)
The C standard, when defining field width and precision, never gives
any limit on the values used for them (except, I believe, that they
fit within an int). In other words, if the user gives a field width of
32145 and a precision of 9218, the implementation has to handle these
values correctly. However, when such kinds of high numbers are used
with integer conversions, cosmopolitan is limited by an internal
buffer size of 144, which means precisions and field widths have to
fit within this, which violates the standard.

This means that for example, the following program:

 #include <stdio.h>
 #include <string.h>

int main()
{
    char buf2[512] = {};

    int i = snprintf(buf2, sizeof(buf2), "%.9999u", 10);
    printf("%d %zu\n", i, strlen(buf2));
}

would, instead of printing "9999 511" (the correct output), instead
print "144 144" under cosmopolitan.

This patch fixes this.
2023-04-04 14:16:34 -04: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 inttypes.h FAST16 macros to have a correct definition (#791) 2023-03-29 00:19:40 -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