This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[PATCH] Fix initialization of _M_grouping


Hi,

this is the patch I have prepared, and already tested positively with
libstdc++/5280 testcase. I'm currently retesting it with a new additional
testcase.

Ok if it passes?

Cheers,
Paolo.

//////////

2002-01-28  Paolo Carlini  <pcarlini@unitus.it>

        * config/locale/numpunct_members_gnu.cc
        (numpunct<char, wchar_t>::_M_initialize_numpunct()):
        Fix initialization of _M_grouping for locales which have
        _M_thousands_sep == '\0'(L'\0', respectively).
        * testsuite/22_locale/numpunct_byname.cc (test02): Add test.

--- numpunct_members_gnu.cc.orig Mon Jan 28 22:48:17 2002
+++ numpunct_members_gnu.cc Mon Jan 28 23:05:25 2002
@@ -53,7 +53,11 @@
    // Named locale.
    _M_decimal_point = *(__nl_langinfo_l(RADIXCHAR, __cloc));
    _M_thousands_sep = *(__nl_langinfo_l(THOUSEP, __cloc));
-   _M_grouping = __nl_langinfo_l(GROUPING, __cloc);
+   // Check for NUL, which implies no grouping.
+   if (_M_thousands_sep == '\0')
+     _M_grouping = "";
+   else
+     _M_grouping = __nl_langinfo_l(GROUPING, __cloc);
  }
       // NB: There is no way to extact this info from posix locales.
       // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
@@ -79,7 +83,10 @@
    // Named locale.
    _M_decimal_point = static_cast<wchar_t>(((union { const char *__s; unsigned
int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w);
    _M_thousands_sep = static_cast<wchar_t>(((union { const char *__s; unsigned
int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w);
-   _M_grouping = __nl_langinfo_l(GROUPING, __cloc);
+   if (_M_thousands_sep == L'\0')
+     _M_grouping = "";
+   else
+     _M_grouping = __nl_langinfo_l(GROUPING, __cloc);
  }
       // NB: There is no way to extact this info from posix locales.
       // _M_truename = __nl_langinfo_l(YESSTR, __cloc);

--- numpunct_byname.cc.orig Mon Jan 28 23:38:07 2002
+++ numpunct_byname.cc Mon Jan 28 23:43:01 2002
@@ -72,9 +72,28 @@
   VERIFY( dp1 != dp3 );
 }

+void test02()
+{
+  using namespace std;
+
+  bool test = true;
+
+  locale loc_it("it_IT");
+
+  const numpunct<char>& nump_it = use_facet<numpunct<char> >(loc_it);
+
+  char th = nump_it.thousands_sep();
+  string g = nump_it.grouping();
+
+  VERIFY( th == '\0' );
+  VERIFY( g == "" );
+}
+
+
 int main()
 {
   test01();
+  test02();

   return 0;
 }





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