diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | localedata/tst-fmon.data | 25 | ||||
-rw-r--r-- | stdlib/strfmon.c | 23 |
3 files changed, 37 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog index 289ac14f80..a30ee5ad74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2000-03-29 Geoff Clare <gwc@unisoft.com> + + * stdlib/strfmon.c: Corrected problems with the code that + sets default values for [np]_sep_by_space and + [np]_sign_posn; also the new positive/negative alignment + code from the previous patch was not quite right for + [np]_sign_posn = 0. + + * localedata/tst-fmon.data: Changes corresponding to the + two sets of fixes made to stdlib/strfmon.c. + 2000-03-29 Jes Sorensen <jes@pcatls01.cern.ch> * malloc/malloc.c: Declare bit flags UL so that they will not diff --git a/localedata/tst-fmon.data b/localedata/tst-fmon.data index d7e80734d1..f70dea0318 100644 --- a/localedata/tst-fmon.data +++ b/localedata/tst-fmon.data @@ -19,7 +19,7 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # The format of this file is pretty simple: Each line contains a test -# for strfmon. Fields are separated by TABs. Lines that start with a +# for strfmon. Fields are seperated by TABs. Lines that start with a # '#' are comments and are ignored. # # Field Description @@ -36,8 +36,11 @@ C %n 0 0.00 C %% 0 % C *%n* 1.23 *1.23* C %9n 1.23 1.23 -C %#9n 1.23 1.23 -C %=*#9n 1.23 ********1.23 +C %9n -1.23 -1.23 +C %#9n 1.23 1.23 +C %#9n -1.23 - 1.23 +C %=*#9n 1.23 ********1.23 +C %=*#9n -1.23 -********1.23 # # check both the german locale and strfmon with that data # @@ -80,12 +83,12 @@ de_DE.ISO-8859-1 %^#5.0n 3456.781 DM 3457 de_DE.ISO-8859-1 %^#5.4n 123.45 DM 123,4500 de_DE.ISO-8859-1 %^#5.4n -123.45 -DM 123,4500 de_DE.ISO-8859-1 %^#5.4n 3456.781 DM 3456,7810 -de_DE.ISO-8859-1 %(#5n 123.45 DM 123,45 +de_DE.ISO-8859-1 %(#5n 123.45 DM 123,45 de_DE.ISO-8859-1 %(#5n -123.45 (DM 123,45) -de_DE.ISO-8859-1 %(#5n 3456.781 DM 3.456,78 -de_DE.ISO-8859-1 %!(#5n 123.45 123,45 +de_DE.ISO-8859-1 %(#5n 3456.781 DM 3.456,78 +de_DE.ISO-8859-1 %!(#5n 123.45 123,45 de_DE.ISO-8859-1 %!(#5n -123.45 ( 123,45) -de_DE.ISO-8859-1 %!(#5n 3456.781 3.456,78 +de_DE.ISO-8859-1 %!(#5n 3456.781 3.456,78 # # check both the en_US locale and strfmon with that data # a lot of this checks are created from a strfmon(3) man-page. @@ -114,12 +117,12 @@ en_US.ISO-8859-1 %^#5.0n 3456.781 $ 3457 en_US.ISO-8859-1 %^#5.4n 123.45 $ 123.4500 en_US.ISO-8859-1 %^#5.4n -123.45 -$ 123.4500 en_US.ISO-8859-1 %^#5.4n 3456.781 $ 3456.7810 -en_US.ISO-8859-1 %(#5n 123.45 $ 123.45 +en_US.ISO-8859-1 %(#5n 123.45 $ 123.45 en_US.ISO-8859-1 %(#5n -123.45 ($ 123.45) -en_US.ISO-8859-1 %(#5n 3456.781 $ 3,456.78 -en_US.ISO-8859-1 %!(#5n 123.45 123.45 +en_US.ISO-8859-1 %(#5n 3456.781 $ 3,456.78 +en_US.ISO-8859-1 %!(#5n 123.45 123.45 en_US.ISO-8859-1 %!(#5n -123.45 ( 123.45) -en_US.ISO-8859-1 %!(#5n 3456.781 3,456.78 +en_US.ISO-8859-1 %!(#5n 3456.781 3,456.78 en_US.ISO-8859-1 %#5n 123.45 $ 123.45 en_US.ISO-8859-1 %#5n -123.45 -$ 123.45 en_US.ISO-8859-1 %#5n 3456.781 $ 3,456.78 diff --git a/stdlib/strfmon.c b/stdlib/strfmon.c index d7213cae7a..b0c9375247 100644 --- a/stdlib/strfmon.c +++ b/stdlib/strfmon.c @@ -193,14 +193,8 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) va_end (ap); return -1; } - if (*_NL_CURRENT (LC_MONETARY, P_SIGN_POSN) == '\0') - p_sign_posn = 1; - else - p_sign_posn = *_NL_CURRENT (LC_MONETARY, P_SIGN_POSN); - if (*_NL_CURRENT (LC_MONETARY, N_SIGN_POSN) == '\0') - n_sign_posn = 1; - else - n_sign_posn = *_NL_CURRENT (LC_MONETARY, N_SIGN_POSN); + p_sign_posn = *_NL_CURRENT (LC_MONETARY, P_SIGN_POSN); + n_sign_posn = *_NL_CURRENT (LC_MONETARY, N_SIGN_POSN); continue; case '(': /* Use ( ) for negative sign. */ if (n_sign_posn != -1) @@ -385,10 +379,14 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) cs_precedes = 1; if (other_cs_precedes != 0) other_cs_precedes = 1; - if (sep_by_space == 127) + if (sep_by_space == CHAR_MAX) sep_by_space = 0; - if (other_sep_by_space == 127) + if (other_sep_by_space == CHAR_MAX) other_sep_by_space = 0; + if (sign_posn == CHAR_MAX) + sign_posn = 1; + if (other_sign_posn == CHAR_MAX) + other_sign_posn = 1; /* Set the left precision and padding needed for alignment */ if (left_prec == -1) @@ -404,7 +402,10 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...) int sign_precedes = 0; int other_sign_precedes = 0; - left_pad = 0; + if (sign_posn == 0 && !is_negative) + left_pad = 1; + else + left_pad = 0; if (!cs_precedes && other_cs_precedes) { |