[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r12870 - in /fsf/trunk/libc: ChangeLog stdio-common/_i18n_number.h stdio-common/printf-parsemb.c



Author: eglibc
Date: Wed Feb 16 00:03:27 2011
New Revision: 12870

Log:
Import glibc-mainline for 2011-02-16

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/stdio-common/_i18n_number.h
    fsf/trunk/libc/stdio-common/printf-parsemb.c

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Wed Feb 16 00:03:27 2011
@@ -1,3 +1,11 @@
+2011-02-11  Jakub Jelinek  <jakub@xxxxxxxxxx>
+
+	* stdio-common/printf-parsemb.c (__parse_one_specmb): Handle
+	arginfo fn returning -1.
+
+	* stdio-common/_i18n_number.h (_i18n_number_rewrite): Ensure decimal
+	and thousands string is zero terminated.
+
 2011-02-03  Andreas Schwab  <schwab@xxxxxxxxxx>
 
 	* sysdeps/unix/sysv/linux/sparc/bits/socket.h: Sync with

Modified: fsf/trunk/libc/stdio-common/_i18n_number.h
==============================================================================
--- fsf/trunk/libc/stdio-common/_i18n_number.h (original)
+++ fsf/trunk/libc/stdio-common/_i18n_number.h Wed Feb 16 00:03:27 2011
@@ -30,8 +30,8 @@
 # define decimal NULL
 # define thousands NULL
 #else
-  char decimal[MB_LEN_MAX];
-  char thousands[MB_LEN_MAX];
+  char decimal[MB_LEN_MAX + 1];
+  char thousands[MB_LEN_MAX + 1];
 #endif
 
   /* "to_outpunct" is a map from ASCII decimal point and thousands-sep
@@ -47,13 +47,19 @@
       mbstate_t state;
       memset (&state, '\0', sizeof (state));
 
-      if (__wcrtomb (decimal, wdecimal, &state) == (size_t) -1)
+      size_t n = __wcrtomb (decimal, wdecimal, &state);
+      if (n == (size_t) -1)
 	memcpy (decimal, ".", 2);
+      else
+	decimal[n] = '\0';
 
       memset (&state, '\0', sizeof (state));
 
-      if (__wcrtomb (thousands, wthousands, &state) == (size_t) -1)
+      n = __wcrtomb (thousands, wthousands, &state);
+      if (n == (size_t) -1)
 	memcpy (thousands, ",", 2);
+      else
+	thousands[n] = '\0';
     }
 #endif
 

Modified: fsf/trunk/libc/stdio-common/printf-parsemb.c
==============================================================================
--- fsf/trunk/libc/stdio-common/printf-parsemb.c (original)
+++ fsf/trunk/libc/stdio-common/printf-parsemb.c Wed Feb 16 00:03:27 2011
@@ -295,9 +295,9 @@
       /* We don't try to get the types for all arguments if the format
 	 uses more than one.  The normal case is covered though.  If
 	 the call returns -1 we continue with the normal specifiers.  */
-      || (spec->ndata_args = (*__printf_arginfo_table[spec->info.spec])
-	  (&spec->info, 1, &spec->data_arg_type,
-	   &spec->size)) < 0)
+      || (int) (spec->ndata_args = (*__printf_arginfo_table[spec->info.spec])
+				   (&spec->info, 1, &spec->data_arg_type,
+				    &spec->size)) < 0)
     {
       /* Find the data argument types of a built-in spec.  */
       spec->ndata_args = 1;