diff options
author | Nathan Myers <ncm@cantrip.org> | 2003-04-14 22:43:32 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2003-04-14 22:43:32 +0000 |
commit | 21a1d2c493e2d81e2adb0165bfeccfdaa963bd3f (patch) | |
tree | 64065f4ecbc88f651936567cbfbc56ac32c2a405 | |
parent | 629f6514b833a56608fb06fe6a0832a1782a04c9 (diff) | |
download | gcc-21a1d2c493e2d81e2adb0165bfeccfdaa963bd3f.zip gcc-21a1d2c493e2d81e2adb0165bfeccfdaa963bd3f.tar.gz gcc-21a1d2c493e2d81e2adb0165bfeccfdaa963bd3f.tar.bz2 |
PR libstdc++/9701 (in_avail())
2003-04-14 Nathan Myers <ncm@cantrip.org>
Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/9701 (in_avail())
* include/std/std_streambuf.h (in_avail): Simplify, in_avail
doesn't care if there is anything in some putback cell.
* testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc: Add.
* testsuite/27_io/basic_filebuf/in_avail/char/1.cc: Remove some
unused string literals.
Co-Authored-By: Paolo Carlini <pcarlini@unitus.it>
From-SVN: r65603
-rw-r--r-- | libstdc++-v3/ChangeLog | 11 | ||||
-rw-r--r-- | libstdc++-v3/include/std/std_streambuf.h | 17 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/basic_filebuf/in_avail/char/1.cc | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc | 59 |
4 files changed, 72 insertions, 20 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 26d0095..f43490c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2003-04-14 Nathan Myers <ncm@cantrip.org> + Paolo Carlini <pcarlini@unitus.it> + + PR libstdc++/9701 (in_avail()) + * include/std/std_streambuf.h (in_avail): Simplify, in_avail + doesn't care if there is anything in some putback cell. + * testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc: Add. + + * testsuite/27_io/basic_filebuf/in_avail/char/1.cc: Remove some + unused string literals. + 2003-04-14 Paolo Carlini <pcarlini@unitus.it> * include/bits/fstream.tcc (basic_filebuf::setbuf): Don't set diff --git a/libstdc++-v3/include/std/std_streambuf.h b/libstdc++-v3/include/std/std_streambuf.h index f6a31ac..62ea740 100644 --- a/libstdc++-v3/include/std/std_streambuf.h +++ b/libstdc++-v3/include/std/std_streambuf.h @@ -403,21 +403,8 @@ namespace std streamsize in_avail() { - streamsize __ret; - if (_M_in_cur && _M_in_cur < _M_in_end) - { - if (_M_pback_init) - { - size_t __save_len = _M_pback_end_save - _M_pback_cur_save; - size_t __pback_len = _M_in_cur - _M_pback; - __ret = __save_len - __pback_len; - } - else - __ret = this->egptr() - this->gptr(); - } - else - __ret = this->showmanyc(); - return __ret; + streamsize __ret = _M_in_end - _M_in_cur; + return __ret ? __ret : this->showmanyc(); } /** diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/in_avail/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/in_avail/char/1.cc index 479ff7b..306060e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/in_avail/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/in_avail/char/1.cc @@ -44,11 +44,6 @@ const char carray_02[] = "memphis, new orleans, and savanah"; const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create -const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create -const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create -const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create -const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create -const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create class derived_filebuf: public std::filebuf { diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc new file mode 100644 index 0000000..4f98839 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.5.2.2.3 Get area + +#include <fstream> +#include <testsuite_hooks.h> + +class Derived_fbuf : public std::filebuf +{ +public: + const char_type* pub_egptr() const + { return egptr(); } + + const char_type* pub_gptr() const + { return gptr(); } +}; + +// libstdc++/9701 (in_avail) +void test01() +{ + using namespace std; + bool test = true; + const char* name = "tmp_file1"; + + Derived_fbuf df2; + df2.open(name, ios_base::in | ios_base::out | ios_base::trunc); + + df2.sputn("Comomoc", 7); + + df2.pubseekoff(0, ios_base::beg); + df2.sbumpc(); + df2.sputbackc('t'); + + VERIFY( df2.pub_gptr() < df2.pub_egptr() ); + VERIFY( df2.in_avail() == df2.pub_egptr() - df2.pub_gptr() ); +} + +int +main() +{ + test01(); + return 0; +} |