[libcxx] r193814 - LWG issue 2341; Make the two variants of basic_ostream::seekp and basic_istream::seekg behave consistently; update tests to make sure
Marshall Clow
mclow.lists at gmail.com
Thu Oct 31 15:20:46 PDT 2013
Author: marshall
Date: Thu Oct 31 17:20:45 2013
New Revision: 193814
URL: http://llvm.org/viewvc/llvm-project?rev=193814&view=rev
Log:
LWG issue 2341; Make the two variants of basic_ostream::seekp and basic_istream::seekg behave consistently; update tests to make sure
Modified:
libcxx/trunk/include/istream
libcxx/trunk/include/ostream
libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp
libcxx/trunk/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp
Modified: libcxx/trunk/include/istream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=193814&r1=193813&r2=193814&view=diff
==============================================================================
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Thu Oct 31 17:20:45 2013
@@ -1369,8 +1369,10 @@ basic_istream<_CharT, _Traits>::seekg(po
this->clear(this->rdstate() & ~ios_base::eofbit);
sentry __sen(*this, true);
if (__sen)
+ {
if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
this->setstate(ios_base::failbit);
+ }
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -1391,7 +1393,10 @@ basic_istream<_CharT, _Traits>::seekg(of
#endif // _LIBCPP_NO_EXCEPTIONS
sentry __sen(*this, true);
if (__sen)
- this->rdbuf()->pubseekoff(__off, __dir, ios_base::in);
+ {
+ if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
+ this->setstate(ios_base::failbit);
+ }
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
Modified: libcxx/trunk/include/ostream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ostream?rev=193814&r1=193813&r2=193814&view=diff
==============================================================================
--- libcxx/trunk/include/ostream (original)
+++ libcxx/trunk/include/ostream Thu Oct 31 17:20:45 2013
@@ -1159,7 +1159,8 @@ inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
{
- if (!this->fail())
+ sentry __s(*this);
+ if (__s)
{
if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
this->setstate(ios_base::failbit);
@@ -1172,8 +1173,12 @@ inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
{
- if (!this->fail())
- this->rdbuf()->pubseekoff(__off, __dir, ios_base::out);
+ sentry __s(*this);
+ if (__s)
+ {
+ if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
+ this->setstate(ios_base::failbit);
+ }
return *this;
}
Modified: libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp?rev=193814&r1=193813&r2=193814&view=diff
==============================================================================
--- libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp (original)
+++ libcxx/trunk/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp Thu Oct 31 17:20:45 2013
@@ -57,12 +57,18 @@ int main()
is.seekg(5, std::ios_base::cur);
assert(is.good());
assert(seekoff_called == 1);
+ is.seekg(-1, std::ios_base::beg);
+ assert(is.fail());
+ assert(seekoff_called == 2);
}
{
testbuf<wchar_t> sb(L" 123456789");
std::wistream is(&sb);
is.seekg(5, std::ios_base::cur);
assert(is.good());
- assert(seekoff_called == 2);
+ assert(seekoff_called == 3);
+ is.seekg(-1, std::ios_base::beg);
+ assert(is.fail());
+ assert(seekoff_called == 4);
}
}
Modified: libcxx/trunk/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp?rev=193814&r1=193813&r2=193814&view=diff
==============================================================================
--- libcxx/trunk/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp (original)
+++ libcxx/trunk/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp Thu Oct 31 17:20:45 2013
@@ -54,6 +54,6 @@ int main()
assert(os.good());
assert(&os.seekp(-1, std::ios_base::beg) == &os);
assert(seekoff_called == 2);
- assert(os.good());
+ assert(os.fail());
}
}
More information about the cfe-commits
mailing list