This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: LC_MONETARY and incorrect danish locale?


[Petter Reinholdtsen]
> OK, so how is the locale supposed to look to get it to print "DKK
> 1,23" for the value 1.23?

Hm, it was supposed to read "DKK 1,23" without the line break.

Anyway, I've been checking some more, and I believe there is a bug in
stdlib/strfmon.c.  It always print the trailing space from
int_curr_symbol, even if the value of int_n_sep_by_space or
int_n_sep_by_space is 0.  It would be more sensible if the fourth
character in int_curr_symbol only is used if the currency symbol and
the value is supposed to be separated by space.

Something along these lines might solve the problem.  Is this correct,
or is it just me not understanding the locales format?  I'm using the
standard "ISO/IEC FPDTR 14652:1999(E)" as documentation for the
format.

Of course, this change make it necessary to change a lot of locales,
including en_US.

--- strfmon.c.~1.23.~	Sat Aug  3 08:29:57 2002
+++ strfmon.c	Sun Jun 15 20:43:02 2003
@@ -307,10 +307,12 @@
       /* Handle format specifier.  */
       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 *tmp = _NL_CURRENT (LC_MONETARY, INT_CURR_SYMBOL);
 	  currency_symbol_len = 3;
-	  space_char = currency_symbol[3];
+	  currency_symbol = alloca(currency_symbol_len + 1);
+	  strncpy(currency_symbol, tmp, currency_symbol_len);
+	  space_char = tmp[3];
 	  if (right_prec == -1)
 	    {
 	      if (*_NL_CURRENT (LC_MONETARY, INT_FRAC_DIGITS) == CHAR_MAX)
@@ -319,6 +321,7 @@
 		right_prec = *_NL_CURRENT (LC_MONETARY, INT_FRAC_DIGITS);
 	    }
 	  break;
+	}
 	case 'n':		/* Use national currency symbol.  */
 	  currency_symbol = _NL_CURRENT (LC_MONETARY, CURRENCY_SYMBOL);
 	  currency_symbol_len = strlen (currency_symbol);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]