summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-02 20:37:06 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-02 20:37:06 +0000
commitd085eae1c1b16fcb233befb866fa5867d80aa1ad (patch)
tree4d184b4b415b37498837bdba6a3fc0f2e46b5118
parent6c7890e8571fce4b57dc9998a006d98f079af6ee (diff)
downloadgcc-d085eae1c1b16fcb233befb866fa5867d80aa1ad.tar.gz
2003-10-02 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/12232 * include/bits/fstream.tcc (seekoff): Ignore the openmode argument; simplify. * config/io/basic_file_stdio.h (__basic_file<char>::seekoff, seekpos): Remove the openmode argument. * config/io/basic_file_stdio.cc (__basic_file<char>::seekoff, seekpos): Remove redundant placeholder for the openmode argument. * testsuite/27_io/basic_filebuf/seekoff/char/12232.cc: New. * testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc: Tweak. * testsuite/27_io/basic_filebuf/seekoff/char/3-out.cc: Likewise. * testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc: Likewise. * testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72048 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog15
-rw-r--r--libstdc++-v3/config/io/basic_file_stdio.cc5
-rw-r--r--libstdc++-v3/config/io/basic_file_stdio.h6
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc15
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/12232.cc72
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc10
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-out.cc8
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc10
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc10
9 files changed, 115 insertions, 36 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 7224004a186..2cc15acf19a 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,18 @@
+2003-10-02 Paolo Carlini <pcarlini@unitus.it>
+
+ PR libstdc++/12232
+ * include/bits/fstream.tcc (seekoff): Ignore the openmode
+ argument; simplify.
+ * config/io/basic_file_stdio.h (__basic_file<char>::seekoff,
+ seekpos): Remove the openmode argument.
+ * config/io/basic_file_stdio.cc (__basic_file<char>::seekoff,
+ seekpos): Remove redundant placeholder for the openmode argument.
+ * testsuite/27_io/basic_filebuf/seekoff/char/12232.cc: New.
+ * testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc: Tweak.
+ * testsuite/27_io/basic_filebuf/seekoff/char/3-out.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc: Likewise.
+
2003-10-02 Benjamin Kosnik <bkoz@redhat.com>
* src/locale.cc (locale::_S_initialize): Use __gthread_active_p.
diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc
index b531906a3f8..b3223f50ca7 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.cc
+++ b/libstdc++-v3/config/io/basic_file_stdio.cc
@@ -261,12 +261,11 @@ namespace std
}
streampos
- __basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way,
- ios_base::openmode /*__mode*/)
+ __basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way)
{ return lseek(this->fd(), __off, __way); }
streampos
- __basic_file<char>::seekpos(streampos __pos, ios_base::openmode /*__mode*/)
+ __basic_file<char>::seekpos(streampos __pos)
{ return lseek(this->fd(), __pos, ios_base::beg); }
int
diff --git a/libstdc++-v3/config/io/basic_file_stdio.h b/libstdc++-v3/config/io/basic_file_stdio.h
index 2b1a9871c32..2ff2ba464fc 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.h
+++ b/libstdc++-v3/config/io/basic_file_stdio.h
@@ -98,12 +98,10 @@ namespace std
xsgetn(char* __s, streamsize __n);
streampos
- seekoff(streamoff __off, ios_base::seekdir __way,
- ios_base::openmode __mode = ios_base::in | ios_base::out);
+ seekoff(streamoff __off, ios_base::seekdir __way);
streampos
- seekpos(streampos __pos,
- ios_base::openmode __mode = ios_base::in | ios_base::out);
+ seekpos(streampos __pos);
int
sync();
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 31175559bb9..4a7ad850f38 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -572,15 +572,18 @@ namespace std
return this;
}
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // According to 27.8.1.4 p11 - 13 (for seekoff) and the resolution of
+ // DR 171 (for seekpos), both functions should ignore the last argument
+ // (of type openmode).
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::
- seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
+ seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode)
{
pos_type __ret = pos_type(off_type(-1));
- const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
- const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
-
+
int __width = 0;
if (_M_codecvt)
__width = _M_codecvt->encoding();
@@ -588,7 +591,7 @@ namespace std
__width = 0;
const bool __testfail = __off != 0 && __width <= 0;
- if (this->is_open() && !__testfail && (__testin || __testout))
+ if (this->is_open() && !__testfail)
{
// Ditch any pback buffers to avoid confusion.
_M_destroy_pback();
@@ -618,7 +621,7 @@ namespace std
}
// Returns pos_type(off_type(-1)) in case of failure.
- __ret = _M_file.seekoff(__computed_off, __way, __mode);
+ __ret = _M_file.seekoff(__computed_off, __way);
_M_reading = false;
_M_writing = false;
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/12232.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/12232.cc
new file mode 100644
index 00000000000..430183162fc
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/12232.cc
@@ -0,0 +1,72 @@
+// 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 <testsuite_hooks.h>
+
+const char name[] = "tmp_12232";
+
+// libstdc++/12232
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ filebuf fbout;
+ fbout.open(name, ios_base::out);
+ fbout.sputn("abc", 3);
+
+ streampos p1 = fbout.pubseekoff(0, ios_base::cur, ios_base::in);
+ VERIFY( p1 != streampos(-1) );
+ fbout.sputn("de", 2);
+
+ streampos p2 = fbout.pubseekpos(p1, ios_base::openmode());
+ VERIFY( p2 != streampos(-1) );
+ fbout.sputn("34", 2);
+
+ streampos p3 = fbout.pubseekoff(0, ios_base::beg, ios_base::ate);
+ VERIFY( p3 != streampos(-1) );
+ fbout.sputn("012", 3);
+
+ fbout.close();
+
+ filebuf fbin;
+ fbin.open(name, ios_base::in);
+
+ streampos p4 = fbin.pubseekoff(0, ios_base::beg, ios_base::ate);
+ VERIFY( p4 != streampos(-1) );
+ VERIFY( fbin.sgetc() == '0' );
+
+ streampos p5 = fbin.pubseekoff(-1, ios_base::end, ios_base::out);
+ VERIFY( p5 != streampos(-1) );
+ VERIFY( fbin.sbumpc() == '4' );
+
+ streampos p6 = fbin.pubseekpos(p4, ios_base::binary);
+ VERIFY( p6 != streampos(-1) );
+ VERIFY( fbin.sbumpc() == '0' );
+
+ fbin.close();
+}
+
+int main()
+{
+ void test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc
index 2a798dbbf16..3d28f6f5dae 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc
@@ -34,15 +34,13 @@ void test02(std::filebuf& in, bool pass)
// seekoff
p = in.pubseekoff(0, ios_base::beg, ios_base::in);
- if (pass)
- VERIFY( p != bad );
+ VERIFY( pass == (p != bad) );
- p = in.pubseekoff(0, ios_base::beg, ios_base::out);
- VERIFY( p == bad );
+ p = in.pubseekoff(0, ios_base::beg, ios_base::out);
+ VERIFY( pass == (p != bad) ); // See libstdc++/12232
p = in.pubseekoff(0, ios_base::beg);
- if (pass)
- VERIFY( p != bad );
+ VERIFY( pass == (p != bad) );
}
const char name_01[] = "filebuf_virtuals-1.tst"; // file with data in it
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-out.cc
index d803e5551ff..fda7be2f45c 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-out.cc
@@ -34,15 +34,13 @@ void test02(std::filebuf& in, bool pass)
// seekoff
p = in.pubseekoff(0, ios_base::beg, ios_base::in);
- VERIFY( p == bad );
+ VERIFY( pass == (p != bad) ); // See libstdc++/12232
p = in.pubseekoff(0, ios_base::beg, ios_base::out);
- if (pass)
- VERIFY( p != bad );
+ VERIFY( pass == (p != bad) );
p = in.pubseekoff(0, ios_base::beg);
- if (pass)
- VERIFY( p != bad );
+ VERIFY( pass == (p != bad) );
}
const char name_01[] = "filebuf_virtuals-1.tst"; // file with data in it
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc
index 39f18de3b05..e18030a5ace 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc
@@ -34,15 +34,13 @@ void test02(std::filebuf& in, bool pass)
// seekpos
p = in.pubseekpos(0, ios_base::in);
- if (pass)
- VERIFY( p != bad );
+ VERIFY( pass == (p != bad) );
- p = in.pubseekpos(0, ios_base::out);
- VERIFY( p == bad );
+ p = in.pubseekpos(0, ios_base::out);
+ VERIFY( pass == (p != bad) ); // See libstdc++/12232
p = in.pubseekpos(0);
- if (pass)
- VERIFY( p != bad );
+ VERIFY( pass == (p != bad) );
}
const char name_01[] = "filebuf_virtuals-1.tst"; // file with data in it
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc
index 9dd1ab8a066..ecd8433f3fb 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc
@@ -34,15 +34,13 @@ void test02(std::filebuf& in, bool pass)
// seekpos
p = in.pubseekpos(0, ios_base::in);
- VERIFY( p == bad );
+ VERIFY( pass == (p != bad) ); // See libstdc++/12232
p = in.pubseekpos(0, ios_base::out);
- if (pass)
- VERIFY( p != bad );
+ VERIFY( pass == (p != bad) );
- p = in.pubseekpos(0);
- if (pass)
- VERIFY( p != bad );
+ p = in.pubseekpos(0);
+ VERIFY( pass == (p != bad) );
}
const char name_01[] = "filebuf_virtuals-1.tst"; // file with data in it