diff options
author | Paolo Carlini <pcarlini@unitus.it> | 2002-09-05 21:13:07 +0000 |
---|---|---|
committer | Paolo Carlini <pcarlini@unitus.it> | 2002-09-05 21:13:07 +0000 |
commit | 90afb7a3979127e0f67116e03964d8cf59f0a5d0 (patch) | |
tree | 04d7512b4857d0931c9bdb1ce34ae5d6b7799f97 | |
parent | 740448f0978e53d4a6b7af1cbd657fe9d0883bb0 (diff) |
2002-09-05 Paolo Carlini <pcarlini@unitus.it>
Roland McGrath <roland@redhat.com>
PR libstdc++/7811
* src/locale.cc (locale::locale(__s)): Use getenv instead
of setenv for the environment locale.
* testsuite/22_locale/ctor_copy_dtor.cc (test03): New.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@56865 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/src/locale.cc | 10 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc | 16 |
3 files changed, 33 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 07f92a87a80..89804df5295 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2002-09-05 Paolo Carlini <pcarlini@unitus.it> + Roland McGrath <roland@redhat.com> + + PR libstdc++/7811 + * src/locale.cc (locale::locale(__s)): Use getenv instead + of setenv for the environment locale. + * testsuite/22_locale/ctor_copy_dtor.cc (test03): New. + 2002-09-05 Jakub Jelinek <jakub@redhat.com> * config/abi/ia64-unknown-linux-gnu: Add. diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index 3cb9d1b4cbf..99c8c67144b 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -202,7 +202,15 @@ namespace std if (strcmp(__s, "C") == 0 || strcmp(__s, "POSIX") == 0) (_M_impl = _S_classic)->_M_add_reference(); else if (strcmp(__s, "") == 0) - _M_impl = new _Impl(setlocale(LC_ALL, NULL), 1); + { + char* __env = getenv("LC_ALL"); + if (__env) + _M_impl = new _Impl(__env, 1); + else if ((__env = getenv("LANG"))) + _M_impl = new _Impl(__env, 1); + else + (_M_impl = _S_classic)->_M_add_reference(); + } else _M_impl = new _Impl(__s, 1); } diff --git a/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc b/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc index 94db3bcc139..a27b2457e87 100644 --- a/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc +++ b/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc @@ -310,6 +310,21 @@ void test02() VERIFY( loc_1 == loc_2 ); } +// libstdc++/7811 +void test03() +{ + bool test = true; +#ifdef _GLIBCPP_HAVE_SETENV + const char* oldLANG = getenv("LANG"); + if (!setenv("LANG", "it_IT", 1)) + { + std::locale loc(""); + VERIFY( loc.name() == "it_IT" ); + setenv("LANG", oldLANG ? oldLANG : "", 1); + } +#endif +} + int main() { test00(); @@ -319,6 +334,7 @@ int main() #endif test02(); + test03(); return 0; } |