Further refine printf long double change (#66)

This commit is contained in:
Justine Tunney 2021-02-27 13:30:02 -08:00
parent 98fba078a3
commit da199b7a45
2 changed files with 8 additions and 3 deletions

View file

@ -121,6 +121,7 @@ static int ppatoi(const char **str) {
hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
void *p;
char qchar;
bool longdouble;
long double ldbl;
wchar_t charbuf[1];
const char *alphabet;
@ -209,6 +210,7 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
/* evaluate length field */
signbit = 31;
longdouble = false;
switch (*format) {
case 'j': /* intmax_t */
format++;
@ -224,10 +226,13 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
case 't': /* ptrdiff_t */
case 'z': /* size_t */
case 'Z': /* size_t */
case 'L': /* long double */
format++;
signbit = 63;
break;
case 'L': /* long double */
format++;
longdouble = true;
break;
case 'h':
format++;
if (*format == 'h') {
@ -280,7 +285,7 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
case 'f':
case 'F':
if (signbit == 63) {
if (longdouble) {
ldbl = va_arg(va, long double);
} else {
ldbl = va_arg(va, double);

View file

@ -80,7 +80,7 @@ TEST(SUITE(snprintf), testReprChar16) {
}
TEST(SUITE(snprintf), testReprChar32) {
EXPECT_STREQ("L'♥'", Format("%`'Lc", L'♥'));
EXPECT_STREQ("L'♥'", Format("%`'lc", L'♥'));
}
TEST(SUITE(snprintf), testReprUtf8) {