locale.cc (locale::locale(const char*)): Make sure global locales are initialized.
authorBenjamin Kosnik <bkoz@redhat.com>
Mon, 2 Jul 2001 23:08:28 +0000 (23:08 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Mon, 2 Jul 2001 23:08:28 +0000 (23:08 +0000)
2001-07-02  Benjamin Kosnik  <bkoz@redhat.com>

* src/locale.cc (locale::locale(const char*)): Make sure global
locales are initialized.
* include/bits/locale_facets.tcc (locale::combine): Refcout should
be zero, not one as it's return-by-value.
* testsuite/27_io/ios_base_callbacks.cc (test01): Don't check for
named locales here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Instead, check
for it here.
(test02): Add test.
* libsupc++/eh_alloc.cc: Use climits, not limits.h.

From-SVN: r43713

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc
libstdc++-v3/libsupc++/eh_alloc.cc
libstdc++-v3/src/locale.cc
libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc
libstdc++-v3/testsuite/27_io/ios_base_callbacks.cc

index da17d68..6c582e2 100644 (file)
@@ -1,10 +1,16 @@
-2001-07-02  Loren J. Rittle  <ljrittle@acm.org>
-
-       libstdc++/3284
-       * acinclude.m4 (GLIBCPP_ENABLE_THREADS): Portability enhancement.
-       * aclocal.m4: Regenerate.
-       * configure: Regenerate.
-
+2001-07-02  Benjamin Kosnik  <bkoz@redhat.com>
+       
+       * src/locale.cc (locale::locale(const char*)): Make sure global
+       locales are initialized.
+       * include/bits/locale_facets.tcc (locale::combine): Refcout should
+       be zero, not one as it's return-by-value.
+       * testsuite/27_io/ios_base_callbacks.cc (test01): Don't check for
+       named locales here.
+       * testsuite/22_locale/ctor_copy_dtor.cc (test01): Instead, check
+       for it here.
+       (test02): Add test.
+       * libsupc++/eh_alloc.cc: Use climits, not limits.h.
+       
 2001-07-02  Loren J. Rittle  <ljrittle@acm.org>
 
        libstdc++/3243
index 982914f..6eceed1 100644 (file)
@@ -48,7 +48,7 @@ namespace std
     locale
     locale::combine(const locale& __other)
     {
-      _Impl* __tmp = new _Impl(*_M_impl, 1);
+      _Impl* __tmp = new _Impl(*_M_impl, 0);
       __tmp->_M_replace_facet(__other._M_impl, &_Facet::id);
       return locale(__tmp);
     }
index 8b55d6c..1f59ec4 100644 (file)
@@ -33,7 +33,7 @@
 #include <exception>
 #include <cstdlib>
 #include <cstring>
-#include <limits.h>
+#include <climits>
 #include "unwind-cxx.h"
 #include "bits/c++config.h"
 #include "bits/gthr.h"
index de4f983..fb0b406 100644 (file)
@@ -371,6 +371,7 @@ namespace std
   {
     if (__s)
       {
+       _S_initialize(); 
        if (strcmp(__s, "C") == 0 || strcmp(__s, "POSIX") == 0)
          (_M_impl = _S_classic)->_M_add_reference();
        else
index cbac884..7269d23 100644 (file)
 #include <stdexcept>
 #include <debug_assert.h>
 
+
+void test00()
+{
+  // Should be able to do this as the first thing that happens in a
+  // file and have it not crash.
+  std::locale loc("C");
+}
+
 #if _GLIBCPP_USE_WCHAR_T
 typedef std::codecvt<char, char, std::mbstate_t>             c_codecvt;
 typedef std::codecvt_byname<char, char, std::mbstate_t>       c_codecvt_byname;
@@ -126,6 +134,13 @@ void test01()
   catch(...)
     { VERIFY (false); }
 
+  try
+    { locale loc08("saturn_SUN*RA"); }
+  catch(runtime_error& obj)
+    { VERIFY (true); }
+  catch(...)
+    { VERIFY (false); }
+
   // 4
   // locale(const locale& other, const char* std_name, category)
   {
@@ -226,6 +241,8 @@ void test01()
 
 int main ()
 {
+  test00();
+
 #if _GLIBCPP_USE_WCHAR_T
   test01();
 #endif 
index 236e9eb..84ca815 100644 (file)
@@ -42,14 +42,14 @@ callb03(std::ios_base::event e,  std::ios_base& b, int i)
 bool test01() 
 {
   bool test = true;
-  std::locale locco("saturn_SUN*RA");
+  std::locale loc("C");
   std::stringbuf       strbuf01;
   std::ios             ios01(&strbuf01);
 
   ios01.register_callback(callb03, 1);
   ios01.register_callback(callb02, 1);
   ios01.register_callback(callb01, 1);
-  ios01.imbue(locco);
+  ios01.imbue(loc);
   VERIFY( str01 == str02 );
 
 #ifdef DEBUG_ASSERT
@@ -66,3 +66,4 @@ int main(void)
 
   return 0;
 }
+