aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog18
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc3
-rw-r--r--libstdc++-v3/include/std/std_streambuf.h13
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13007.cc61
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc6
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc61
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc6
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc61
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc61
11 files changed, 375 insertions, 13 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 4aaf2ad..7d84d46 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,21 @@
+2003-11-13 Paolo Carlini <pcarlini@suse.de>
+ Petur Runolfsson <peturr02@ru.is>
+
+ PR libstdc++/13007
+ * include/bits/fstream.tcc (imbue): Don't touch the stored
+ locale.
+ * include/std/std_streambuf.h (imbue): According to the
+ standard, base class version does nothing.
+ (pubimbue): Store the locale.
+ * testsuite/27_io/basic_filebuf/imbue/char/13007.cc: New.
+ * testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc: New.
+ * testsuite/27_io/basic_filebuf/imbue/char/2.cc: Tweak.
+ * testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc: Likewise.
+ * testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc: New.
+ * testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc: New.
+ * testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc: New.
+ * testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc: New.
+
2003-11-13 Petur Runolfsson <peturr02@ru.is>
PR libstdc++/12594
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index a2daab5..0104711 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -742,7 +742,7 @@ namespace std
basic_filebuf<_CharT, _Traits>::
imbue(const locale& __loc)
{
- if (this->_M_buf_locale != __loc)
+ if (this->getloc() != __loc)
{
bool __testfail = false;
if (this->is_open())
@@ -758,7 +758,6 @@ namespace std
if (!__testfail)
{
- this->_M_buf_locale = __loc;
if (__builtin_expect(has_facet<__codecvt_type>(__loc), true))
_M_codecvt = &use_facet<__codecvt_type>(__loc);
else
diff --git a/libstdc++-v3/include/std/std_streambuf.h b/libstdc++-v3/include/std/std_streambuf.h
index e8a4992..23b9821 100644
--- a/libstdc++-v3/include/std/std_streambuf.h
+++ b/libstdc++-v3/include/std/std_streambuf.h
@@ -200,6 +200,7 @@ namespace std
{
locale __tmp(this->getloc());
this->imbue(__loc);
+ _M_buf_locale = __loc;
return __tmp;
}
@@ -538,15 +539,13 @@ namespace std
* are changed by this call. The standard adds, "Between invocations
* of this function a class derived from streambuf can safely cache
* results of calls to locale functions and to members of facets
- * so obtained." This function simply stores the new locale for use
- * by derived classes.
+ * so obtained."
+ *
+ * @note Base class version does nothing.
*/
virtual void
- imbue(const locale& __loc)
- {
- if (_M_buf_locale != __loc)
- _M_buf_locale = __loc;
- }
+ imbue(const locale&)
+ { }
// [27.5.2.4.2] buffer management and positioning
/**
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13007.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13007.cc
new file mode 100644
index 0000000..6eb5d9a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/13007.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf : public std::filebuf
+{
+public:
+ std::locale before;
+ std::locale after;
+
+protected:
+ void imbue(const std::locale& loc)
+ {
+ before = getloc();
+
+ std::filebuf::imbue(loc);
+
+ after = getloc();
+ }
+};
+
+// libstdc++/13007
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf buf;
+ std::locale loc(__gnu_test::try_named_locale("fr_FR"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+ VERIFY( buf.before == std::locale::classic() );
+ VERIFY( buf.after == std::locale::classic() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc
index f10ff4f..422ec85c 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc
@@ -41,10 +41,12 @@ void test02()
pos_type p = ob.pubseekoff(2, ios_base::beg, ios_base::in);
VERIFY( p != bad);
- // 1 "if file is not positioned at its beginning" fails...
+ // "if file is not positioned at its beginning" imbue fails
+ // but, according to 27.5.2.2.1, p1, still loc == getloc()
+ // after pubimbue(loc).
locale loc_de = __gnu_test::try_named_locale("de_DE");
locale ret = ob.pubimbue(loc_de);
- VERIFY( ob.getloc() == loc );
+ VERIFY( ob.getloc() == loc_de );
}
int main()
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc
new file mode 100644
index 0000000..db3e536
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/13007.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.8.1.4 Overridden virtual functions
+
+#include <fstream>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf : public std::wfilebuf
+{
+public:
+ std::locale before;
+ std::locale after;
+
+protected:
+ void imbue(const std::locale& loc)
+ {
+ before = getloc();
+
+ std::wfilebuf::imbue(loc);
+
+ after = getloc();
+ }
+};
+
+// libstdc++/13007
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf buf;
+ std::locale loc(__gnu_test::try_named_locale("fr_FR"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+ VERIFY( buf.before == std::locale::classic() );
+ VERIFY( buf.after == std::locale::classic() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc
index c47a6fa..0879de8 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc
@@ -41,10 +41,12 @@ void test02()
pos_type p = ob.pubseekoff(2, ios_base::beg, ios_base::in);
VERIFY( p != bad);
- // 1 "if file is not positioned at its beginning" fails...
+ // "if file is not positioned at its beginning" imbue fails
+ // but, according to 27.5.2.2.1, p1, still loc == getloc()
+ // after pubimbue(loc).
locale loc_de = __gnu_test::try_named_locale("de_DE");
locale ret = ob.pubimbue(loc_de);
- VERIFY( ob.getloc() == loc );
+ VERIFY( ob.getloc() == loc_de );
}
int main()
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc
new file mode 100644
index 0000000..4f5c046
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-1.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.5.2.4.1 Locales
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf1 : public std::streambuf
+{
+protected:
+ void imbue(const std::locale&)
+ { }
+};
+
+// libstdc++/13007
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf1 buf;
+ std::locale loc(__gnu_test::try_named_locale("is_IS.UTF-8"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc
new file mode 100644
index 0000000..812d822
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/char/13007-2.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.5.2.4.1 Locales
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf2 : public std::streambuf
+{
+public:
+ std::locale before;
+ std::locale after;
+
+protected:
+ void imbue(const std::locale& loc)
+ {
+ before = getloc();
+
+ std::streambuf::imbue(loc);
+
+ after = getloc();
+ }
+};
+
+// libstdc++/13007
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf2 buf;
+ std::locale loc(__gnu_test::try_named_locale("en_US"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+ VERIFY( buf.before == std::locale::classic() );
+ VERIFY( buf.after == std::locale::classic() );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc
new file mode 100644
index 0000000..9410a47
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-1.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.5.2.4.1 Locales
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf1 : public std::wstreambuf
+{
+protected:
+ void imbue(const std::locale&)
+ { }
+};
+
+// libstdc++/13007
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf1 buf;
+ std::locale loc(__gnu_test::try_named_locale("is_IS.UTF-8"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc
new file mode 100644
index 0000000..0fa76d5
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/imbue/wchar_t/13007-2.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 27.5.2.4.1 Locales
+
+#include <streambuf>
+#include <locale>
+#include <testsuite_hooks.h>
+
+class Buf2 : public std::wstreambuf
+{
+public:
+ std::locale before;
+ std::locale after;
+
+protected:
+ void imbue(const std::locale& loc)
+ {
+ before = getloc();
+
+ std::wstreambuf::imbue(loc);
+
+ after = getloc();
+ }
+};
+
+// libstdc++/13007
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ Buf2 buf;
+ std::locale loc(__gnu_test::try_named_locale("en_US"));
+
+ buf.pubimbue(loc);
+
+ VERIFY( buf.getloc() == loc );
+ VERIFY( buf.before == std::locale::classic() );
+ VERIFY( buf.after == std::locale::classic() );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}