Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
	* 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.
  • Loading branch information
Ulrich Drepper committed Jul 1, 2000
1 parent 7f45535 commit 3da67f9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 69 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
2000-06-30 Ulrich Drepper <drepper@redhat.com>

* 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.

* iconv/gconv_trans.c: Test with _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN
whether this information is available.

Expand Down
54 changes: 0 additions & 54 deletions localedata/tests-mbwc/dat_strfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@ TST_STRFMON tst_strfmon_loc [] = {
{
{
/* #01 */
#ifdef NO_WAIVER
/*inp*/ { 23, "%n %% %i", 123.00 },
/*exp*/ { 1,0,1,22, "123,00 DM % 123,00 DEM" },
#else
/*inp*/ { 24, "%n %% %i", 123.00 },
/*exp*/ { 1,0,1,23, "123,00 DM % 123,00 DEM " },
#endif
},
{
/* #02 */
#ifdef NO_WAIVER
/*inp*/ { 23, "%n %% %i", 123.00 },
/*exp*/ { 1,0,1,22, "123,00 DM % 123,00 DEM" },
#else
/*inp*/ { 24, "%n %% %i", 123.00 },
/*exp*/ { 1,0,1,23, "123,00 DM % 123,00 DEM " },
#endif
},
{
/* #03 */
Expand All @@ -46,101 +36,57 @@ TST_STRFMON tst_strfmon_loc [] = {
{
/* #04 */
/*inp*/ { 30, "%n|%i", 1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,24, "1.234,56 DM|1.234,56 DEM" },
#else
/*exp*/ { 1,0,1,25, "1.234,56 DM|1.234,56 DEM " },
#endif
},
{
/* #05 */
/*inp*/ { 32, "%n|%i", -1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,26, "-1.234,56 DM|-1.234,56 DEM"},
#else
/*exp*/ { 1,0,1,27, "-1.234,56 DM|-1.234,56 DEM "},
#endif
},
{
/* #06 */
/*inp*/ { 32, "%12n|%12i", 1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,25, " 1.234,56 DM|1.234,56 DEM"},
#else
/*exp*/ { 1,0,1,26, " 1.234,56 DM|1.234,56 DEM "},
#endif
},
{
/* #07 */
/*inp*/ { 32, "%12n|%12i", -1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,26, "-1.234,56 DM|-1.234,56 DEM"},
#else
/*exp*/ { 1,0,1,27, "-1.234,56 DM|-1.234,56 DEM "},
#endif
},
{
/* #08 */
/*inp*/ { 32, "%#5n|%#5i", 1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,28, " 1.234,56 DM| 1.234,56 DEM"},
#else
/*exp*/ { 1,0,1,29, " 1.234,56 DM| 1.234,56 DEM "},
#endif
},
{
/* #09 */
/*inp*/ { 32, "%#5n|%#5i", -1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,28, "- 1.234,56 DM|- 1.234,56 DEM"},
#else
/*exp*/ { 1,0,1,29, "- 1.234,56 DM|- 1.234,56 DEM "},
#endif
},
{
/* #10 */
/*inp*/ { 32, "%=*#5n|%=*#5i", 1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,28, " *1.234,56 DM| *1.234,56 DEM"},
#else
/*exp*/ { 1,0,1,29, " *1.234,56 DM| *1.234,56 DEM "},
#endif
},
{
/* #11 */
/*inp*/ { 32, "%=0#5n|%=0#5i", -1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,28, "-01.234,56 DM|-01.234,56 DEM"},
#else
/*exp*/ { 1,0,1,29, "-01.234,56 DM|-01.234,56 DEM "},
#endif
},
{
/* #12 */
/*inp*/ { 32, "%^#5n|%^#5i", -1234.561 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,26, "- 1234,56 DM|- 1234,56 DEM"},
#else
/*exp*/ { 1,0,1,27, "- 1234,56 DM|- 1234,56 DEM "},
#endif
},
{
/* #13 */
/*inp*/ { 32, "%#5.0n|%#5.0i", 1234.444 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,22, " 1.234 DM| 1.234 DEM" },
#else
/*exp*/ { 1,0,1,23, " 1.234 DM| 1.234 DEM " },
#endif
},
{
/* #14 */
/*inp*/ { 32, "%#5.0n|%#5.4i", -1234.555 },
#ifdef NO_WAIVER
/*exp*/ { 1,0,1,27, "- 1.235 DM|- 1.234,5550 DEM"},
#else
/*exp*/ { 1,0,1,28, "- 1.235 DM|- 1.234,5550 DEM "},
#endif
},
{
/* #15 */
Expand Down
18 changes: 9 additions & 9 deletions localedata/tst-fmon.data
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ de_DE.ISO-8859-1 %+n -1234.56 -1.234,56 DM
de_DE.ISO-8859-1 %(n 1234.56 1.234,56 DM
de_DE.ISO-8859-1 %(n -1234.56 (1.234,56 DM)
de_DE.ISO-8859-1 %^n 1234.56 1234,56 DM
de_DE.ISO-8859-1 %i 1.23 1,23 DEM
de_DE.ISO-8859-1 %i -1.23 -1,23 DEM
de_DE.ISO-8859-1 %i 1234.56 1.234,56 DEM
de_DE.ISO-8859-1 %^i 1234.56 1234,56 DEM
de_DE.ISO-8859-1 %+i 1234.56 1.234,56 DEM
de_DE.ISO-8859-1 %+i -1234.56 -1.234,56 DEM
de_DE.ISO-8859-1 %(i 1234.56 1.234,56 DEM
de_DE.ISO-8859-1 %(i -1234.56 (1.234,56 DEM )
de_DE.ISO-8859-1 %^i 1234.56 1234,56 DEM
de_DE.ISO-8859-1 %i 1.23 1,23 DEM
de_DE.ISO-8859-1 %i -1.23 -1,23 DEM
de_DE.ISO-8859-1 %i 1234.56 1.234,56 DEM
de_DE.ISO-8859-1 %^i 1234.56 1234,56 DEM
de_DE.ISO-8859-1 %+i 1234.56 1.234,56 DEM
de_DE.ISO-8859-1 %+i -1234.56 -1.234,56 DEM
de_DE.ISO-8859-1 %(i 1234.56 1.234,56 DEM
de_DE.ISO-8859-1 %(i -1234.56 (1.234,56 DEM)
de_DE.ISO-8859-1 %^i 1234.56 1234,56 DEM
de_DE.ISO-8859-1 %#5n 123.45 123,45 DM
de_DE.ISO-8859-1 %#5n -123.45 - 123,45 DM
de_DE.ISO-8859-1 %#5n 3456.781 3.456,78 DM
Expand Down
26 changes: 20 additions & 6 deletions stdlib/strfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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')


Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3da67f9

Please sign in to comment.