Hi,
On native Windows with the UCRT (mingw-w64, GCC 14.2), in a testdir
created with
gnulib-tool --create-testdir --dir=testdir \
vasnprintf-posix vasnwprintf-posix
at commit eedf47b2d43288f528db62ccd1cd2ce55eda92d4, where configure
defines NEED_PRINTF_DOUBLE, vasnprintf prints the exponent of a double
with three digits, and that of a long double with two:
vasnprintf (NULL, &len, "%e", 1e-5) => "1.000000e-005"
vasnprintf (NULL, &len, "%g", 1e-5) => "1e-005"
vasnprintf (NULL, &len, "%Le", 1e-5L) => "1.000000e-05"
The UCRT's own printf and mingw-w64's both give "1.000000e-05" and
"1e-05" for the first two.
I understand this is deliberate: lib/vasnprintf.c uses "%+.3d" when
_WIN32 is defined and __CYGWIN__ is not, to "produce the same number
of exponent digits as the native printf implementation", and
tests/test-vasnprintf-posix2.c and tests/test-vasnwprintf-posix2.c
expect "3,1416e+009" there ("Native Windows uses 3 digits for the
exponent"). That holds for msvcrt.dll, but not for the UCRT, which
prints two digits. The code for long double uses "%+.2d"
unconditionally.
Would it make sense to exclude the UCRT there? I tried adding
"&& ! defined _UCRT" to the five such conditions in the code for
double (four choose the format string, one adds a third "0" to the
exponent of a zero). The output then has two digits throughout, and
"make check" in the testdir fails only in the two tests named above,
at the assertions which expect three digits
(test-vasnprintf-posix2.c:365, test-vasnwprintf-posix2.c:299); they
would need the same condition.
Thanks,
Kevin