stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Farid_Zari...@epam.com>
Subject 22.locale.money.get.cpp asserts
Date Tue, 25 Sep 2007 18:24:44 GMT
  I have checked the re-asserting lines of the test and compared the
results with
DinkumwareSTL and STLport.

  The line 752:

    // all spaces extracted since currency symbol (last) is mandatory
    // verify that the facet doesn't extract too many optional spaces
    // leaving none for the final required currency symbol
    TEST (T,  103.0, "103 ", 4, showbase, eofbit, 0, "\3\4\0\2", " ");

  The line 798:

    const charT minus_space[][3] = { { '-', ' ', '\0' }, { '\0' } };
    PunctData<charT>::negative_sign_ [intl] = minus_space [0];
    PunctData<charT>::negative_sign_ [locl] = minus_space [1];

    // { sign, value, none, symbol }
    // negative_sign is "- ", (note the single trailing space)
    // verify that the extraction suceeds, i.e., that the
money_base::none
    // specifier that's last in the pattern doesn't confuse the facet
into
    // extracting all the optional whitespace, leaving none to complete
    // the negative_sign
    TEST (T, -109.1, "-109  ", 6, 0, eofbit, 0, "\3\4\0\2", "");

  The problem is in that all spaces are eaten when 'none' pattern
element was parsed,
but the ending currency character in first test and trailing
negative_sign character
in second test are requires for presence of the space character.

  The both test lines above are failed on DinkumwareSTL and STLport too.
The questions:
- may the negative_sign have the trailing part with only space
characters?
- may the currency symbol contain only spaces?



  The another lines with rw_asserts() (851 - 853):

    PunctData<charT>::positive_sign_ [intl] = 0;
    PunctData<charT>::positive_sign_ [locl] = 0;
    PunctData<charT>::negative_sign_ [intl] = 0;
    PunctData<charT>::negative_sign_ [locl] = 0;

    [...]

    TEST (T,  117.0, "117$",   4, showbase, eofbit,  0, "\4\0\2\3",
"$");
    TEST (T,  118.0, "118$",   4, showbase, eofbit,  0, "\4\0\2\3",
"$");
    TEST (T,  119.0, "119 $",  5, showbase, eofbit,  0, "\4\1\2\3",
"$");

  Here the sign is the last position in pattern, and positive sign and
negative sign both are empty.
I've prepared the patch, fixing the problem:


Index: _money_get.cc
===================================================================
--- _money_get.cc	(revision 579104)
+++ _money_get.cc	(working copy)
@@ -165,7 +165,10 @@
         case /* '\3' */ money_base::sign: {
 
             if (__it == __end) {
-                __ebits |= _RW::__rw_failbit;
+                if (__ps.size () && __ns.size ())
+                    __ebits |= _RW::__rw_failbit;
+                else
+                    __sign = __ps.empty () - 1;
                 break;
             }
 

Farid.

Mime
View raw message