sstream.tcc (pbackfail): Remove redundant NULL pointer check from test involving _M_in_*.

2003-04-20  Paolo Carlini  <pcarlini@unitus.it>

	* include/bits/sstream.tcc (pbackfail): Remove redundant
	NULL pointer check from test involving _M_in_*.
	(overflow, seekoff, seekpos): Const qualify bool variables.
	* include/std/std_sstream.h (underflow): Remove redundant
	NULL pointer check from test involving _M_in_*.
	(_M_really_sync): Const qualify bool variables.
	* src/fstream.cc (_M_underflow_common): Remove redundant
	NULL pointer check from test involving _M_in_*, const qualify
	bool variables.

	* include/std/std_streambuf.h (sgetc): Remove redundant
	variable.

From-SVN: r65853
This commit is contained in:
Paolo Carlini 2003-04-20 15:54:45 +02:00 committed by Paolo Carlini
parent 1052bb09b8
commit 5e77a35767
5 changed files with 42 additions and 27 deletions

View File

@ -1,3 +1,18 @@
2003-04-20 Paolo Carlini <pcarlini@unitus.it>
* include/bits/sstream.tcc (pbackfail): Remove redundant
NULL pointer check from test involving _M_in_*.
(overflow, seekoff, seekpos): Const qualify bool variables.
* include/std/std_sstream.h (underflow): Remove redundant
NULL pointer check from test involving _M_in_*.
(_M_really_sync): Const qualify bool variables.
* src/fstream.cc (_M_underflow_common): Remove redundant
NULL pointer check from test involving _M_in_*, const qualify
bool variables.
* include/std/std_streambuf.h (sgetc): Remove redundant
variable.
2003-04-18 Paolo Carlini <pcarlini@unitus.it>
According to 5.9 para 2 (second bullet) for pointers p, q

View File

@ -47,8 +47,9 @@ namespace std
pbackfail(int_type __c)
{
int_type __ret = traits_type::eof();
bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
bool __testpos = this->_M_in_cur && this->_M_in_beg < this->_M_in_cur;
const bool __testeof =
traits_type::eq_int_type(__c, traits_type::eof());
const bool __testpos = this->_M_in_beg < this->_M_in_cur;
// Try to put back __c into input sequence in one of three ways.
// Order these tests done in is unspecified by the standard.
@ -80,11 +81,12 @@ namespace std
basic_stringbuf<_CharT, _Traits, _Alloc>::
overflow(int_type __c)
{
bool __testout = this->_M_mode & ios_base::out;
const bool __testout = this->_M_mode & ios_base::out;
if (__builtin_expect(!__testout, false))
return traits_type::eof();
bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
const bool __testeof =
traits_type::eq_int_type(__c, traits_type::eof());
if (__builtin_expect(__testeof, false))
return traits_type::not_eof(__c);
@ -94,7 +96,7 @@ namespace std
// suit particular needs.
__size_type __len = std::max(__size_type(_M_string.capacity() + 1),
__size_type(512));
bool __testput = this->_M_out_cur < this->_M_out_end;
const bool __testput = this->_M_out_cur < this->_M_out_end;
if (__builtin_expect(!__testput && __len > _M_string.max_size(), false))
return traits_type::eof();
@ -123,7 +125,7 @@ namespace std
pos_type __ret = pos_type(off_type(-1));
bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
bool __testboth = __testin && __testout && __way != ios_base::cur;
const bool __testboth = __testin && __testout && __way != ios_base::cur;
__testin &= !(__mode & ios_base::out);
__testout &= !(__mode & ios_base::in);
@ -189,8 +191,8 @@ namespace std
off_type __pos = __sp; // Use streamoff operator to do conversion.
char_type* __beg = NULL;
char_type* __end = NULL;
bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
// NB: Ordered.
bool __testposi = false;

View File

@ -190,7 +190,7 @@ namespace std
virtual int_type
underflow()
{
if (this->_M_in_cur && this->_M_in_cur < this->_M_in_end)
if (this->_M_in_cur < this->_M_in_end)
return traits_type::to_int_type(*gptr());
else
return traits_type::eof();
@ -260,8 +260,8 @@ namespace std
virtual void
_M_really_sync(char_type* __base, __size_type __i, __size_type __o)
{
bool __testin = this->_M_mode & ios_base::in;
bool __testout = this->_M_mode & ios_base::out;
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
__size_type __len = _M_string.size();
this->_M_buf = __base;

View File

@ -452,12 +452,10 @@ namespace std
int_type
sgetc()
{
int_type __ret;
if (_M_in_cur < _M_in_end)
__ret = traits_type::to_int_type(*(this->gptr()));
return traits_type::to_int_type(*(this->gptr()));
else
__ret = this->underflow();
return __ret;
return this->underflow();
}
/**

View File

@ -41,10 +41,10 @@ namespace std
basic_filebuf<char>::_M_underflow_common(bool __bump)
{
int_type __ret = traits_type::eof();
bool __testin = _M_mode & ios_base::in;
bool __testout = _M_mode & ios_base::out;
const bool __testin = _M_mode & ios_base::in;
const bool __testout = _M_mode & ios_base::out;
// Sync with stdio.
bool __sync = _M_buf_size <= 1;
const bool __sync = _M_buf_size <= 1;
if (__testin)
{
@ -54,7 +54,7 @@ namespace std
if (_M_pback_init)
_M_pback_destroy();
if (_M_in_cur && _M_in_cur < _M_in_end)
if (_M_in_cur < _M_in_end)
{
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
@ -64,8 +64,8 @@ namespace std
// Sync internal and external buffers.
// NB: __testget -> __testput as _M_buf_unified here.
bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
bool __testinit = _M_is_indeterminate();
const bool __testget = _M_in_beg < _M_in_cur;
const bool __testinit = _M_is_indeterminate();
if (__testget)
{
if (__testout)
@ -123,10 +123,10 @@ namespace std
basic_filebuf<wchar_t>::_M_underflow_common(bool __bump)
{
int_type __ret = traits_type::eof();
bool __testin = _M_mode & ios_base::in;
bool __testout = _M_mode & ios_base::out;
const bool __testin = _M_mode & ios_base::in;
const bool __testout = _M_mode & ios_base::out;
// Sync with stdio.
bool __sync = _M_buf_size <= 1;
const bool __sync = _M_buf_size <= 1;
if (__testin)
{
@ -136,7 +136,7 @@ namespace std
if (_M_pback_init)
_M_pback_destroy();
if (_M_in_cur && _M_in_cur < _M_in_end)
if (_M_in_cur < _M_in_end)
{
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
@ -146,8 +146,8 @@ namespace std
// Sync internal and external buffers.
// NB: __testget -> __testput as _M_buf_unified here.
bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
bool __testinit = _M_is_indeterminate();
const bool __testget = _M_in_beg < _M_in_cur;
const bool __testinit = _M_is_indeterminate();
if (__testget)
{
if (__testout)