summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-08 17:29:44 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-08 17:29:44 +0000
commitec722c30b1eaeca10b587bb3972ce0f3d25db37d (patch)
tree3d40a9b1cf39b61c1b41528d779cb747f7eb263c /libstdc++-v3/include
parentede34e3c5bbcf9fb60e81325f17ddbac114dd8d3 (diff)
downloadgcc-ec722c30b1eaeca10b587bb3972ce0f3d25db37d.tar.gz
2005-06-08 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/21955 * include/std/std_sstream.h (basic_stringbuf::showmanyc): Add. Remove unnecessary this->_M_mode decoration. * include/bits/fstream.tcc: Adjust line spacing. * testsuite/27_io/basic_streambuf/in_avail/char/1.cc: New, test base class behavior. * testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc: Same. * testsuite/27_io/basic_stringbuf/in_avail/char/21955.cc: New. * testsuite/27_io/basic_stringbuf/in_avail/char/1.cc: Match filebuf behavior. * testsuite/27_io/basic_stringbuf/in_avail/wchar_t/1.cc: Same. * testsuite/27_io/basic_stringbuf/str/wchar_t/1.cc: Same. * testsuite/27_io/basic_stringbuf/str/char/1.cc: Same. * testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc: Move... * testsuite/27_io/basic_filebuf/in_avail/char/9701-3.cc: ...here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100770 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc3
-rw-r--r--libstdc++-v3/include/std/std_sstream.h36
2 files changed, 25 insertions, 14 deletions
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 40bf428e2c1..0228322f2ea 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -203,8 +203,7 @@ namespace std
return traits_type::to_int_type(*this->gptr());
// Get and convert input sequence.
- const size_t __buflen = _M_buf_size > 1
- ? _M_buf_size - 1 : 1;
+ const size_t __buflen = _M_buf_size > 1 ? _M_buf_size - 1 : 1;
// Will be set to true if ::read() returns 0 indicating EOF.
bool __got_eof = false;
diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h
index 66215b2f730..52c416f85b9 100644
--- a/libstdc++-v3/include/std/std_sstream.h
+++ b/libstdc++-v3/include/std/std_sstream.h
@@ -1,6 +1,6 @@
// String based streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004
+// Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004, 2005
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -127,16 +127,18 @@ namespace std
__string_type
str() const
{
+ __string_type __ret;
if (this->pptr())
{
// The current egptr() may not be the actual string end.
if (this->pptr() > this->egptr())
- return __string_type(this->pbase(), this->pptr());
+ __ret = __string_type(this->pbase(), this->pptr());
else
- return __string_type(this->pbase(), this->egptr());
+ __ret = __string_type(this->pbase(), this->egptr());
}
else
- return _M_string;
+ __ret = _M_string;
+ return __ret;
}
/**
@@ -151,7 +153,7 @@ namespace std
{
// Cannot use _M_string = __s, since v3 strings are COW.
_M_string.assign(__s.data(), __s.size());
- _M_stringbuf_init(this->_M_mode);
+ _M_stringbuf_init(_M_mode);
}
protected:
@@ -159,14 +161,25 @@ namespace std
void
_M_stringbuf_init(ios_base::openmode __mode)
{
- this->_M_mode = __mode;
-
+ _M_mode = __mode;
__size_type __len = 0;
- if (this->_M_mode & (ios_base::ate | ios_base::app))
+ if (_M_mode & (ios_base::ate | ios_base::app))
__len = _M_string.size();
_M_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
}
+ virtual streamsize
+ showmanyc()
+ {
+ streamsize __ret = -1;
+ if (_M_mode & ios_base::in)
+ {
+ _M_update_egptr();
+ __ret = this->egptr() - this->gptr();
+ }
+ return __ret;
+ }
+
virtual int_type
underflow();
@@ -223,8 +236,8 @@ namespace std
void
_M_sync(char_type* __base, __size_type __i, __size_type __o)
{
- const bool __testin = this->_M_mode & ios_base::in;
- const bool __testout = this->_M_mode & ios_base::out;
+ const bool __testin = _M_mode & ios_base::in;
+ const bool __testout = _M_mode & ios_base::out;
char_type* __end = __base + _M_string.size();
if (__testin)
@@ -252,8 +265,7 @@ namespace std
void
_M_update_egptr()
{
- const bool __testin = this->_M_mode & ios_base::in;
-
+ const bool __testin = _M_mode & ios_base::in;
if (this->pptr() && this->pptr() > this->egptr())
if (__testin)
this->setg(this->eback(), this->gptr(), this->pptr());