http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52486

             Bug #: 52486
           Summary: money_put/money_get/moneypunct interpreting
                    localeconv() result incorrectly and
                    inserting/requiring an extra space
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: jyass...@gcc.gnu.org


Created attachment 26829
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26829
Test program to show monetary formatting results

The attached test program produces the following output with trunk gcc and
Ubuntu EGLIBC 2.13-20ubuntu5. Note that reading and writing values in the US
locale requires two spaces between "USD" and the currency value, and writes an
extra space when showbase is false (meaning the currency symbol should be
omitted). In the French locale, we're getting an extra space at the very end of
the output string.

I believe glibc is setting the locale data correctly for C11, and it matches
the example table in paragraph 10 of "7.11.2.1 The localeconv function". In C99
I think the normative wording was ambiguous, but the example table showed the
opposite value for int_*_sep_by_space. 

$ ~/src/gcc/install/bin/g++-4.8svn -Wall test.cc -o test && ./test en_US.UTF-8
Set locale to 'en_US.UTF-8'
lc->currency_symbol == '$'
lc->p_sep_by_space == 0
lc->n_sep_by_space == 0
lc->int_curr_symbol == 'USD '
lc->int_p_sep_by_space == 1
lc->int_n_sep_by_space == 1

'1.23' reads as: '0'
And advances the iterator from 0x227c028 to 0x227c028.
And leaves the stream in state failbit.

'USD 1.23' reads as: '0'
And advances the iterator from 0x227c028 to 0x227c02c.
And leaves the stream in state failbit.

'USD  1.23' reads as: '123'
And advances the iterator from 0x227c028 to 0x227c031.
And leaves the stream in state eofbit.

Testing 123:
!showbase: ' 1.23'; showbase: 'USD  1.23'
strfmon writes it/100 as: no-symbol: '1.23'; symbol: 'USD 1.23'

Testing -1:
!showbase: '- .01'; showbase: '-USD  .01'
strfmon writes it/100 as: no-symbol: '-0.01'; symbol: '-USD 0.01'
$ ~/src/gcc/install/bin/g++-4.8svn -Wall test.cc -o test && ./test fr_FR.UTF-8
Set locale to 'fr_FR.UTF-8'
lc->currency_symbol == '€'
lc->p_sep_by_space == 1
lc->n_sep_by_space == 1
lc->int_curr_symbol == 'EUR '
lc->int_p_sep_by_space == 1
lc->int_n_sep_by_space == 1

'1.23' reads as: '0'
And advances the iterator from 0x1c8f028 to 0x1c8f029.
And leaves the stream in state failbit.

'USD 1.23' reads as: '0'
And advances the iterator from 0x1c8f028 to 0x1c8f028.
And leaves the stream in state failbit.

'USD  1.23' reads as: '0'
And advances the iterator from 0x1c8f028 to 0x1c8f028.
And leaves the stream in state failbit.

Testing 123:
!showbase: '1,23 '; showbase: '1,23 EUR '
strfmon writes it/100 as: no-symbol: '1,23'; symbol: '1,23 EUR'

Testing -1:
!showbase: '-,01 '; showbase: '-,01 EUR '
strfmon writes it/100 as: no-symbol: '-0,01'; symbol: '-0,01 EUR'
jyasskin@abzu:~/tmp$

Reply via email to