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

[v3] libstdc++/7811


Hi,

to fix this regression from 3.1.1 I have committed the below to mainline and 3.2.
Tested i686-pc-linux-gnu, approved by Benjamin Kosnik (and myself ;)

Ciao, Paolo.

/////////////////

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.

===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- gcc/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc 2002/07/31 02:47:34 1.15
+++ gcc/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc 2002/09/05 21:13:06 1.16
@@ -310,6 +310,21 @@
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 @@
#endif
test02();
+ test03();

return 0;
}

===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale.cc,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- gcc/libstdc++-v3/src/locale.cc 2002/08/15 22:25:39 1.63
+++ gcc/libstdc++-v3/src/locale.cc 2002/09/05 21:13:07 1.64
@@ -202,7 +202,15 @@
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);
}





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