tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Strange "C" locale data



I had a (very quick) look at the only remaining test failure in my latest
sparc64 test runs. This is the strfmon test failing because it adds additional
(that is unwanted) padding between the empty currency symbol ("") and the
number formated.

It seems that the C locale contains strange monetary data:

(gdb) p *loc->cache       
$10 = {cache_link = {sle_next = 0x0}, monetary_name = 0x7f7ff7535570 "C", 
  numeric_name = 0x7f7ff7535570 "C", ldata = {
    decimal_point = 0x7f7ff752f107 ".", thousands_sep = 0x7f7ff7524461 "", 
    grouping = 0x7f7ff7524461 "", int_curr_symbol = 0x7f7ff7524461 "", 
    currency_symbol = 0x7f7ff7524461 "", 
    mon_decimal_point = 0x7f7ff7524461 "", 
    mon_thousands_sep = 0x7f7ff7524461 "", mon_grouping = 0x7f7ff7524461 "", 
    positive_sign = 0x7f7ff7524461 "", negative_sign = 0x7f7ff7524461 "", 
    int_frac_digits = 127 '\177', frac_digits = 127 '\177', 
    p_cs_precedes = 127 '\177', p_sep_by_space = 127 '\177', 
    n_cs_precedes = 127 '\177', n_sep_by_space = 127 '\177', 
    p_sign_posn = 127 '\177', n_sign_posn = 127 '\177', 
    int_p_cs_precedes = 127 '\177', int_n_cs_precedes = 127 '\177', 
    int_p_sep_by_space = 127 '\177', int_n_sep_by_space = 127 '\177', 
    int_p_sign_posn = 127 '\177', int_n_sign_posn = 127 '\177'}}

where 127 is invalid. It comes from:

src/lib/libc/locale/global_locale.c:

static const _MonetaryLocale _DefaultMonetaryLocale = {
        "",
        "",
        "",
        "",
        "",
        "",
        "",
        (char)CHAR_MAX,
        (char)CHAR_MAX,
        (char)CHAR_MAX,
..

but the documetnation (src/lib/stdlib/strfmon.c) says:

                /*
                 * Description of some LC_MONETARY's values:
                 * 
                 * p_cs_precedes & n_cs_precedes
                 *       
                 * = 1 - $currency_symbol precedes the value
                 *       for a monetary quantity with a non-negative value
                 * = 0 - symbol succeeds the value
                 * 
                 * p_sep_by_space & n_sep_by_space
                 *
                 * = 0 - no space separates $currency_symbol
                 *       from the value for a monetary quantity with a
                 *       non-negative value
                 * = 1 - space separates the symbol from the value
                 * = 2 - space separates the symbol and the sign string,
                 *       if adjacent.

...

So either the documentation is out of date, or the default locale is 
wrong.

Anyone know details?

Martin


Home | Main Index | Thread Index | Old Index