aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2001-07-02 23:08:28 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2001-07-02 23:08:28 +0000
commit213c2316b697c78344ba7d03b2e922c8229e8b35 (patch)
treeb7c70c18995c1b35cea67a52cbf249a39eb5f33b
parent30b3a033af6c62b95c16c3f26610753c0aaa4002 (diff)
downloadgcc-213c2316b697c78344ba7d03b2e922c8229e8b35.zip
gcc-213c2316b697c78344ba7d03b2e922c8229e8b35.tar.gz
gcc-213c2316b697c78344ba7d03b2e922c8229e8b35.tar.bz2
locale.cc (locale::locale(const char*)): Make sure global locales are initialized.
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
-rw-r--r--libstdc++-v3/ChangeLog20
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc2
-rw-r--r--libstdc++-v3/libsupc++/eh_alloc.cc2
-rw-r--r--libstdc++-v3/src/locale.cc1
-rw-r--r--libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc17
-rw-r--r--libstdc++-v3/testsuite/27_io/ios_base_callbacks.cc5
6 files changed, 36 insertions, 11 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index da17d68..6c582e2 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index 982914f..6eceed1 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -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);
}
diff --git a/libstdc++-v3/libsupc++/eh_alloc.cc b/libstdc++-v3/libsupc++/eh_alloc.cc
index 8b55d6c..1f59ec4 100644
--- a/libstdc++-v3/libsupc++/eh_alloc.cc
+++ b/libstdc++-v3/libsupc++/eh_alloc.cc
@@ -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"
diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc
index de4f983..fb0b406 100644
--- a/libstdc++-v3/src/locale.cc
+++ b/libstdc++-v3/src/locale.cc
@@ -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
diff --git a/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc b/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc
index cbac884..7269d23 100644
--- a/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc
+++ b/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc
@@ -25,6 +25,14 @@
#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
diff --git a/libstdc++-v3/testsuite/27_io/ios_base_callbacks.cc b/libstdc++-v3/testsuite/27_io/ios_base_callbacks.cc
index 236e9eb..84ca815 100644
--- a/libstdc++-v3/testsuite/27_io/ios_base_callbacks.cc
+++ b/libstdc++-v3/testsuite/27_io/ios_base_callbacks.cc
@@ -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;
}
+