mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 08:11:08 +00:00
(_i18n_number_rewrite): Few more changes to make the code smaller.
This commit is contained in:
parent
43e56b0efc
commit
3bd6014e8f
@ -27,13 +27,9 @@ static CHAR_T *
|
|||||||
_i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr)
|
_i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr)
|
||||||
{
|
{
|
||||||
#ifdef COMPILE_WPRINTF
|
#ifdef COMPILE_WPRINTF
|
||||||
wint_t wdecimal = L'\0';
|
|
||||||
wint_t wthousands = L'\0';
|
|
||||||
# define decimal NULL
|
# define decimal NULL
|
||||||
# define thousands NULL
|
# define thousands NULL
|
||||||
#else
|
#else
|
||||||
wint_t wdecimal = L'\0';
|
|
||||||
wint_t wthousands = L'\0';
|
|
||||||
char decimal[MB_LEN_MAX];
|
char decimal[MB_LEN_MAX];
|
||||||
char thousands[MB_LEN_MAX];
|
char thousands[MB_LEN_MAX];
|
||||||
#endif
|
#endif
|
||||||
@ -42,12 +38,12 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr)
|
|||||||
to their equivalent in locale. This is defined for locales which
|
to their equivalent in locale. This is defined for locales which
|
||||||
use extra decimal point and thousands-sep. */
|
use extra decimal point and thousands-sep. */
|
||||||
wctrans_t map = __wctrans ("to_outpunct");
|
wctrans_t map = __wctrans ("to_outpunct");
|
||||||
if (map != NULL)
|
wint_t wdecimal = __towctrans (L'.', map);
|
||||||
{
|
wint_t wthousands = __towctrans (L',', map);
|
||||||
wdecimal = __towctrans (L'.', map);
|
|
||||||
wthousands = __towctrans (L',', map);
|
|
||||||
|
|
||||||
#ifndef COMPILE_WPRINTF
|
#ifndef COMPILE_WPRINTF
|
||||||
|
if (__builtin_expect (map != NULL, 0))
|
||||||
|
{
|
||||||
mbstate_t state;
|
mbstate_t state;
|
||||||
memset (&state, '\0', sizeof (state));
|
memset (&state, '\0', sizeof (state));
|
||||||
|
|
||||||
@ -58,8 +54,8 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr)
|
|||||||
|
|
||||||
if (__wcrtomb (thousands, wthousands, &state) == (size_t) -1)
|
if (__wcrtomb (thousands, wthousands, &state) == (size_t) -1)
|
||||||
memcpy (thousands, ",", 2);
|
memcpy (thousands, ",", 2);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Copy existing string so that nothing gets overwritten. */
|
/* Copy existing string so that nothing gets overwritten. */
|
||||||
CHAR_T *src = (CHAR_T *) alloca ((rear_ptr - w) * sizeof (CHAR_T));
|
CHAR_T *src = (CHAR_T *) alloca ((rear_ptr - w) * sizeof (CHAR_T));
|
||||||
|
Loading…
Reference in New Issue
Block a user