diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-07-01 00:39:39 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-07-01 00:39:39 +0000 |
commit | 3da67f9970670030fdc273455b08606170183489 (patch) | |
tree | 3ffb811177f74e2295f8e70102effe21fff68585 /stdlib | |
parent | 7f4553513cc2e247fa40ba80485f41e942ba6c9b (diff) | |
download | glibc-3da67f9970670030fdc273455b08606170183489.tar glibc-3da67f9970670030fdc273455b08606170183489.tar.gz glibc-3da67f9970670030fdc273455b08606170183489.tar.bz2 glibc-3da67f9970670030fdc273455b08606170183489.zip |
Update.
* stdlib/strfmon.c: Move somewhat closer to the standard wrt to
handling the internation currency symbol. POSIX says that the
fourth character is used to separate the currency symbol from the
value. Therefore it does not have to be printed. But we cannot
remove the space if the currency symbol is printed before the
number since this is what many locales expect.
* localedata/tests-mbwc/dat_strfmon.c: Remove #ifdefs introduced to
work around DEM problem.
* localedata/tst-fmon.data: Change back entries with DEM.
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/strfmon.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/stdlib/strfmon.c b/stdlib/strfmon.c index 50b87dff82..28249c1f62 100644 --- a/stdlib/strfmon.c +++ b/stdlib/strfmon.c @@ -52,6 +52,14 @@ out_char (*_s++); \ } while (0) +#define out_nstring(String, N) \ + do { \ + int _n = (N); \ + const char *_s = (String); \ + while (_n-- > 0) \ + out_char (*_s++); \ + } while (0) + #define to_digit(Ch) ((Ch) - '0') @@ -136,9 +144,11 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) const char *other_sign_string; int done; const char *currency_symbol; + size_t currency_symbol_len; int width; char *startp; const void *ptr; + char space_char; /* Process all character which do not introduce a format specification. */ @@ -294,6 +304,8 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) { case 'i': /* Use international currency symbol. */ currency_symbol = _NL_CURRENT (LC_MONETARY, INT_CURR_SYMBOL); + currency_symbol_len = 3; + space_char = currency_symbol[3]; if (right_prec == -1) { if (*_NL_CURRENT (LC_MONETARY, INT_FRAC_DIGITS) == CHAR_MAX) @@ -304,6 +316,8 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) break; case 'n': /* Use national currency symbol. */ currency_symbol = _NL_CURRENT (LC_MONETARY, CURRENCY_SYMBOL); + currency_symbol_len = strlen (currency_symbol); + space_char = ' '; if (right_prec == -1) { if (*_NL_CURRENT (LC_MONETARY, FRAC_DIGITS) == CHAR_MAX) @@ -424,14 +438,14 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) preceding the value */ if (cs_precedes) { - left_bytes += strlen (currency_symbol); + left_bytes += currency_symbol_len; if (sep_by_space != 0) ++left_bytes; } if (other_cs_precedes) { - other_left_bytes += strlen (currency_symbol); + other_left_bytes += currency_symbol_len; if (other_sep_by_space != 0) ++other_left_bytes; } @@ -491,7 +505,7 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) if (sign_posn == 4) { if (sep_by_space == 2) - out_char (' '); + out_char (space_char); out_string (sign_string); if (sep_by_space == 1) /* POSIX.2 and SUS are not clear on this case, but C99 @@ -500,7 +514,7 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) } else if (sep_by_space == 1) - out_char (' '); + out_char (space_char); } } else @@ -580,8 +594,8 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) || (sign_posn == 2 && sep_by_space == 1) || (sign_posn == 1 && sep_by_space == 1) || (sign_posn == 0 && sep_by_space == 1)) - out_char (' '); - out_string (currency_symbol); + out_char (space_char); + out_nstring (currency_symbol, currency_symbol_len); if (sign_posn == 4) { if (sep_by_space == 2) |