在 2025-10-16 08:03, Peter Damianov via Mingw-w64-public 写道:
Address review comment about redundant conditions in __bigint_to_stringb()
and __bigint_to_stringo() where 'pos < bufflen - 1' was always true since
pos starts from bufflen - 2 and breaks when reaching zero.

Fix loop bounds in __pformat_xint() to avoid accessing null terminators
by changing 'strlen(tmp_buf)' to 'strlen(tmp_buf)-1'. This fixes %o of a zero
int128 from printing '' (nothing) instead of the '0'.

Signed-off-by: Peter Damianov <[email protected]>
---
  mingw-w64-crt/stdio/mingw_pformat.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

Thanks for the patch. Pushed to master now.

I tried these arguments:

   printf("%I128o$\n", (struct { int64_t lo, hi; }) { 8070450532249983185, 
21399 });
   printf("%I128o$\n", (struct { int64_t lo, hi; }) { 0, 0 });
   printf("%-20I128o$\n", (struct { int64_t lo, hi; }) { 8070450532249983185, 
21399 });
   printf("%-20I128o$\n", (struct { int64_t lo, hi; }) { 0, 0 });
   printf("%20I128o$\n", (struct { int64_t lo, hi; }) { 8070450532249983185, 
21399 });
   printf("%20I128o$\n", (struct { int64_t lo, hi; }) { 0, 0 });

and the outputs seemed correct:

   123456700000000000007654321$
   0$
   123456700000000000007654321$
   0                   $
   123456700000000000007654321$
                      0$





--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to