aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo@gcc.gnu.org>2003-02-04 18:08:45 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2003-02-04 18:08:45 +0000
commit7cd3907b57b0dc2d968a90be5985db4c897e11ca (patch)
tree82cde50835a300e4ff4bae0d4ed772e3cc147011
parent09f26fb511eb0cb0184bf81111b7041ae8ae6042 (diff)
downloadgcc-7cd3907b57b0dc2d968a90be5985db4c897e11ca.zip
gcc-7cd3907b57b0dc2d968a90be5985db4c897e11ca.tar.gz
gcc-7cd3907b57b0dc2d968a90be5985db4c897e11ca.tar.bz2
[multiple changes]
2003-02-04 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/9538 * include/bits/streambuf.tcc (sputbackc): Access this->gptr()[-1] only if _M_in_beg < _M_in_cur. * testsuite/27_io/filebuf_virtuals.cc (test08): Add. 2003-02-04 Paolo Carlini <pcarlini@unitus.it> PR libstdc++/9507 * include/bits/fstream.tcc (open): If the 'ate' repositioning operation fails, calls close _and_ returns a null pointer to indicate failure (27.8.1.3,4). * testsuite/27_io/filebuf_members.cc (test_06): Add. 2003-02-04 Petur Runolfsson <peturr02@ru.is> * testsuite/27_io/filebuf_members.cc (test_04): Remove exit(0). From-SVN: r62388
-rw-r--r--libstdc++-v3/ChangeLog19
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc6
-rw-r--r--libstdc++-v3/include/bits/streambuf.tcc3
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf_members.cc29
-rw-r--r--libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc34
5 files changed, 87 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d9c4f4c..ac01012 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,22 @@
+2003-02-04 Paolo Carlini <pcarlini@unitus.it>
+
+ PR libstdc++/9538
+ * include/bits/streambuf.tcc (sputbackc): Access
+ this->gptr()[-1] only if _M_in_beg < _M_in_cur.
+ * testsuite/27_io/filebuf_virtuals.cc (test08): Add.
+
+2003-02-04 Paolo Carlini <pcarlini@unitus.it>
+
+ PR libstdc++/9507
+ * include/bits/fstream.tcc (open): If the 'ate' repositioning
+ operation fails, calls close _and_ returns a null pointer
+ to indicate failure (27.8.1.3,4).
+ * testsuite/27_io/filebuf_members.cc (test_06): Add.
+
+2003-02-04 Petur Runolfsson <peturr02@ru.is>
+
+ * testsuite/27_io/filebuf_members.cc (test_04): Remove exit(0).
+
2002-02-04 Jonathan Wakely <redi@gcc.gnu.org>
* docs/html/27_io/howto.html: New section on stdio_filebuf.
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index bf1c42e..c5f9758 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -103,7 +103,11 @@ namespace std
if ((__mode & ios_base::ate)
&& this->seekoff(0, ios_base::end, __mode) < 0)
- this->close();
+ {
+ // 27.8.1.3,4
+ this->close();
+ return __ret;
+ }
__ret = this;
}
diff --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc
index 73db2cd..cb6f95d 100644
--- a/libstdc++-v3/include/bits/streambuf.tcc
+++ b/libstdc++-v3/include/bits/streambuf.tcc
@@ -67,8 +67,7 @@ namespace std
{
int_type __ret;
bool __testpos = _M_in_cur && _M_in_beg < _M_in_cur;
- bool __testne = _M_in_cur && !traits_type::eq(__c, this->gptr()[-1]);
- if (!__testpos || __testne)
+ if (!__testpos || !traits_type::eq(__c, this->gptr()[-1]))
__ret = this->pbackfail(traits_type::to_int_type(__c));
else
{
diff --git a/libstdc++-v3/testsuite/27_io/filebuf_members.cc b/libstdc++-v3/testsuite/27_io/filebuf_members.cc
index 9f48229..88b0535 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf_members.cc
+++ b/libstdc++-v3/testsuite/27_io/filebuf_members.cc
@@ -172,7 +172,6 @@ test_04()
}
unlink("xxx");
- exit(0);
}
// Charles Leggett <CGLeggett@lbl.gov>
@@ -191,6 +190,33 @@ void test_05()
scratch_file.close();
}
+// libstdc++/9507
+void test_06()
+{
+ bool test = true;
+
+ signal(SIGPIPE, SIG_IGN);
+
+ unlink("yyy");
+ mkfifo("yyy", S_IRWXU);
+
+ if (!fork())
+ {
+ std::filebuf fbuf;
+ fbuf.open("yyy", std::ios_base::in);
+ fbuf.sgetc();
+ fbuf.close();
+
+ exit(0);
+ }
+
+ std::filebuf fbuf;
+ std::filebuf* r =
+ fbuf.open("yyy", std::ios_base::out | std::ios_base::ate);
+ VERIFY( !fbuf.is_open() );
+ VERIFY( r == NULL );
+}
+
int
main()
{
@@ -199,6 +225,7 @@ main()
test_03();
test_04();
test_05();
+ test_06();
return 0;
}
diff --git a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
index c02e1a7..75c2e1c 100644
--- a/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
+++ b/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
@@ -537,6 +537,39 @@ void test07()
VERIFY( ob.getloc() == loc_de );
}
+class MyTraits : public std::char_traits<char>
+{
+public:
+ static bool eq(char c1, char c2)
+ {
+ VERIFY( c1 >= 0 );
+ VERIFY( c2 >= 0 );
+ return std::char_traits<char>::eq(c1, c2);
+ }
+};
+
+class MyBuf : public std::basic_streambuf<char, MyTraits>
+{
+ char buffer[8];
+
+public:
+ MyBuf()
+ {
+ std::memset(buffer, -1, sizeof(buffer));
+ std::memset(buffer + 2, 0, 4);
+ setg(buffer + 2, buffer + 2, buffer + 6);
+ }
+};
+
+// libstdc++/9538
+void test08()
+{
+ bool test = true;
+
+ MyBuf mb;
+ mb.sputbackc(0);
+}
+
main()
{
test01();
@@ -548,5 +581,6 @@ main()
test06();
test07();
+ test08();
return 0;
}