1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

Correctly handle %p in wprintf (BZ #16890)

This commit is contained in:
Andreas Schwab
2014-05-01 15:50:27 +02:00
parent 0cdddc25a4
commit 4fdfe821e2
4 changed files with 30 additions and 2 deletions

View File

@@ -46,6 +46,24 @@ t2 (void)
return result;
}
static int
t3 (void)
{
char buf[80];
wchar_t wbuf[80];
int result = 0;
int retval;
retval = sprintf (buf, "%p", (char *) NULL);
result |= retval != 5 || strcmp (buf, "(nil)") != 0;
retval = swprintf (wbuf, sizeof (wbuf) / sizeof (wbuf[0]),
L"%p", (char *) NULL);
result |= retval != 5 || wcscmp (wbuf, L"(nil)") != 0;
return result;
}
volatile double qnanval;
volatile long double lqnanval;
/* A sNaN is only guaranteed to be representable in variables with static (or
@@ -243,6 +261,7 @@ main (int argc, char *argv[])
result |= t1 ();
result |= t2 ();
result |= t3 ();
result |= F ();
result |= fflush (stdout) == EOF;

View File

@@ -936,7 +936,8 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
/* Make sure the full string "(nil)" is printed. */ \
if (prec < 5) \
prec = 5; \
is_long = 0; /* This is no wide-char string. */ \
/* This is a wide string iff compiling wprintf. */ \
is_long = sizeof (CHAR_T) > 1; \
goto LABEL (print_string); \
} \
} \