Skip to content

Commit c2167bc

Browse files
committed
crt/stdio: Fix thosand separators in printf128
This uses the same pattern with the other non-printf128 path. Here digits are written backwards i.e. from the least significant end to the most significant end, so they are counted as `p` is increased i.e. in humans' order from right to left. Signed-off-by: LIU Hao <[email protected]>
1 parent 328aa20 commit c2167bc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mingw-w64-crt/stdio/mingw_pformat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,8 @@ void __pformat_int( __pformat_intarg_t value, __pformat_t *stream )
779779

780780
memset(p,0,bufflen);
781781
for(int32_t i = strlen(tmp_buff) - 1; i >= 0; i--){
782-
if ( i && (stream->flags & PFORMAT_GROUPED) != 0 && stream->thousands_chr != 0
783-
&& (i % 4) == 3)
782+
if (p != buf && (stream->flags & PFORMAT_GROUPED) != 0 && stream->thousands_chr != 0
783+
&& ((p - buf) % 4) == 3)
784784
{
785785
*p++ = ',';
786786
}

0 commit comments

Comments
 (0)