mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Further refine printf long double change (#66)
This commit is contained in:
parent
98fba078a3
commit
da199b7a45
2 changed files with 8 additions and 3 deletions
|
@ -121,6 +121,7 @@ static int ppatoi(const char **str) {
|
||||||
hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
|
hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
|
||||||
void *p;
|
void *p;
|
||||||
char qchar;
|
char qchar;
|
||||||
|
bool longdouble;
|
||||||
long double ldbl;
|
long double ldbl;
|
||||||
wchar_t charbuf[1];
|
wchar_t charbuf[1];
|
||||||
const char *alphabet;
|
const char *alphabet;
|
||||||
|
@ -209,6 +210,7 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
|
||||||
|
|
||||||
/* evaluate length field */
|
/* evaluate length field */
|
||||||
signbit = 31;
|
signbit = 31;
|
||||||
|
longdouble = false;
|
||||||
switch (*format) {
|
switch (*format) {
|
||||||
case 'j': /* intmax_t */
|
case 'j': /* intmax_t */
|
||||||
format++;
|
format++;
|
||||||
|
@ -224,10 +226,13 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
|
||||||
case 't': /* ptrdiff_t */
|
case 't': /* ptrdiff_t */
|
||||||
case 'z': /* size_t */
|
case 'z': /* size_t */
|
||||||
case 'Z': /* size_t */
|
case 'Z': /* size_t */
|
||||||
case 'L': /* long double */
|
|
||||||
format++;
|
format++;
|
||||||
signbit = 63;
|
signbit = 63;
|
||||||
break;
|
break;
|
||||||
|
case 'L': /* long double */
|
||||||
|
format++;
|
||||||
|
longdouble = true;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
format++;
|
format++;
|
||||||
if (*format == 'h') {
|
if (*format == 'h') {
|
||||||
|
@ -280,7 +285,7 @@ hidden int palandprintf(void *fn, void *arg, const char *format, va_list va) {
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'F':
|
case 'F':
|
||||||
if (signbit == 63) {
|
if (longdouble) {
|
||||||
ldbl = va_arg(va, long double);
|
ldbl = va_arg(va, long double);
|
||||||
} else {
|
} else {
|
||||||
ldbl = va_arg(va, double);
|
ldbl = va_arg(va, double);
|
||||||
|
|
|
@ -80,7 +80,7 @@ TEST(SUITE(snprintf), testReprChar16) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SUITE(snprintf), testReprChar32) {
|
TEST(SUITE(snprintf), testReprChar32) {
|
||||||
EXPECT_STREQ("L'♥'", Format("%`'Lc", L'♥'));
|
EXPECT_STREQ("L'♥'", Format("%`'lc", L'♥'));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SUITE(snprintf), testReprUtf8) {
|
TEST(SUITE(snprintf), testReprUtf8) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue