aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetur Runolfsson <peturr02@ru.is>2003-01-23 22:53:35 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2003-01-23 22:53:35 +0000
commit1ceb90cfa1d97be16c6ce787293f70e4d0c77a5d (patch)
tree6e6f05ca3780e30c6e94fb8dcc7556a942ff45de
parent806e09354fd41e8783964a2403ac57b25ef8a64e (diff)
downloadgcc-1ceb90cfa1d97be16c6ce787293f70e4d0c77a5d.zip
gcc-1ceb90cfa1d97be16c6ce787293f70e4d0c77a5d.tar.gz
gcc-1ceb90cfa1d97be16c6ce787293f70e4d0c77a5d.tar.bz2
re PR libstdc++/9322 (return value of basic_streambuf<>::getloc affected by locale::global)
2003-01-23 Petur Runolfsson <peturr02@ru.is> PR libstdc++/9322 * include/std/std_streambuf.h (basic_streambuf::basic_streambuf, basic_streambuf::~basic_streambuf, basic_streambuf::getloc, basic_streambuf::imbue): Remove _M_buf_locale_init use. * include/bits/fstream.tcc (basic_filebuf::imbue): Likewise * testsuite/27_io/filebuf_virtuals.cc (test08): Add. * testsuite/27_io/streambuf_members.cc (test08): Add. * testsuite/27_io/stringbuf_virtuals.cc (test08): Add. From-SVN: r61678
-rw-r--r--libstdc++-v3/ChangeLog13
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc5
-rw-r--r--libstdc++-v3/include/std/std_streambuf.h20
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc26
-rw-r--r--libstdc++-v3/testsuite/27_io/streambuf_members.cc25
-rw-r--r--libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc25
6 files changed, 90 insertions, 24 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ff2b166..bda8f07 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,16 @@
+2003-01-23 Petur Runolfsson <peturr02@ru.is>
+
+ PR libstdc++/9322
+ * include/std/std_streambuf.h
+ (basic_streambuf::basic_streambuf,
+ basic_streambuf::~basic_streambuf,
+ basic_streambuf::getloc, basic_streambuf::imbue):
+ Remove _M_buf_locale_init
+ * include/bits/fstream.tcc (basic_filebuf::imbue): Likewise
+ * testsuite/27_io/filebuf_virtuals.cc (test08): Add.
+ * testsuite/27_io/streambuf_members.cc (test08): Add.
+ * testsuite/27_io/stringbuf_virtuals.cc (test08): Add.
+
2003-01-23 Benjamin Kosnik <bkoz@redhat.com>
Revert include ordering.
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 1865a92..bf1c42e 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -477,10 +477,7 @@ namespace std
bool __testbeg = gptr() == eback() && pptr() == pbase();
if (__testbeg && this->_M_buf_locale != __loc)
- {
- this->_M_buf_locale = __loc;
- this->_M_buf_locale_init = true;
- }
+ this->_M_buf_locale = __loc;
// NB this may require the reconversion of previously
// converted chars. This in turn may cause the reconstruction
diff --git a/libstdc++-v3/include/std/std_streambuf.h b/libstdc++-v3/include/std/std_streambuf.h
index ffa14df..e7dca92 100644
--- a/libstdc++-v3/include/std/std_streambuf.h
+++ b/libstdc++-v3/include/std/std_streambuf.h
@@ -1,6 +1,6 @@
// Stream buffer classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -224,13 +224,6 @@ namespace std
*/
locale _M_buf_locale;
- /**
- * @if maint
- * True iff locale is initialized.
- * @endif
- */
- bool _M_buf_locale_init;
-
//@{
/**
* @if maint
@@ -364,7 +357,6 @@ namespace std
_M_buf_size = 0;
_M_buf_size_opt = 0;
_M_mode = ios_base::openmode(0);
- _M_buf_locale_init = false;
}
// [27.5.2.2.1] locales
@@ -393,12 +385,7 @@ namespace std
*/
locale
getloc() const
- {
- if (_M_buf_locale_init)
- return _M_buf_locale;
- else
- return locale();
- }
+ { return _M_buf_locale; }
// [27.5.2.2.2] buffer management and positioning
//@{
@@ -584,7 +571,7 @@ namespace std
_M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
_M_out_beg(0), _M_out_cur(0), _M_out_end(0),
_M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
- _M_buf_locale_init(false), _M_pback_cur_save(0), _M_pback_end_save(0),
+ _M_pback_cur_save(0), _M_pback_end_save(0),
_M_pback_init(false)
{ }
@@ -700,7 +687,6 @@ namespace std
virtual void
imbue(const locale& __loc)
{
- _M_buf_locale_init = true;
if (_M_buf_locale != __loc)
_M_buf_locale = __loc;
}
diff --git a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
index 0a92788..c02e1a7 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
+++ b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
@@ -1,6 +1,6 @@
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// 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
@@ -21,6 +21,7 @@
// 27.8.1.4 Overridden virtual functions
#include <fstream>
+#include <locale>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
@@ -514,6 +515,28 @@ void test06()
VERIFY( buffer[0] == 'a' );
}
+// libstdc++/9322
+void test07()
+{
+ using std::locale;
+ bool test = true;
+
+ locale loc;
+ std::filebuf ob;
+ VERIFY( ob.getloc() == loc );
+
+ locale::global(locale("en_US"));
+ VERIFY( ob.getloc() == loc );
+
+ locale loc_de ("de_DE");
+ locale ret = ob.pubimbue(loc_de);
+ VERIFY( ob.getloc() == loc_de );
+ VERIFY( ret == loc );
+
+ locale::global(loc);
+ VERIFY( ob.getloc() == loc_de );
+}
+
main()
{
test01();
@@ -524,5 +547,6 @@ main()
test05();
test06();
+ test07();
return 0;
}
diff --git a/libstdc++-v3/testsuite/27_io/streambuf_members.cc b/libstdc++-v3/testsuite/27_io/streambuf_members.cc
index 3f9a319..aaad07d 100644
--- a/libstdc++-v3/testsuite/27_io/streambuf_members.cc
+++ b/libstdc++-v3/testsuite/27_io/streambuf_members.cc
@@ -1,6 +1,6 @@
// 1999-10-11 bkoz
-// Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
//
// 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
@@ -364,6 +364,28 @@ test07()
VERIFY(out.good());
}
+// libstdc++/9322
+void test08()
+{
+ using std::locale;
+ bool test = true;
+
+ locale loc;
+ testbuf2 ob;
+ VERIFY( ob.getloc() == loc );
+
+ locale::global(locale("en_US"));
+ VERIFY( ob.getloc() == loc );
+
+ locale loc_de ("de_DE");
+ locale ret = ob.pubimbue(loc_de);
+ VERIFY( ob.getloc() == loc_de );
+ VERIFY( ret == loc );
+
+ locale::global(loc);
+ VERIFY( ob.getloc() == loc_de );
+}
+
int main()
{
test01();
@@ -374,5 +396,6 @@ int main()
test05();
test07();
+ test08();
return 0;
}
diff --git a/libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc b/libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc
index 318bb72..8a6add9 100644
--- a/libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc
+++ b/libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc
@@ -1,6 +1,6 @@
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// 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
@@ -70,6 +70,28 @@ void test02(std::stringbuf& in, bool pass)
VERIFY( p == bad );
}
+// libstdc++/9322
+void test08()
+{
+ using std::locale;
+ bool test = true;
+
+ locale loc;
+ std::stringbuf ob;
+ VERIFY( ob.getloc() == loc );
+
+ locale::global(locale("en_US"));
+ VERIFY( ob.getloc() == loc );
+
+ locale loc_de ("de_DE");
+ locale ret = ob.pubimbue(loc_de);
+ VERIFY( ob.getloc() == loc_de );
+ VERIFY( ret == loc );
+
+ locale::global(loc);
+ VERIFY( ob.getloc() == loc_de );
+}
+
int main()
{
using namespace std;
@@ -83,5 +105,6 @@ int main()
test02(in2, false);
test02(in3, false);
+ test08();
return 0;
}