diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-22 19:40:43 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-22 19:40:43 +0000 |
commit | 3f7babea0ff1e2365dd2346f97c6f2c77257feff (patch) | |
tree | a04325d2591098556af14addef9debb056684968 /libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/4.cc | |
parent | a0f415f0a2526028dd14f39dabbec1672c566eac (diff) | |
download | gcc-3f7babea0ff1e2365dd2346f97c6f2c77257feff.tar.gz |
2010-09-22 David Krauss <potswa@mac.com>
PR libstdc++/45628
* include/bits/fstream.tcc (basic_filebuf::underflow): Add state
transition to avoid modality requiring seekoff(0,ios::cur).
(basic_filebuf::pbackfail): Likewise.
(basic_filebuf::overflow): Likewise.
(basic_filebuf::_M_seek): Avoid minor unnecessary conversion.
(basic_filebuf::seekoff): Remove code to _M_get_ext_pos; make
(0, ios::cur) a special case preserving buffer contents.
(basic_filebuf::_M_get_ext_pos): New function to obtain status
about codecvt extern_t buffer for overflow and seekoff.
* include/std/fstream (basic_filebuf::_M_get_ext_pos): Likewise.
* config/abi/pre/gnu.ver: Export new symbols.
* testsuite/27_io/basic_filebuf/seekoff/char/45628-1.cc: New,
verifies that seekoff(0, ios::cur) preserves buffers.
* testsuite/27_io/basic_filebuf/seekoff/char/45628-2.cc: Likewise.
for codecvt case. More lenient as it may still flush put area.
* testsuite/27_io/basic_filebuf/seekoff/char/4.cc: Modify to
check that seekoff is not required between read and write.
* testsuite/27_io/basic_filebuf/seekoff/wchar_t/4.cc: Likewise.
* testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: Remove.
* testsuite/27_io/basic_filebuf/sync/wchar_t/1.cc: Likewise.
* testsuite/util/testsuite_character.h (codecvt::do_length): Comply
with 22.2.1.5.2/10 "Returns ... the LARGEST value in the range..."
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164529 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/4.cc')
-rw-r--r-- | libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/4.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/4.cc index 9422f29f0d9..fe21b3a88e2 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/4.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/4.cc @@ -31,7 +31,7 @@ void test01() typedef filebuf::pos_type pos_type; const char name[] = "tmp_seekoff-4.tst"; - const size_t size = 10; + const size_t size = 12; char buf[size]; streamsize n; @@ -46,7 +46,7 @@ void test01() VERIFY( n == 3 ); VERIFY( !memcmp(buf, "abc", 3) ); - fb.pubseekoff(0, ios_base::cur); + // Check read => write without pubseekoff(0, ios_base::cur) n = fb.sputn("ef", 2); VERIFY( n == 2 ); @@ -58,9 +58,17 @@ void test01() VERIFY( !memcmp(buf, "abcef", 5) ); fb.pubseekoff(0, ios_base::beg); - n = fb.sputn("ghijkl", 6); - VERIFY( n == 6 ); + n = fb.sputn("gh", 2); + VERIFY( n == 2 ); + + // Check write => read without pubseekoff(0, ios_base::cur) + + n = fb.sgetn( buf, 3 ); + VERIFY( !memcmp(buf, "cef", 3) ); + n = fb.sputn("ijkl", 4); + VERIFY( n == 4 ); + fb.pubseekoff(0, ios_base::beg); n = fb.sgetn(buf, 2); VERIFY( n == 2 ); @@ -72,8 +80,8 @@ void test01() fb.pubseekoff(0, ios_base::beg); n = fb.sgetn(buf, size); - VERIFY( n == 9 ); - VERIFY( !memcmp(buf, "ghijklmno", 9) ); + VERIFY( n == 12 ); + VERIFY( !memcmp(buf, "ghcefijklmno", 12) ); fb.close(); } |