diff options
author | Paolo Carlini <pcarlini@suse.de> | 2004-02-09 23:10:47 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-02-09 23:10:47 +0000 |
commit | cf0d2c4044fb7a95db4ee80d60003590dce5b6a6 (patch) | |
tree | c36990d7f1dba6b6043233d2d75cb472a37fc044 | |
parent | cee63f4d4eb5f36d5059a00ddd83a99049367e2d (diff) | |
download | gcc-cf0d2c4044fb7a95db4ee80d60003590dce5b6a6.zip gcc-cf0d2c4044fb7a95db4ee80d60003590dce5b6a6.tar.gz gcc-cf0d2c4044fb7a95db4ee80d60003590dce5b6a6.tar.bz2 |
re PR libstdc++/14071 (locale::global doesn't always call setlocale)
2004-02-09 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/14071
* src/locale_init.cc (locale::global(const locale&)): Use
locale::name() in order to decide whether calling setlocale.
* testsuite/22_locale/locale/global_locale_objects/14071.cc: New.
* include/bits/locale_classes.h (locale::_Impl::_M_check_same_name()):
Avoid computing &= unnecessarily.
From-SVN: r77568
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/locale_classes.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/src/locale_init.cc | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc | 49 |
4 files changed, 62 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e18aff6..b519c94 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2004-02-09 Paolo Carlini <pcarlini@suse.de> + + PR libstdc++/14071 + * src/locale_init.cc (locale::global(const locale&)): Use + locale::name() in order to decide whether calling setlocale. + * testsuite/22_locale/locale/global_locale_objects/14071.cc: New. + + * include/bits/locale_classes.h (locale::_Impl::_M_check_same_name()): + Avoid computing &= unnecessarily. + 2004-02-09 James E Wilson <wilson@specifixinc.com> PR libstdc++/5625 diff --git a/libstdc++-v3/include/bits/locale_classes.h b/libstdc++-v3/include/bits/locale_classes.h index 33eb475..e4f5c17 100644 --- a/libstdc++-v3/include/bits/locale_classes.h +++ b/libstdc++-v3/include/bits/locale_classes.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -535,7 +535,7 @@ namespace std { bool __ret = true; for (size_t __i = 0; __ret && __i < _S_categories_size - 1; ++__i) - __ret &= (std::strcmp(_M_names[__i], _M_names[__i + 1]) == 0); + __ret = std::strcmp(_M_names[__i], _M_names[__i + 1]) == 0; return __ret; } diff --git a/libstdc++-v3/src/locale_init.cc b/libstdc++-v3/src/locale_init.cc index a00366b..276d686 100644 --- a/libstdc++-v3/src/locale_init.cc +++ b/libstdc++-v3/src/locale_init.cc @@ -108,8 +108,7 @@ namespace std _Impl* __old = _S_global; __other._M_impl->_M_add_reference(); _S_global = __other._M_impl; - if (_S_global->_M_check_same_name() - && (std::strcmp(_S_global->_M_names[0], "*") != 0)) + if (__other.name() != "*") setlocale(LC_ALL, __other.name().c_str()); // Reference count sanity check: one reference removed for the diff --git a/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc b/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc new file mode 100644 index 0000000..7c143f4 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/locale/global_locale_objects/14071.cc @@ -0,0 +1,49 @@ +// 2004-02-09 Petur Runolfsson <peturr02@ru.is> + +// Copyright (C) 2004 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 22.1.1.5 locale static members [lib.locale.statics] + +#include <locale> +#include <clocale> +#include <testsuite_hooks.h> + +// libstdc++/14071 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const locale loc_is = __gnu_test::try_named_locale("is_IS"); + const locale loc_en = __gnu_test::try_named_locale("en_US"); + + const locale loc(loc_is, loc_en, locale::monetary); + + if (loc.name() != "*") + { + locale::global(loc); + VERIFY( loc.name() == setlocale(LC_ALL, NULL) ); + } +} + +int main() +{ + test01(); + return 0; +} |