From 54d10d2b099fa1d700de8e598e5032766360d6b5 Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 30 Jan 2002 21:00:40 +0000 Subject: [PATCH] 2002-01-30 Paolo Carlini * config/locale/numpunct_members_gnu.cc (numpunct::_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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49343 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 8 ++++++++ libstdc++-v3/config/locale/numpunct_members_gnu.cc | 11 +++++++++-- libstdc++-v3/testsuite/22_locale/numpunct_byname.cc | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 05ff24c8b55..34126053580 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2002-01-30 Paolo Carlini + * config/locale/numpunct_members_gnu.cc + (numpunct::_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. + +2002-01-30 Paolo Carlini + * testsuite/27_io/ostream_inserter_arith.cc (test03): Better fix for 32/64 bit architectures, avoiding the implicit assumption that CHAR_BIT == 8. diff --git a/libstdc++-v3/config/locale/numpunct_members_gnu.cc b/libstdc++-v3/config/locale/numpunct_members_gnu.cc index de9e386fd46..4284c7c07b3 100644 --- a/libstdc++-v3/config/locale/numpunct_members_gnu.cc +++ b/libstdc++-v3/config/locale/numpunct_members_gnu.cc @@ -53,7 +53,11 @@ namespace std // 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 @@ namespace std // Named locale. _M_decimal_point = static_cast(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w); _M_thousands_sep = static_cast(((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); diff --git a/libstdc++-v3/testsuite/22_locale/numpunct_byname.cc b/libstdc++-v3/testsuite/22_locale/numpunct_byname.cc index 6b6d7d80a0f..4c69b291a0a 100644 --- a/libstdc++-v3/testsuite/22_locale/numpunct_byname.cc +++ b/libstdc++-v3/testsuite/22_locale/numpunct_byname.cc @@ -72,9 +72,26 @@ void test01() VERIFY( dp1 != dp3 ); } +void test02() +{ + using namespace std; + + bool test = true; + + locale loc_it("it_IT"); + + const numpunct& nump_it = use_facet >(loc_it); + + string g = nump_it.grouping(); + + VERIFY( g == "" ); +} + + int main() { test01(); + test02(); return 0; } -- 2.11.0