diff options
| author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-18 23:26:32 +0000 |
|---|---|---|
| committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-18 23:26:32 +0000 |
| commit | 68aafaa05d8a81bfab73e61bbd7fb0b769a9b899 (patch) | |
| tree | 31433e473479468cebb7c703dca648eaaf19825c | |
| parent | 3c002acee9f0c1fd935dc04f306127beab3e2af1 (diff) | |
| download | ppe42-gcc-68aafaa05d8a81bfab73e61bbd7fb0b769a9b899.tar.gz ppe42-gcc-68aafaa05d8a81bfab73e61bbd7fb0b769a9b899.zip | |
2003-02-18 Paolo Carlini <pcarlini@unitus.it>
* include/std/std_sstream.h (str()): the size of the
current string may be different from the initial one
whenever _M_out_end > _M_out_beg.
* testsuite/27_io/stringbuf_members.cc (test07): Add.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63066 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
| -rw-r--r-- | libstdc++-v3/include/std/std_sstream.h | 2 | ||||
| -rw-r--r-- | libstdc++-v3/testsuite/27_io/stringbuf_members.cc | 29 |
3 files changed, 36 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 46a80698aba..7860617c012 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2003-02-18 Paolo Carlini <pcarlini@unitus.it> + * include/std/std_sstream.h (str()): the size of the + current string may be different from the initial one + whenever _M_out_end > _M_out_beg. + * testsuite/27_io/stringbuf_members.cc (test07): Add. + +2003-02-18 Paolo Carlini <pcarlini@unitus.it> + PR libstdc++/9582 * include/bits/stl_alloc.h (__pool_alloc::allocate): Remove assert. diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h index 0ad52d023c8..268478f3339 100644 --- a/libstdc++-v3/include/std/std_sstream.h +++ b/libstdc++-v3/include/std/std_sstream.h @@ -140,7 +140,7 @@ namespace std // _M_string, and may not be the correct size of the // current stringbuf internal buffer. __size_type __len = _M_string.size(); - if (this->_M_out_cur > this->_M_out_beg) + if (this->_M_out_end > this->_M_out_beg) __len = std::max(__size_type(this->_M_out_end - this->_M_out_beg), __len); return __string_type(this->_M_out_beg, this->_M_out_beg + __len); diff --git a/libstdc++-v3/testsuite/27_io/stringbuf_members.cc b/libstdc++-v3/testsuite/27_io/stringbuf_members.cc index bc0bbb4dd8e..5e493301890 100644 --- a/libstdc++-v3/testsuite/27_io/stringbuf_members.cc +++ b/libstdc++-v3/testsuite/27_io/stringbuf_members.cc @@ -1,6 +1,6 @@ // 981208 bkoz test functionality of basic_stringbuf for char_type == char -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -473,6 +473,32 @@ bool test06() return test; } +// http://gcc.gnu.org/ml/libstdc++/2003-02/msg00269.html +// Growing and then seeking to ios_base::beg triggered a bug in str(), +// which didn't notice the grow. +bool test07() +{ + bool test = true; + + std::stringbuf strb_01; + strb_01.sputc('s'); + strb_01.pubseekoff(0, std::ios_base::beg); + VERIFY( strb_01.str() == "s" ); + + std::string str("strivi,"); + std::stringbuf strb_02(str); + strb_02.pubseekoff(0, std::ios_base::end); + strb_02.sputn(" no better!", 11); + strb_02.pubseekoff(0, std::ios_base::beg); + VERIFY( strb_02.str() == "strivi, no better!" ); + +#ifdef DEBUG_ASSERT + assert(test); +#endif + + return test; +} + int main() { test01(); @@ -481,6 +507,7 @@ int main() test04(); test05(); test06(); + test07(); return 0; } |

