diff --git a/libc/stdio/fmt.c b/libc/stdio/fmt.c index f5ea9739f22..0e44bbb46a0 100644 --- a/libc/stdio/fmt.c +++ b/libc/stdio/fmt.c @@ -272,8 +272,8 @@ static int __fmt_ntoa2(int out(const char *, void *, size_t), void *arg, digit &= (1u << log2base) - 1; value >>= log2base; } - if ((flags & FLAGS_GROUPING) && count == 3) { - buf[len++] = ','; + if ((flags & (FLAGS_GROUPING | FLAGS_QUOTE)) && count == 3) { + buf[len++] = (flags & FLAGS_QUOTE) ? '\'' : ','; count = 1; } else { count++; @@ -289,7 +289,7 @@ static int __fmt_ntoa2(int out(const char *, void *, size_t), void *arg, static int __fmt_ntoa(int out(const char *, void *, size_t), void *arg, uint128_t value, unsigned char signbit, unsigned long log2base, unsigned long prec, - unsigned long width, unsigned char flags, + unsigned long width, unsigned flags, const char *lang) { bool neg; uint128_t sign; diff --git a/test/libc/stdio/snprintf_test.c b/test/libc/stdio/snprintf_test.c index eeb520de556..cb82328242f 100644 --- a/test/libc/stdio/snprintf_test.c +++ b/test/libc/stdio/snprintf_test.c @@ -220,6 +220,6 @@ TEST(snprintf, testLongDoubleRounding) { TEST(snprintf, apostropheFlag) { char buf[20]; int i = snprintf(buf, sizeof(buf), "%'d", 1000000); - ASSERT_EQ(7, i); - ASSERT_STREQ("1000000", buf); + ASSERT_EQ(9, i); + ASSERT_STREQ("1'000'000", buf); }