diff options
23 files changed, 291 insertions, 39 deletions
@@ -1,3 +1,10 @@ +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. diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 1b4802c..62c79ff 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,35 @@ +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. diff --git a/localedata/locales/en_US b/localedata/locales/en_US index 13a19db..1da3158 100644 --- a/localedata/locales/en_US +++ b/localedata/locales/en_US @@ -52,8 +52,10 @@ negative_sign "<U002D>" 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 diff --git a/localedata/locales/ja_JP b/localedata/locales/ja_JP index 1e4b1c1..6a3229f 100644 --- a/localedata/locales/ja_JP +++ b/localedata/locales/ja_JP @@ -14894,8 +14894,10 @@ p_cs_precedes 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 diff --git a/localedata/tst-fmon-locales/tstfmon_n01y12 b/localedata/tst-fmon-locales/tstfmon_n01y12 index 975c5ec..499a1ea 100644 --- a/localedata/tst-fmon-locales/tstfmon_n01y12 +++ b/localedata/tst-fmon-locales/tstfmon_n01y12 @@ -23,4 +23,10 @@ p_sep_by_space 1 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 diff --git a/localedata/tst-fmon-locales/tstfmon_n02n40 b/localedata/tst-fmon-locales/tstfmon_n02n40 index 7c41612..ad6ee6b 100644 --- a/localedata/tst-fmon-locales/tstfmon_n02n40 +++ b/localedata/tst-fmon-locales/tstfmon_n02n40 @@ -23,4 +23,10 @@ p_sep_by_space 2 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 diff --git a/localedata/tst-fmon-locales/tstfmon_n10y31 b/localedata/tst-fmon-locales/tstfmon_n10y31 index 5e14d7d..e325832 100644 --- a/localedata/tst-fmon-locales/tstfmon_n10y31 +++ b/localedata/tst-fmon-locales/tstfmon_n10y31 @@ -23,4 +23,10 @@ p_sep_by_space 0 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 diff --git a/localedata/tst-fmon-locales/tstfmon_n11y41 b/localedata/tst-fmon-locales/tstfmon_n11y41 index 22685cb..497f750 100644 --- a/localedata/tst-fmon-locales/tstfmon_n11y41 +++ b/localedata/tst-fmon-locales/tstfmon_n11y41 @@ -23,4 +23,10 @@ p_sep_by_space 1 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 diff --git a/localedata/tst-fmon-locales/tstfmon_n12y11 b/localedata/tst-fmon-locales/tstfmon_n12y11 index 0788bab..d964101 100644 --- a/localedata/tst-fmon-locales/tstfmon_n12y11 +++ b/localedata/tst-fmon-locales/tstfmon_n12y11 @@ -23,4 +23,10 @@ p_sep_by_space 2 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 diff --git a/localedata/tst-fmon-locales/tstfmon_n20n32 b/localedata/tst-fmon-locales/tstfmon_n20n32 index 2c219e9..9441280 100644 --- a/localedata/tst-fmon-locales/tstfmon_n20n32 +++ b/localedata/tst-fmon-locales/tstfmon_n20n32 @@ -23,4 +23,10 @@ p_sep_by_space 0 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 diff --git a/localedata/tst-fmon-locales/tstfmon_n30y20 b/localedata/tst-fmon-locales/tstfmon_n30y20 index c3216b4..2c8a9ea 100644 --- a/localedata/tst-fmon-locales/tstfmon_n30y20 +++ b/localedata/tst-fmon-locales/tstfmon_n30y20 @@ -23,4 +23,10 @@ p_sep_by_space 0 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 diff --git a/localedata/tst-fmon-locales/tstfmon_n41n00 b/localedata/tst-fmon-locales/tstfmon_n41n00 index 199cd54..56879ec 100644 --- a/localedata/tst-fmon-locales/tstfmon_n41n00 +++ b/localedata/tst-fmon-locales/tstfmon_n41n00 @@ -23,4 +23,10 @@ p_sep_by_space 1 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 diff --git a/localedata/tst-fmon-locales/tstfmon_y01y10 b/localedata/tst-fmon-locales/tstfmon_y01y10 index 1e26360..7c0b22a 100644 --- a/localedata/tst-fmon-locales/tstfmon_y01y10 +++ b/localedata/tst-fmon-locales/tstfmon_y01y10 @@ -23,4 +23,10 @@ p_sep_by_space 1 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 diff --git a/localedata/tst-fmon-locales/tstfmon_y02n22 b/localedata/tst-fmon-locales/tstfmon_y02n22 index 26c8158..7d9ac30 100644 --- a/localedata/tst-fmon-locales/tstfmon_y02n22 +++ b/localedata/tst-fmon-locales/tstfmon_y02n22 @@ -23,4 +23,10 @@ p_sep_by_space 2 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 diff --git a/localedata/tst-fmon-locales/tstfmon_y22n42 b/localedata/tst-fmon-locales/tstfmon_y22n42 index 37a2d49..fda413b 100644 --- a/localedata/tst-fmon-locales/tstfmon_y22n42 +++ b/localedata/tst-fmon-locales/tstfmon_y22n42 @@ -23,4 +23,10 @@ p_sep_by_space 2 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 diff --git a/localedata/tst-fmon-locales/tstfmon_y30y21 b/localedata/tst-fmon-locales/tstfmon_y30y21 index 4b38c42..9dee2cc 100644 --- a/localedata/tst-fmon-locales/tstfmon_y30y21 +++ b/localedata/tst-fmon-locales/tstfmon_y30y21 @@ -23,4 +23,10 @@ p_sep_by_space 0 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 diff --git a/localedata/tst-fmon-locales/tstfmon_y32n31 b/localedata/tst-fmon-locales/tstfmon_y32n31 index 7c54154..34967c7 100644 --- a/localedata/tst-fmon-locales/tstfmon_y32n31 +++ b/localedata/tst-fmon-locales/tstfmon_y32n31 @@ -23,4 +23,10 @@ p_sep_by_space 2 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 diff --git a/localedata/tst-fmon-locales/tstfmon_y40y00 b/localedata/tst-fmon-locales/tstfmon_y40y00 index 664b20d..348b07b 100644 --- a/localedata/tst-fmon-locales/tstfmon_y40y00 +++ b/localedata/tst-fmon-locales/tstfmon_y40y00 @@ -23,4 +23,10 @@ p_sep_by_space 0 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 diff --git a/localedata/tst-fmon-locales/tstfmon_y42n21 b/localedata/tst-fmon-locales/tstfmon_y42n21 index 2a879e4..d2f7e9e 100644 --- a/localedata/tst-fmon-locales/tstfmon_y42n21 +++ b/localedata/tst-fmon-locales/tstfmon_y42n21 @@ -23,4 +23,10 @@ p_sep_by_space 2 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 diff --git a/localedata/tst-fmon.c b/localedata/tst-fmon.c index 091a057..a45c8ba 100644 --- a/localedata/tst-fmon.c +++ b/localedata/tst-fmon.c @@ -58,8 +58,8 @@ main (int argc, char *argv[]) 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); } diff --git a/localedata/tst-fmon.data b/localedata/tst-fmon.data index d67a38f..d7bcb17 100644 --- a/localedata/tst-fmon.data +++ b/localedata/tst-fmon.data @@ -1,5 +1,5 @@ # 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. # @@ -28,6 +28,8 @@ # #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 @@ -236,3 +238,113 @@ tstfmon_y42n21 %11n 123.45 $ +123.45 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-" diff --git a/localedata/tst-fmon.sh b/localedata/tst-fmon.sh index c8b6d69..95dab36 100755 --- a/localedata/tst-fmon.sh +++ b/localedata/tst-fmon.sh @@ -44,16 +44,17 @@ errcode=0 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 diff --git a/stdlib/strfmon.c b/stdlib/strfmon.c index e7183ec..4f16316 100644 --- a/stdlib/strfmon.c +++ b/stdlib/strfmon.c @@ -1,5 +1,5 @@ /* 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. @@ -128,6 +128,7 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) __long_double_t ldbl; } fpnum; + int int_format; int print_curr_symbol; int left_prec; int left_pad; @@ -172,6 +173,7 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) } /* 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. */ @@ -233,13 +235,6 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) 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. */ @@ -305,31 +300,27 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) } /* 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); @@ -337,6 +328,21 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) 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) @@ -369,27 +375,27 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) 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; } |