I'm having a problem on gcc-3.2.3 and gcc-3.3 getting the money_get facet to parse "$.00". It is happy with things like "$.01" though. (I haven't been able to test it with anything more recent because I'm getting errors every time I try to compile something from cvs.) The problem is reproduced in the following code. After compiling, I run it as LANG=en_US.UTF8 ./main The output I get is amount = 5 amount = 4 amount = 3 amount = 2 amount = 1 amount = <error> The "<error>" corresponds to "$.00". =================== #include <locale> #include <string> #include <sstream> #include <iostream> using namespace std; namespace { void doit(const string& amount) { // Use a non-trivial locale by setting LANG=en_US.UTF8 (for // example). istringstream istrm(amount); istrm.imbue(locale("")); // Retrieve the money_get facet. const money_get<char>& mgf = use_facet< money_get <char> >(istrm.getloc()); // Use the facet to extract the amount from istrm. string extracted_amount; ios_base::iostate err = ios_base::iostate(0); mgf.get(istrm, 0, false, istrm, err, extracted_amount); // Check for errors. if( err & ios_base::failbit ) { extracted_amount = "<error>"; } // What did we get? cout << "amount = " << extracted_amount << endl; } } int main(int argc, char* argv[]) { int rv = 0; doit("$.05"); doit("$.04"); doit("$.03"); doit("$.02"); doit("$.01"); doit("$.00"); return rv; }
Subject: Bug 11528 CVSROOT: /cvs/gcc Module name: gcc Changes by: paolo@gcc.gnu.org 2003-07-16 16:12:47 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/bits: locale_facets.tcc Added files: libstdc++-v3/testsuite/22_locale/money_get/get/char: 11528.cc libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t: 11528.cc Log message: 2003-07-16 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/11528 * include/bits/locale_facets.tcc (money_get::do_get): Strip only _leading_ zeros. * testsuite/22_locale/money_get/get/char/11528.cc: Add. * testsuite/22_locale/money_get/get/wchar_t/11528.cc: Add. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.1883&r2=1.1884 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.tcc.diff?cvsroot=gcc&r1=1.107&r2=1.108 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/money_get/get/char/11528.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/11528.cc.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 11528 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: paolo@gcc.gnu.org 2003-07-17 10:12:24 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/include/bits: locale_facets.tcc Log message: 2003-07-17 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/11528 * include/bits/locale_facets.tcc (money_get::do_get): Strip only _leading_ zeros. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.1464.2.135&r2=1.1464.2.136 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/locale_facets.tcc.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.82.4.12&r2=1.82.4.13
Fixed for 3.3.1 and 3.4.