summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/printf-parse.h4
-rw-r--r--stdio-common/tst-sprintf.c23
-rw-r--r--stdio-common/vfprintf.c12
3 files changed, 27 insertions, 12 deletions
diff --git a/stdio-common/printf-parse.h b/stdio-common/printf-parse.h
index eff2816607..ed0dc8bbc8 100644
--- a/stdio-common/printf-parse.h
+++ b/stdio-common/printf-parse.h
@@ -51,17 +51,13 @@ struct printf_spec
 /* The various kinds off arguments that can be passed to printf.  */
 union printf_arg
   {
-    unsigned char pa_char;
     wchar_t pa_wchar;
-    short int pa_short_int;
     int pa_int;
     long int pa_long_int;
     long long int pa_long_long_int;
-    unsigned short int pa_u_short_int;
     unsigned int pa_u_int;
     unsigned long int pa_u_long_int;
     unsigned long long int pa_u_long_long_int;
-    float pa_float;
     double pa_double;
     long double pa_long_double;
     const char *pa_string;
diff --git a/stdio-common/tst-sprintf.c b/stdio-common/tst-sprintf.c
index afbacd9037..b20561ebfd 100644
--- a/stdio-common/tst-sprintf.c
+++ b/stdio-common/tst-sprintf.c
@@ -11,9 +11,30 @@ main (void)
   if (sprintf (buf, "%.0ls", L"foo") != 0
       || strlen (buf) != 0)
     {
-      puts ("sprintf (buf, \"%.0ls\", L\"foo\") produced some output\n");
+      puts ("sprintf (buf, \"%.0ls\", L\"foo\") produced some output");
       result = 1;
     }
 
+#define SIZE (1024*70000)
+#define STR(x) #x
+
+  char *dst = malloc (SIZE + 1);
+
+  if (dst == NULL)
+    {
+      puts ("memory allocation failure");
+      result = 1;
+    }
+  else
+    {
+      sprintf (dst, "%*s", SIZE, "");
+      if (strnlen (dst, SIZE + 1) != SIZE)
+	{
+	  puts ("sprintf (dst, \"%*s\", " STR(SIZE) ", \"\") did not produce enough output");
+	  result = 1;
+	}
+      free (dst);
+    }
+
   return result;
 }
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index f8e01b73a1..63440f4b76 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -581,10 +581,8 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 	  else								      \
 	    if (is_long_num)						      \
 	      signed_number = args_value[fspec->data_arg].pa_long_int;	      \
-	    else if (!is_short)						      \
+	    else  /* `char' and `short int' will be promoted to `int'.  */    \
 	      signed_number = args_value[fspec->data_arg].pa_int;	      \
-	    else	      						      \
-	      signed_number = args_value[fspec->data_arg].pa_short_int;	      \
 									      \
 	  is_negative = signed_number < 0;				      \
 	  number.word = is_negative ? (- signed_number) : signed_number;      \
@@ -675,12 +673,12 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 	      number.word = args_value[fspec->data_arg].pa_u_long_int;	      \
 	    else if (is_char)						      \
 	      number.word = (unsigned char)				      \
-		args_value[fspec->data_arg].pa_char;			      \
+		args_value[fspec->data_arg].pa_u_int;			      \
 	    else if (!is_short)						      \
 	      number.word = args_value[fspec->data_arg].pa_u_int;	      \
 	    else							      \
 	      number.word = (unsigned short int)			      \
-		args_value[fspec->data_arg].pa_u_short_int;		      \
+		args_value[fspec->data_arg].pa_u_int;			      \
 									      \
 	LABEL (number):							      \
 	  if (prec < 0)							      \
@@ -977,7 +975,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 	outchar (__btowc ((unsigned char) va_arg (ap, int))); /* Promoted. */ \
       else								      \
 	outchar (__btowc ((unsigned char)				      \
-			  args_value[fspec->data_arg].pa_char));	      \
+			  args_value[fspec->data_arg].pa_int));		      \
       if (left)								      \
 	PAD (L' ');							      \
       break;								      \
@@ -1096,7 +1094,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       if (fspec == NULL)						      \
 	outchar ((unsigned char) va_arg (ap, int)); /* Promoted.  */	      \
       else								      \
-	outchar ((unsigned char) args_value[fspec->data_arg].pa_char);	      \
+	outchar ((unsigned char) args_value[fspec->data_arg].pa_int);	      \
       if (left)								      \
 	PAD (' ');							      \
       break;								      \