Commit 21a1d2c4 by Nathan Myers Committed by Paolo Carlini

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
parent 629f6514
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
......
......@@ -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();
}
/**
......
......@@ -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
{
......
// 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment