summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-01 05:38:27 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2002-11-01 05:38:27 +0000
commit679c5941f6ecb8686be342f2012fb0884c5b3555 (patch)
tree5300fc4a8ade525eb2191e63aa079db2cc2b894e
parentb075bdcc8d0819c1c6cbefd95cd43af3f17bd034 (diff)
downloadppe42-gcc-679c5941f6ecb8686be342f2012fb0884c5b3555.tar.gz
ppe42-gcc-679c5941f6ecb8686be342f2012fb0884c5b3555.zip
2002-10-31 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/8348 * include/bits/istream.tcc (istream::tellg): Remove sentry bits. (istream::seekg): Same. * testsuite/27_io/istream_seeks.cc (test06): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@58703 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/istream.tcc61
-rw-r--r--libstdc++-v3/testsuite/27_io/istream_seeks.cc57
3 files changed, 63 insertions, 62 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 55b79be1a9a..3a2ee83669c 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2002-10-31 Benjamin Kosnik <bkoz@redhat.com>
+
+ PR libstdc++/8348
+ * include/bits/istream.tcc (istream::tellg): Remove sentry bits.
+ (istream::seekg): Same.
+ * testsuite/27_io/istream_seeks.cc (test06): New.
+
2002-10-28 Jason Thorpe <thorpej@wasabisystems.com>
* testsuite/thread/pthread5.cc: Include <unistd.h>
diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc
index 58e2caf02cd..617110d953b 100644
--- a/libstdc++-v3/include/bits/istream.tcc
+++ b/libstdc++-v3/include/bits/istream.tcc
@@ -935,23 +935,8 @@ namespace std
tellg(void)
{
pos_type __ret = pos_type(-1);
- _M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb)
- {
- try
- {
- __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
- }
- catch(exception& __fail)
- {
- // 27.6.1.3 paragraph 1
- // Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
- if ((this->exceptions() & ios_base::badbit) != 0)
- __throw_exception_again;
- }
- }
+ if (!this->fail())
+ __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
return __ret;
}
@@ -962,28 +947,16 @@ namespace std
seekg(pos_type __pos)
{
_M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb)
+ if (!this->fail())
{
- try
- {
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// 136. seekp, seekg setting wrong streams?
- pos_type __err = this->rdbuf()->pubseekpos(__pos, ios_base::in);
+ pos_type __err = this->rdbuf()->pubseekpos(__pos, ios_base::in);
// 129. Need error indication from seekp() and seekg()
- if (__err == pos_type(off_type(-1)))
- this->setstate(ios_base::failbit);
+ if (__err == pos_type(off_type(-1)))
+ this->setstate(ios_base::failbit);
#endif
- }
- catch(exception& __fail)
- {
- // 27.6.1.3 paragraph 1
- // Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
- if ((this->exceptions() & ios_base::badbit) != 0)
- __throw_exception_again;
- }
}
return *this;
}
@@ -994,29 +967,17 @@ namespace std
seekg(off_type __off, ios_base::seekdir __dir)
{
_M_gcount = 0;
- sentry __cerb(*this, true);
- if (__cerb)
+ if (!this->fail())
{
- try
- {
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// 136. seekp, seekg setting wrong streams?
- pos_type __err = this->rdbuf()->pubseekoff(__off, __dir,
- ios_base::in);
+ pos_type __err = this->rdbuf()->pubseekoff(__off, __dir,
+ ios_base::in);
// 129. Need error indication from seekp() and seekg()
- if (__err == pos_type(off_type(-1)))
- this->setstate(ios_base::failbit);
+ if (__err == pos_type(off_type(-1)))
+ this->setstate(ios_base::failbit);
#endif
- }
- catch(exception& __fail)
- {
- // 27.6.1.3 paragraph 1
- // Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
- if ((this->exceptions() & ios_base::badbit) != 0)
- __throw_exception_again;
- }
}
return *this;
}
diff --git a/libstdc++-v3/testsuite/27_io/istream_seeks.cc b/libstdc++-v3/testsuite/27_io/istream_seeks.cc
index cd0e0656748..892e10bcb1e 100644
--- a/libstdc++-v3/testsuite/27_io/istream_seeks.cc
+++ b/libstdc++-v3/testsuite/27_io/istream_seeks.cc
@@ -55,11 +55,6 @@ bool test01()
p4 = ifs2.tellg();
VERIFY( p3 == p4 );
-
-#ifdef DEBUG_ASSERT
- assert(test);
-#endif
-
return test;
}
@@ -237,10 +232,6 @@ void test04(void)
if01.peek();
pos02 = if01.tellg();
VERIFY( pos02 == pos01 );
-
-#ifdef DEBUG_ASSERT
- assert(test);
-#endif
}
// stringstreams
@@ -351,10 +342,50 @@ void test05(void)
VERIFY( state01 == state02 );
pos06 = is03.tellg();
VERIFY( pos05 == pos06 );
+}
-#ifdef DEBUG_ASSERT
- assert(test);
-#endif
+// libstdc++/8348
+void test06(void)
+{
+ using namespace std;
+ bool test = true;
+ string num1("555");
+
+ // tellg
+ {
+ istringstream iss(num1);
+ istream::pos_type pos1 = iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.tellg();
+ VERIFY( test = !iss.fail() );
+ }
+
+ // seekg
+ {
+ istringstream iss(num1);
+ istream::pos_type pos1 = iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(0, ios_base::beg);
+ VERIFY( test = !iss.fail() );
+ }
+
+ // seekg
+ {
+ istringstream iss(num1);
+ istream::pos_type pos1 = iss.tellg();
+ int asNum = 0;
+ iss >> asNum;
+ VERIFY( test = iss.eof() );
+ VERIFY( test = !iss.fail() );
+ iss.seekg(pos1);
+ VERIFY( test = !iss.fail() );
+ }
}
int main()
@@ -366,6 +397,8 @@ int main()
test04();
test05();
+
+ test06();
return 0;
}
OpenPOWER on IntegriCloud