]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Correctly handle %p in wprintf (BZ #16890)
authorAndreas Schwab <schwab@linux-m68k.org>
Thu, 1 May 2014 13:50:27 +0000 (15:50 +0200)
committerAndreas Schwab <schwab@linux-m68k.org>
Thu, 1 May 2014 18:42:08 +0000 (20:42 +0200)
ChangeLog
NEWS
stdio-common/tstdiomisc.c
stdio-common/vfprintf.c

index 08ec932dde63d5819ab0e305baf5894735bf8043..55724f6fef201beadae1686a9cd74e12230acfc9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-05-01  Andreas Schwab  <schwab@linux-m68k.org>
+
+       [BZ #16890]
+       * stdio-common/vfprintf.c (process_arg) [%p]: Mark string as wide
+       when compiling wprintf.
+       * stdio-common/tstdiomisc.c (t3): New function.
+       (main): Call it.
+
 2014-05-01  Steve Ellcey  <sellcey@mips.com>
 
        * intl/iconv/skeleton.c (ONE_DIRECTION): Remove define.
diff --git a/NEWS b/NEWS
index 5a690b8279450e0a02c30b556b3503e32c47fdde..f58437b03a7ad5a1f07c6fd6c2fa961381a21f0a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,7 +16,7 @@ Version 2.20
   16677, 16680, 16683, 16689, 16695, 16701, 16706, 16707, 16712, 16713,
   16714, 16731, 16739, 16740, 16743, 16754, 16758, 16759, 16760, 16770,
   16786, 16789, 16791, 16799, 16800, 16815, 16823, 16824, 16831, 16838,
-  16854, 16888.
+  16854, 16888, 16890.
 
 * The minimum Linux kernel version that this version of the GNU C Library
   can be used with is 2.6.32.
index 5a25ecc9f09e443f3f6e06ddee7132e44d1091bf..2e0663a5e5a22b211b3e952c67920a495391cb5d 100644 (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;
index f7e5f61cc8d3a8612af5b7d40b1b807eb3356089..c4ff8334b206fdeb3ae1e97ebec203552ca6a1ff 100644 (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);                                        \
          }                                                                   \
       }                                                                              \