summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog18
-rw-r--r--libstdc++-v3/docs/html/ext/howto.html6
-rw-r--r--libstdc++-v3/include/bits/sstream.tcc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc7
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/seekp/char/2346-fstream.cc (renamed from libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc)16
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/seekp/char/2346-sstream.cc (renamed from libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc)17
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc10
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc8
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char/10975.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/10975.cc57
10 files changed, 173 insertions, 27 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d7feffc7b3d..2e928168b28 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,21 @@
+2004-09-30 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/10975 (DR 453)
+ * include/bits/sstream.tcc (seekoff): Don't fail if __beg == 0
+ and __off == 0.
+ * docs/html/ext/howto.html: Add an entry for DR 453.
+ * testsuite/27_io/basic_stringbuf/seekoff/char/10975.cc: New.
+ * testsuite/27_io/basic_stringbuf/seekoff/wchar_t/10975.cc: Likewise.
+ * testsuite/27_io/basic_istream/tellg/char/1.cc: Tweak consistently.
+ * testsuite/27_io/basic_ostream/tellp/char/1.cc: Likewise.
+ * testsuite/27_io/basic_ostream/tellp/char/2.cc: Likewise.
+ * testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc: Fix and
+ move to...
+ * testsuite/27_io/basic_istream/seekp/char/2346-fstream.cc: ... here.
+ * testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc: Fix and
+ move to...
+ * testsuite/27_io/basic_istream/seekp/char/2346-sstream.cc: ... here.
+
2004-09-29 Paolo Carlini <pcarlini@suse.de>
* include/std/std_sstream.h (basic_stringbuf(ios_base::openmode)):
diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html
index 5670c469768..5b4a69fb1f7 100644
--- a/libstdc++-v3/docs/html/ext/howto.html
+++ b/libstdc++-v3/docs/html/ext/howto.html
@@ -496,6 +496,12 @@
</dt>
<dd>Replace &quot;new&quot; with &quot;::new&quot;.
</dd>
+
+ <dt><a href="lwg-active.html#453">453</a>:
+ <em>basic_stringbuf::seekoff need not always fail for an empty stream</em>
+ </dt>
+ <dd>Don't fail if the next pointer is null and newoff is zero.
+ </dd>
<!--
<dt><a href="lwg-defects.html#"></a>:
<em></em>
diff --git a/libstdc++-v3/include/bits/sstream.tcc b/libstdc++-v3/include/bits/sstream.tcc
index bd05cc2eb43..1b1232e9175 100644
--- a/libstdc++-v3/include/bits/sstream.tcc
+++ b/libstdc++-v3/include/bits/sstream.tcc
@@ -142,8 +142,10 @@ namespace std
__testin &= !(__mode & ios_base::out);
__testout &= !(__mode & ios_base::in);
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 453. basic_stringbuf::seekoff need not always fail for an empty stream.
const char_type* __beg = __testin ? this->eback() : this->pbase();
- if (__beg && (__testin || __testout || __testboth))
+ if ((__beg || !__off) && (__testin || __testout || __testboth))
{
_M_update_egptr();
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc
index d213d040a11..4bbe40be919 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/1.cc
@@ -31,20 +31,23 @@
void test01()
{
using namespace std;
+ typedef ios::off_type off_type;
typedef ios::pos_type pos_type;
bool test __attribute__((unused)) = true;
const char str_lit01[] = "istream_seeks-1.tst";
// in
- // test default ctors leave things in the same positions...
istringstream ist1;
pos_type p3 = ist1.tellg();
ifstream ifs1;
pos_type p4 = ifs1.tellg();
- VERIFY( p3 == p4 );
+ // N.B. We implement the resolution of DR 453 and
+ // istringstream::tellg() doesn't fail.
+ VERIFY( p3 == pos_type(off_type(0)) );
+ VERIFY( p4 == pos_type(off_type(-1)) );
// in
// test ctors leave things in the same positions...
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/seekp/char/2346-fstream.cc
index 72686f1b699..29d52f19988 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-fstream.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/seekp/char/2346-fstream.cc
@@ -1,6 +1,6 @@
// 2000-06-29 bkoz
-// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation
+// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation
//
// 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
@@ -18,11 +18,11 @@
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
-// 27.6.1.3 unformatted input functions
-// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// 27.6.2.4 basic_ostream seek members [lib.ostream.seeks]
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
+#include <ostream>
#include <istream>
#include <fstream>
#include <testsuite_hooks.h>
@@ -32,18 +32,18 @@ const int times = 10;
void write_rewind(std::iostream& stream)
{
+ bool test __attribute__((unused)) = true;
+
for (int j = 0; j < times; j++)
{
- bool test __attribute__((unused)) = true;
- std::streampos begin = stream.tellg();
+ std::streampos begin = stream.tellp();
for (int i = 0; i < times; ++i)
stream << j << '-' << i << s << '\n';
- stream.seekg(begin);
- std::streampos end = stream.tellg();
- std::streampos badpos = std::streampos(std::streambuf::off_type(-1));
+ stream.seekp(begin);
}
+ VERIFY( stream.good() );
}
void check_contents(std::iostream& stream)
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/seekp/char/2346-sstream.cc
index 60e43c9a78b..e0a7071cf31 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/2346-sstream.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/seekp/char/2346-sstream.cc
@@ -1,6 +1,6 @@
// 2000-06-29 bkoz
-// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation
+// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation
//
// 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
@@ -18,9 +18,9 @@
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
-// 27.6.1.3 unformatted input functions
-// NB: ostream has a particular "seeks" category. Adopt this for istreams too.
+// 27.6.2.4 basic_ostream seek members [lib.ostream.seeks]
+#include <ostream>
#include <istream>
#include <sstream>
#include <testsuite_hooks.h>
@@ -30,18 +30,18 @@ const int times = 10;
void write_rewind(std::iostream& stream)
{
+ bool test __attribute__((unused)) = true;
+
for (int j = 0; j < times; j++)
{
- bool test __attribute__((unused)) = true;
- std::streampos begin = stream.tellg();
+ std::streampos begin = stream.tellp();
for (int i = 0; i < times; ++i)
stream << j << '-' << i << s << '\n';
- stream.seekg(begin);
- std::streampos end = stream.tellg();
- std::streampos badpos = std::streampos(std::streambuf::off_type(-1));
+ stream.seekp(begin);
}
+ VERIFY( stream.good() );
}
void check_contents(std::iostream& stream)
@@ -65,6 +65,7 @@ void check_contents(std::iostream& stream)
// stringstream
// libstdc++/2346
+// N.B. The original testcase was broken, using tellg/seekg in write_rewind.
void test03()
{
std::stringstream sstrm;
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc
index 5c8caced6f3..27506636b03 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/1.cc
@@ -1,6 +1,6 @@
// 2000-06-29 bkoz
-// Copyright (C) 2000, 2003 Free Software Foundation
+// Copyright (C) 2000, 2003, 2004 Free Software Foundation
//
// 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
@@ -25,24 +25,26 @@
#include <fstream>
#include <testsuite_hooks.h>
-
void test01()
{
using namespace std;
+ typedef ios::off_type off_type;
typedef ios::pos_type pos_type;
bool test __attribute__((unused)) = true;
const char str_lit01[] = "ostream_seeks-1.txt";
// out
- // test default ctors leave things in the same positions...
ostringstream ost1;
pos_type p1 = ost1.tellp();
ofstream ofs1;
pos_type p2 = ofs1.tellp();
- VERIFY( p1 == p2 );
+ // N.B. We implement the resolution of DR 453 and
+ // ostringstream::tellp() doesn't fail.
+ VERIFY( p1 == pos_type(off_type(0)) );
+ VERIFY( p2 == pos_type(off_type(-1)) );
// out
// test ctors leave things in the same positions...
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc
index f82df5d4bb0..acdc3b4cc75 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/tellp/char/2.cc
@@ -1,6 +1,6 @@
// 2000-03-23 bkoz
-// Copyright (C) 2000, 2003 Free Software Foundation
+// Copyright (C) 2000, 2003, 2004 Free Software Foundation
//
// 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
@@ -33,13 +33,13 @@ void test01()
ostringstream ost;
pos_type pos1;
pos1 = ost.tellp();
- VERIFY( pos1 == pos_type(-1) );
+ VERIFY( pos1 == pos_type(off_type(0)) );
ost << "RZA ";
pos1 = ost.tellp();
- VERIFY( pos1 == pos_type(4) );
+ VERIFY( pos1 == pos_type(off_type(4)) );
ost << "ghost dog: way of the samurai";
pos1 = ost.tellp();
- VERIFY( pos1 == pos_type(33) );
+ VERIFY( pos1 == pos_type(off_type(33)) );
}
int main()
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char/10975.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char/10975.cc
new file mode 100644
index 00000000000..d97ecc98992
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char/10975.cc
@@ -0,0 +1,57 @@
+// 2004-09-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004 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.7.1.3 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/10975
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+ typedef streambuf::pos_type pos_type;
+ typedef streambuf::off_type off_type;
+
+ const pos_type good = pos_type(off_type(0));
+ const pos_type bad = pos_type(off_type(-1));
+ pos_type p;
+
+ stringbuf sbuf;
+
+ p = sbuf.pubseekoff(0, ios_base::cur, ios_base::in);
+ VERIFY( p == good );
+
+ p = sbuf.pubseekoff(0, ios_base::beg, ios_base::out);
+ VERIFY( p == good );
+
+ p = sbuf.pubseekoff(0, ios_base::end);
+ VERIFY( p == good );
+
+ p = sbuf.pubseekoff(0, ios_base::cur);
+ VERIFY( p == bad );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/10975.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/10975.cc
new file mode 100644
index 00000000000..1fef6278eb8
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/10975.cc
@@ -0,0 +1,57 @@
+// 2004-09-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004 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.7.1.3 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/10975
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+ typedef wstreambuf::pos_type pos_type;
+ typedef wstreambuf::off_type off_type;
+
+ const pos_type good = pos_type(off_type(0));
+ const pos_type bad = pos_type(off_type(-1));
+ pos_type p;
+
+ wstringbuf sbuf;
+
+ p = sbuf.pubseekoff(0, ios_base::cur, ios_base::in);
+ VERIFY( p == good );
+
+ p = sbuf.pubseekoff(0, ios_base::beg, ios_base::out);
+ VERIFY( p == good );
+
+ p = sbuf.pubseekoff(0, ios_base::end);
+ VERIFY( p == good );
+
+ p = sbuf.pubseekoff(0, ios_base::cur);
+ VERIFY( p == bad );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}