在 2025-10-8 18:12, Peter Damianov via Mingw-w64-public 写道:
Remove incorrect width adjustment that prevented proper padding with spaces for %g format specifier when the value has trailing zeros in the integer part.The original code would reduce the field width when precision became negative (e.g., for 100000.0, precision = strlen("1") - 6 = -5), causing the output to lose its padding: printf("(%10g)\n", 100000.0f); // was: (100000), expected: ( 100000) The fix clamps negative precision to 0 instead of adjusting the width, preserving the requested field width for proper padding. Adds test case t_printf_g_width. ref: https://github.com/skeeto/w64devkit/issues/269 Signed-off-by: Peter Damianov <[email protected]> --- v4: restore changes to Makefile.am add comment clarifying fix further mingw-w64-crt/stdio/mingw_pformat.c | 16 ++++++++-------- mingw-w64-crt/testcases/Makefile.am | 1 + mingw-w64-crt/testcases/t_printf_g_width.c | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 mingw-w64-crt/testcases/t_printf_g_width.c
Thanks for the patch. Pushed now. -- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
