+2003-11-30 Petter Reinholdtsen <pere@hungry.com>
+
+ * stdlib/strfmon.c: Correct formatting of international currency
+ values. The international currency formatting should prefer the
+ int_* values if they are set for a locale, and use the domestic
+ values if the int_* values are unset.
+
2003-12-03 Jakub Jelinek <jakub@redhat.com>
* posix/Makefile (distribute): Add BOOST.tests.
+2003-11-30 Petter Reinholdtsen <pere@hungry.com>
+
+ * tst-fmon.sh: Allow quotes around the result string, to make it
+ easier to see important whitespace.
+ * tst-fmon.data: Likewise.
+
+ * tst-fmon.sh: Clean up output, unify capitalization and output order.
+ * tst-fmon.c: Likewise.
+
+ * tst-fmon.data: Add test for international currency formatting.
+ * tst-fmon-locales/tstfmon_n01y12: Add definitions for int_* fields.
+ * tst-fmon-locales/tstfmon_n02n40: Likewise.
+ * tst-fmon-locales/tstfmon_n10y31: Likewise.
+ * tst-fmon-locales/tstfmon_n11y41: Likewise.
+ * tst-fmon-locales/tstfmon_n12y11: Likewise.
+ * tst-fmon-locales/tstfmon_n20n32: Likewise.
+ * tst-fmon-locales/tstfmon_n30y20: Likewise.
+ * tst-fmon-locales/tstfmon_n41n00: Likewise.
+ * tst-fmon-locales/tstfmon_y01y10: Likewise.
+ * tst-fmon-locales/tstfmon_y02n22: Likewise.
+ * tst-fmon-locales/tstfmon_y22n42: Likewise.
+ * tst-fmon-locales/tstfmon_y30y21: Likewise.
+ * tst-fmon-locales/tstfmon_y32n31: Likewise.
+ * tst-fmon-locales/tstfmon_y40y00: Likewise.
+ * tst-fmon-locales/tstfmon_y42n21: Likewise.
+
+ * locales/en_US: Correct spacing for international
+ currency formatting, now that strfmon() works better.
+
+ * locales/ja_JP: Correct currency position and
+ spacing now that strfmon() work better.
+
2003-12-03 Ulrich Drepper <drepper@redhat.com>
* locales/af_ZA: Add ISO 3166 information.
int_frac_digits 2
frac_digits 2
p_cs_precedes 1
+int_p_sep_by_space 1
p_sep_by_space 0
n_cs_precedes 1
+int_n_sep_by_space 1
n_sep_by_space 0
p_sign_posn 1
n_sign_posn 1
p_sep_by_space 0
n_cs_precedes 1
n_sep_by_space 0
-p_sign_posn 1
+p_sign_posn 4
n_sign_posn 4
+int_p_sep_by_space 2
+int_n_sep_by_space 2
END LC_MONETARY
n_cs_precedes 1
n_sign_posn 1
n_sep_by_space 2
+int_p_cs_precedes 0
+int_p_sign_posn 0
+int_p_sep_by_space 1
+int_n_cs_precedes 1
+int_n_sign_posn 1
+int_n_sep_by_space 2
END LC_MONETARY
n_cs_precedes 0
n_sign_posn 4
n_sep_by_space 0
+int_p_cs_precedes 0
+int_p_sign_posn 0
+int_p_sep_by_space 2
+int_n_cs_precedes 0
+int_n_sign_posn 4
+int_n_sep_by_space 0
END LC_MONETARY
n_cs_precedes 1
n_sign_posn 3
n_sep_by_space 1
+int_p_cs_precedes 0
+int_p_sign_posn 1
+int_p_sep_by_space 0
+int_n_cs_precedes 1
+int_n_sign_posn 3
+int_n_sep_by_space 1
END LC_MONETARY
n_cs_precedes 1
n_sign_posn 4
n_sep_by_space 1
+int_p_cs_precedes 0
+int_p_sign_posn 1
+int_p_sep_by_space 1
+int_n_cs_precedes 1
+int_n_sign_posn 4
+int_n_sep_by_space 1
END LC_MONETARY
n_cs_precedes 1
n_sign_posn 1
n_sep_by_space 1
+int_p_cs_precedes 0
+int_p_sign_posn 1
+int_p_sep_by_space 2
+int_n_cs_precedes 1
+int_n_sign_posn 1
+int_n_sep_by_space 1
END LC_MONETARY
n_cs_precedes 0
n_sign_posn 3
n_sep_by_space 2
+int_p_cs_precedes 0
+int_p_sign_posn 2
+int_p_sep_by_space 0
+int_n_cs_precedes 0
+int_n_sign_posn 3
+int_n_sep_by_space 2
END LC_MONETARY
n_cs_precedes 1
n_sign_posn 2
n_sep_by_space 0
+int_p_cs_precedes 0
+int_p_sign_posn 3
+int_p_sep_by_space 0
+int_n_cs_precedes 1
+int_n_sign_posn 2
+int_n_sep_by_space 0
END LC_MONETARY
n_cs_precedes 0
n_sign_posn 0
n_sep_by_space 0
+int_p_cs_precedes 0
+int_p_sign_posn 4
+int_p_sep_by_space 1
+int_n_cs_precedes 0
+int_n_sign_posn 0
+int_n_sep_by_space 0
END LC_MONETARY
n_cs_precedes 1
n_sign_posn 1
n_sep_by_space 0
+int_p_cs_precedes 1
+int_p_sign_posn 0
+int_p_sep_by_space 1
+int_n_cs_precedes 1
+int_n_sign_posn 1
+int_n_sep_by_space 0
END LC_MONETARY
n_cs_precedes 0
n_sign_posn 2
n_sep_by_space 2
+int_p_cs_precedes 1
+int_p_sign_posn 0
+int_p_sep_by_space 2
+int_n_cs_precedes 0
+int_n_sign_posn 2
+int_n_sep_by_space 2
END LC_MONETARY
n_cs_precedes 0
n_sign_posn 4
n_sep_by_space 2
+int_p_cs_precedes 1
+int_p_sign_posn 2
+int_p_sep_by_space 2
+int_n_cs_precedes 0
+int_n_sign_posn 4
+int_n_sep_by_space 2
END LC_MONETARY
n_cs_precedes 1
n_sign_posn 2
n_sep_by_space 1
+int_p_cs_precedes 1
+int_p_sign_posn 3
+int_p_sep_by_space 0
+int_n_cs_precedes 1
+int_n_sign_posn 2
+int_n_sep_by_space 1
END LC_MONETARY
n_cs_precedes 0
n_sign_posn 3
n_sep_by_space 1
+int_p_cs_precedes 1
+int_p_sign_posn 3
+int_p_sep_by_space 2
+int_n_cs_precedes 0
+int_n_sign_posn 3
+int_n_sep_by_space 1
END LC_MONETARY
n_cs_precedes 1
n_sign_posn 0
n_sep_by_space 0
+int_p_cs_precedes 1
+int_p_sign_posn 4
+int_p_sep_by_space 0
+int_n_cs_precedes 1
+int_n_sign_posn 0
+int_n_sep_by_space 0
END LC_MONETARY
n_cs_precedes 0
n_sign_posn 2
n_sep_by_space 1
+int_p_cs_precedes 1
+int_p_sign_posn 4
+int_p_sep_by_space 2
+int_n_cs_precedes 0
+int_n_sign_posn 2
+int_n_sep_by_space 1
END LC_MONETARY
if (strcmp (s, argv[4]) != 0)
{
printf ("\
-locale: \"%s\", format: \"%s\", expected: \"%s\", got: \"%s\" => %s\n",
- argv[1], argv[2], argv[4], s,
+Locale: \"%s\" Format: \"%s\" Value: \"%s\" Recieved: \"%s\" Expected: \"%s\" => %s\n",
+ argv[1], argv[2], argv[3], s, argv[4],
strcmp (s, argv[4]) != 0 ? "false" : "correct");
exit (EXIT_FAILURE);
}
# Test data for test-strfmon, which checks it's implementation in glibc
-# Copyright (C) 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 2000, 2002, 2003 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
#
# #2 format string which is fed into strfmon
# #3 double value that is used for formatting
# #4 the expected result (may contain trailing spaces!)
+# This field might be enclosed with "" to make it easier to see
+# the white space
#
# First the implementation without any locale-dependent data
# - no currency symbol is printed, formatting is somewhat standard
tstfmon_y42n21 %11n -123.45 123.45 $-
tstfmon_y42n21 %^=*#5n 123.45 $ +**123.45
tstfmon_y42n21 %^=*#5n -123.45 **123.45 $-
+#
+# check all int_cs_precedes/int_sign_posn/int_sep_by_space
+# combinations using special test locales. The six characters after
+# the "_" indicate these three values for positive and then negative
+# quantities.
+#
+tstfmon_n01y12 %i 123.45 "123.45 USC"
+tstfmon_n01y12 %i -123.45 "- USC123.45"
+tstfmon_n01y12 %13i 123.45 " 123.45 USC"
+tstfmon_n01y12 %13i -123.45 " - USC123.45"
+tstfmon_n01y12 %^=*#5i 123.45 " **123.45 USC"
+tstfmon_n01y12 %^=*#5i -123.45 "- USC**123.45"
+#
+tstfmon_n02n40 %i 123.45 "123.45USC"
+tstfmon_n02n40 %i -123.45 "123.45USC-"
+tstfmon_n02n40 %13i 123.45 " 123.45USC"
+tstfmon_n02n40 %13i -123.45 " 123.45USC-"
+tstfmon_n02n40 %^=*#5i 123.45 "**123.45USC"
+tstfmon_n02n40 %^=*#5i -123.45 "**123.45USC-"
+#
+tstfmon_n10y31 %i 123.45 "+123.45USC"
+tstfmon_n10y31 %i -123.45 "-USC 123.45"
+tstfmon_n10y31 %13i 123.45 " +123.45USC"
+tstfmon_n10y31 %13i -123.45 " -USC 123.45"
+tstfmon_n10y31 %^=*#5i 123.45 " +**123.45USC"
+tstfmon_n10y31 %^=*#5i -123.45 "-USC **123.45"
+#
+tstfmon_n11y41 %i 123.45 "+123.45 USC"
+tstfmon_n11y41 %i -123.45 "USC- 123.45"
+tstfmon_n11y41 %13i 123.45 " +123.45 USC"
+tstfmon_n11y41 %13i -123.45 " USC- 123.45"
+tstfmon_n11y41 %^=*#5i 123.45 " +**123.45 USC"
+tstfmon_n11y41 %^=*#5i -123.45 "USC- **123.45"
+#
+tstfmon_n12y11 %i 123.45 "+123.45USC"
+tstfmon_n12y11 %i -123.45 "-USC 123.45"
+tstfmon_n12y11 %13i 123.45 " +123.45USC"
+tstfmon_n12y11 %13i -123.45 " -USC 123.45"
+tstfmon_n12y11 %^=*#5i 123.45 " +**123.45USC"
+tstfmon_n12y11 %^=*#5i -123.45 "-USC **123.45"
+#
+tstfmon_n20n32 %i 123.45 "123.45USC+"
+tstfmon_n20n32 %i -123.45 "123.45- USC"
+tstfmon_n20n32 %13i 123.45 " 123.45USC+"
+tstfmon_n20n32 %13i -123.45 " 123.45- USC"
+tstfmon_n20n32 %^=*#5i 123.45 "**123.45USC+"
+tstfmon_n20n32 %^=*#5i -123.45 "**123.45- USC"
+#
+tstfmon_n30y20 %i 123.45 "123.45+USC"
+tstfmon_n30y20 %i -123.45 "USC123.45-"
+tstfmon_n30y20 %13i 123.45 " 123.45+USC"
+tstfmon_n30y20 %13i -123.45 " USC123.45-"
+tstfmon_n30y20 %^=*#5i 123.45 " **123.45+USC"
+tstfmon_n30y20 %^=*#5i -123.45 "USC**123.45-"
+#
+tstfmon_n41n00 %i 123.45 "123.45 USC+"
+tstfmon_n41n00 %i -123.45 "(123.45USC)"
+tstfmon_n41n00 %13i 123.45 " 123.45 USC+"
+tstfmon_n41n00 %13i -123.45 " (123.45USC)"
+tstfmon_n41n00 %^=*#5i 123.45 " **123.45 USC+"
+tstfmon_n41n00 %^=*#5i -123.45 "(**123.45USC)"
+#
+tstfmon_y01y10 %i 123.45 "USC 123.45"
+tstfmon_y01y10 %i -123.45 "-USC123.45"
+tstfmon_y01y10 %13i 123.45 " USC 123.45"
+tstfmon_y01y10 %13i -123.45 " -USC123.45"
+tstfmon_y01y10 %^=*#5i 123.45 "USC **123.45"
+tstfmon_y01y10 %^=*#5i -123.45 "-USC**123.45"
+#
+tstfmon_y02n22 %i 123.45 "USC123.45"
+tstfmon_y02n22 %i -123.45 "123.45USC O/D"
+tstfmon_y02n22 %12i 123.45 " USC123.45"
+tstfmon_y02n22 %12i -123.45 "123.45USC O/D"
+tstfmon_y02n22 %^=*#5i 123.45 "USC**123.45"
+tstfmon_y02n22 %^=*#5i -123.45 " **123.45USC O/D"
+#
+tstfmon_y22n42 %i 123.45 "USC123.45+"
+tstfmon_y22n42 %i -123.45 "123.45USC -"
+tstfmon_y22n42 %13i 123.45 " USC123.45+"
+tstfmon_y22n42 %13i -123.45 " 123.45USC -"
+tstfmon_y22n42 %^=*#5i 123.45 "USC**123.45+"
+tstfmon_y22n42 %^=*#5i -123.45 " **123.45USC -"
+#
+tstfmon_y30y21 %i 123.45 "+USC123.45"
+tstfmon_y30y21 %i -123.45 "USC 123.45-"
+tstfmon_y30y21 %13i 123.45 " +USC123.45"
+tstfmon_y30y21 %13i -123.45 " USC 123.45-"
+tstfmon_y30y21 %^=*#5i 123.45 "+USC**123.45"
+tstfmon_y30y21 %^=*#5i -123.45 "USC **123.45-"
+#
+tstfmon_y32n31 %i 123.45 "+ USC123.45"
+tstfmon_y32n31 %i -123.45 "123.45 -USC"
+tstfmon_y32n31 %13i 123.45 " + USC123.45"
+tstfmon_y32n31 %13i -123.45 " 123.45 -USC"
+tstfmon_y32n31 %^=*#5i 123.45 "+ USC**123.45"
+tstfmon_y32n31 %^=*#5i -123.45 " **123.45 -USC"
+#
+tstfmon_y40y00 %i 123.45 "USC+123.45"
+tstfmon_y40y00 %i -123.45 "(USC123.45)"
+tstfmon_y40y00 %13i 123.45 " USC+123.45"
+tstfmon_y40y00 %13i -123.45 " (USC123.45)"
+tstfmon_y40y00 %^=*#5i 123.45 "USC+**123.45"
+tstfmon_y40y00 %^=*#5i -123.45 "(USC**123.45)"
+#
+tstfmon_y42n21 %i 123.45 "USC +123.45"
+tstfmon_y42n21 %i -123.45 "123.45 USC-"
+tstfmon_y42n21 %13i 123.45 " USC +123.45"
+tstfmon_y42n21 %13i -123.45 " 123.45 USC-"
+tstfmon_y42n21 %^=*#5i 123.45 "USC +**123.45"
+tstfmon_y42n21 %^=*#5i -123.45 " **123.45 USC-"
while IFS=" " read locale format value expect; do
case "$locale" in '#'*) continue ;; esac
if [ -n "$format" ]; then
+ expect=`echo "$expect" | sed 's/^\"\(.*\)\"$/\1/'`
if LOCPATH=${common_objpfx}localedata \
GCONV_PATH=${common_objpfx}/iconvdata \
${run_program_prefix} ${common_objpfx}localedata/tst-fmon \
"$locale" "$format" "$value" "$expect" ; then
echo "Locale: \"${locale}\" Format: \"${format}\"" \
- "Value: \"${value}\" Expect: \"${expect}\" passed"
+ "Value: \"${value}\" Expected: \"${expect}\" passed"
else
errcode=$?
echo "Locale: \"${locale}\" Format: \"${format}\"" \
- "Value: \"${value}\" Expect: \"${expect}\" failed"
+ "Value: \"${value}\" Expected: \"${expect}\" failed"
fi
fi
done < $datafile
/* Formatting a monetary value according to the current locale.
- Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>
and Jochen Hein <Jochen.Hein@informatik.TU-Clausthal.de>, 1996.
__long_double_t ldbl;
}
fpnum;
+ int int_format;
int print_curr_symbol;
int left_prec;
int left_pad;
}
/* Defaults for formatting. */
+ int_format = 0; /* Use international curr. symbol */
print_curr_symbol = 1; /* Print the currency symbol. */
left_prec = -1; /* No left precision specified. */
right_prec = -1; /* No right precision specified. */
break;
}
- /* If not specified by the format string now find the values for
- the format specification. */
- if (p_sign_posn == -1)
- p_sign_posn = *_NL_CURRENT (LC_MONETARY, P_SIGN_POSN);
- if (n_sign_posn == -1)
- n_sign_posn = *_NL_CURRENT (LC_MONETARY, N_SIGN_POSN);
-
if (isdigit (*fmt))
{
/* Parse field width. */
}
/* Handle format specifier. */
+ char int_symbol[4];
switch (*fmt++)
{
- case 'i': /* Use international currency symbol. */
- currency_symbol = _NL_CURRENT (LC_MONETARY, INT_CURR_SYMBOL);
+ case 'i': { /* Use international currency symbol. */
+ const char *int_curr_symbol;
+
+ int_curr_symbol = _NL_CURRENT (LC_MONETARY, INT_CURR_SYMBOL);
+ strncpy(int_symbol, int_curr_symbol, 3);
+ int_symbol[3] = '\0';
+
currency_symbol_len = 3;
- space_char = currency_symbol[3];
- if (right_prec == -1)
- {
- if (*_NL_CURRENT (LC_MONETARY, INT_FRAC_DIGITS) == CHAR_MAX)
- right_prec = 2;
- else
- right_prec = *_NL_CURRENT (LC_MONETARY, INT_FRAC_DIGITS);
- }
+ currency_symbol = &int_symbol[0];
+ space_char = int_curr_symbol[3];
+ int_format = 1;
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)
- right_prec = 2;
- else
- right_prec = *_NL_CURRENT (LC_MONETARY, FRAC_DIGITS);
- }
+ int_format = 0;
break;
default: /* Any unrecognized format is an error. */
__set_errno (EINVAL);
return -1;
}
+ /* If not specified by the format string now find the values for
+ the format specification. */
+ if (p_sign_posn == -1)
+ p_sign_posn = *_NL_CURRENT (LC_MONETARY, int_format ? INT_P_SIGN_POSN : P_SIGN_POSN);
+ if (n_sign_posn == -1)
+ n_sign_posn = *_NL_CURRENT (LC_MONETARY, int_format ? INT_N_SIGN_POSN : N_SIGN_POSN);
+
+ if (right_prec == -1)
+ {
+ right_prec = *_NL_CURRENT (LC_MONETARY, int_format ? INT_FRAC_DIGITS : FRAC_DIGITS);
+
+ if (right_prec == CHAR_MAX)
+ right_prec = 2;
+ }
+
/* If we have to print the digits grouped determine how many
extra characters this means. */
if (group && left_prec != -1)
negative sign we use a '-'. */
if (*sign_string == '\0')
sign_string = (const char *) "-";
- cs_precedes = *_NL_CURRENT (LC_MONETARY, N_CS_PRECEDES);
- sep_by_space = *_NL_CURRENT (LC_MONETARY, N_SEP_BY_SPACE);
+ cs_precedes = *_NL_CURRENT (LC_MONETARY, int_format ? INT_N_CS_PRECEDES : N_CS_PRECEDES);
+ sep_by_space = *_NL_CURRENT (LC_MONETARY, int_format ? INT_N_SEP_BY_SPACE : N_SEP_BY_SPACE);
sign_posn = n_sign_posn;
other_sign_string = _NL_CURRENT (LC_MONETARY, POSITIVE_SIGN);
- other_cs_precedes = *_NL_CURRENT (LC_MONETARY, P_CS_PRECEDES);
- other_sep_by_space = *_NL_CURRENT (LC_MONETARY, P_SEP_BY_SPACE);
+ other_cs_precedes = *_NL_CURRENT (LC_MONETARY, int_format ? INT_P_CS_PRECEDES : P_CS_PRECEDES);
+ other_sep_by_space = *_NL_CURRENT (LC_MONETARY, int_format ? INT_P_SEP_BY_SPACE : P_SEP_BY_SPACE);
other_sign_posn = p_sign_posn;
}
else
{
sign_string = _NL_CURRENT (LC_MONETARY, POSITIVE_SIGN);
- cs_precedes = *_NL_CURRENT (LC_MONETARY, P_CS_PRECEDES);
- sep_by_space = *_NL_CURRENT (LC_MONETARY, P_SEP_BY_SPACE);
+ cs_precedes = *_NL_CURRENT (LC_MONETARY, int_format ? INT_P_CS_PRECEDES : P_CS_PRECEDES);
+ sep_by_space = *_NL_CURRENT (LC_MONETARY, int_format ? INT_P_SEP_BY_SPACE : P_SEP_BY_SPACE);
sign_posn = p_sign_posn;
other_sign_string = _NL_CURRENT (LC_MONETARY, NEGATIVE_SIGN);
if (*other_sign_string == '\0')
other_sign_string = (const char *) "-";
- other_cs_precedes = *_NL_CURRENT (LC_MONETARY, N_CS_PRECEDES);
- other_sep_by_space = *_NL_CURRENT (LC_MONETARY, N_SEP_BY_SPACE);
+ other_cs_precedes = *_NL_CURRENT (LC_MONETARY, int_format ? INT_N_CS_PRECEDES : N_CS_PRECEDES);
+ other_sep_by_space = *_NL_CURRENT (LC_MONETARY, int_format ? INT_N_SEP_BY_SPACE : N_SEP_BY_SPACE);
other_sign_posn = n_sign_posn;
}