summaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-02-24 20:39:31 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2003-02-24 20:39:31 +0000
commite471a7ac353122909ec7f8bf63c4a7b45ba219f6 (patch)
treea7ad6d88a092d0335e69d0a93702ee68bb891066 /libstdc++-v3
parentb6f7edfa45212f759126c3dda5bb472e7e15014f (diff)
downloadgcc-e471a7ac353122909ec7f8bf63c4a7b45ba219f6.tar.gz
2003-02-24 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/9825 * src/fstream.cc (basic_filebuf<char/wchar_t>::_M_underflow_common): When __bump is true (uflow), always increment the read pointer (_M_in_cur) before returning successfully. * testsuite/27_io/filebuf_virtuals.cc (test12): Add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63378 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog9
-rw-r--r--libstdc++-v3/src/fstream.cc14
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc24
3 files changed, 45 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 30d0c0c049e..158f4b29335 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,12 @@
+2003-02-24 Paolo Carlini <pcarlini@unitus.it>
+
+ PR libstdc++/9825
+ * src/fstream.cc
+ (basic_filebuf<char/wchar_t>::_M_underflow_common): When
+ __bump is true (uflow), always increment the read pointer
+ (_M_in_cur) before returning successfully.
+ * testsuite/27_io/filebuf_virtuals.cc (test12): Add.
+
2003-02-24 Paolo Carlini <pcarlini@unitus.it>
Nathan Myers <ncm@cantrip.org>
diff --git a/libstdc++-v3/src/fstream.cc b/libstdc++-v3/src/fstream.cc
index 944bae27c38..5753e0055cd 100644
--- a/libstdc++-v3/src/fstream.cc
+++ b/libstdc++-v3/src/fstream.cc
@@ -53,7 +53,12 @@ namespace std
{
_M_pback_destroy();
if (_M_in_cur < _M_in_end)
- return traits_type::to_int_type(*_M_in_cur);
+ {
+ __ret = traits_type::to_int_type(*_M_in_cur);
+ if (__bump)
+ _M_in_cur_move(1);
+ return __ret;
+ }
}
// Sync internal and external buffers.
@@ -128,7 +133,12 @@ namespace std
{
_M_pback_destroy();
if (_M_in_cur < _M_in_end)
- return traits_type::to_int_type(*_M_in_cur);
+ {
+ __ret = traits_type::to_int_type(*_M_in_cur);
+ if (__bump)
+ _M_in_cur_move(1);
+ return __ret;
+ }
}
// Sync internal and external buffers.
diff --git a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
index fc9262f8e75..660abd1752a 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
+++ b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
@@ -73,6 +73,7 @@ const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
+const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
@@ -681,6 +682,28 @@ void test11()
dfbuf_02.close();
}
+// libstdc++/9825
+void test12()
+{
+ using namespace std;
+ bool test = true;
+
+ filebuf fbuf;
+
+ fbuf.open(name_06, ios_base::in|ios_base::out|ios_base::trunc);
+ fbuf.sputn("crazy bees!", 11);
+ fbuf.pubseekoff(0, ios_base::beg);
+ fbuf.sbumpc();
+ fbuf.sputbackc('x');
+ filebuf::int_type c = fbuf.sbumpc();
+ VERIFY( c == 'x' );
+ c = fbuf.sbumpc();
+ VERIFY( c == 'r' );
+ c = fbuf.sbumpc();
+ VERIFY( c == 'a' );
+ fbuf.close();
+}
+
main()
{
test01();
@@ -696,5 +719,6 @@ main()
test09();
test10();
test11();
+ test12();
return 0;
}