about summary refs log tree commit diff
path: root/stdio-common/printf_fp.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/printf_fp.c')
-rw-r--r--stdio-common/printf_fp.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index c75289a3a9..1b550abe4f 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -52,11 +52,12 @@
    the GNU I/O library.	 */
 #ifdef USE_IN_LIBIO
 #  define PUT(f, s, n) _IO_sputn (f, s, n)
-#  define PAD(f, c, n) _IO_padn (f, c, n)
+#  define PAD(f, c, n) (wide ? _IO_wpadn (f, c, n) : _IO_padn (f, c, n))
 /* We use this file GNU C library and GNU I/O library.	So make
    names equal.	 */
 #  undef putc
-#  define putc(c, f) _IO_putc_unlocked (c, f)
+#  define putc(c, f) (wide \
+		      ? _IO_putwc_unlocked (c, f) : _IO_putc_unlocked (c, f))
 #  define size_t     _IO_size_t
 #  define FILE	     _IO_FILE
 #else	/* ! USE_IN_LIBIO */
@@ -188,6 +189,9 @@ __printf_fp (FILE *fp,
   /* General helper (carry limb).  */
   mp_limb_t cy;
 
+  /* Nonzero if this is output on a wide character stream.  */
+  int wide = info->wide;
+
   char hack_digit (void)
     {
       mp_limb_t hi;
@@ -765,7 +769,10 @@ __printf_fp (FILE *fp,
 	if ((expsign == 0 && exponent >= dig_max)
 	    || (expsign != 0 && exponent > 4))
 	  {
-	    type = isupper (info->spec) ? 'E' : 'e';
+	    if ('g' - 'G' == 'e' - 'E')
+	      type = 'E' + (info->spec - 'G');
+	    else
+	      type = isupper (info->spec) ? 'E' : 'e';
 	    fracdig_max = dig_max - 1;
 	    intdig_max = 1;
 	    chars_needed = 1 + 1 + fracdig_max + 1 + 1 + 4;