diff options
author | Jakub Jelinek <jakub@redhat.com> | 2011-02-15 13:51:48 -0500 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-02-15 13:51:48 -0500 |
commit | c1d0e639a95d6d3d3f1c1f70cf97d596bd5a24ec (patch) | |
tree | 89aae83ed132c200556941d9d481bd9bbc665ffb /stdio-common/_i18n_number.h | |
parent | edf9294e7a2cd46b050faf2d270d28ff477f6c5e (diff) | |
download | glibc-c1d0e639a95d6d3d3f1c1f70cf97d596bd5a24ec.tar.gz glibc-c1d0e639a95d6d3d3f1c1f70cf97d596bd5a24ec.tar.xz glibc-c1d0e639a95d6d3d3f1c1f70cf97d596bd5a24ec.zip |
Fix two printf handler issues.
Diffstat (limited to 'stdio-common/_i18n_number.h')
-rw-r--r-- | stdio-common/_i18n_number.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/stdio-common/_i18n_number.h b/stdio-common/_i18n_number.h index 8bb56190c6..43ed17e717 100644 --- a/stdio-common/_i18n_number.h +++ b/stdio-common/_i18n_number.h @@ -30,8 +30,8 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end) # 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 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end) 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 |