OSDN Git Service

2003-04-18 Paolo Carlini <pcarlini@unitus.it>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Apr 2003 13:55:22 +0000 (13:55 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Apr 2003 13:55:22 +0000 (13:55 +0000)
According to 5.9 para 2 (second bullet) for pointers p, q
pointing to the same type, with  p == 0 and q == 0, (p < q)
is false.
* include/bits/fstream.tcc (close, overflow, _M_really_overflow,
seekoff): Remove redundant NULL pointer checks from tests
involving _M_out_* and _M_in_*, const qualify bool variables.
(showmanyc, pbackfail, _M_convert_to_external, imbue): Const
qualify bool variables.
* include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc):
Remove redundant NULL pointer checks from tests involving
_M_out_* and _M_in_*, const qualify bool variables.
* include/std/std_fstream.h (sync): Likewise.
(_M_is_indeterminate): Const qualify bool variables.
* include/std/std_streambuf.h (sgetc, uflow): Remove redundant
NULL pointer checks from tests involving _M_out_* and _M_in_*,
const qualify bool variables.
(_M_in_cur_move, _M_out_cur_move, uflow): Const qualify bool
variables.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65783 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/streambuf.tcc
libstdc++-v3/include/std/std_fstream.h
libstdc++-v3/include/std/std_streambuf.h

index 8cba854..0837473 100644 (file)
@@ -1,3 +1,24 @@
+2003-04-18  Paolo Carlini  <pcarlini@unitus.it>
+
+       According to 5.9 para 2 (second bullet) for pointers p, q
+       pointing to the same type, with  p == 0 and q == 0, (p < q)
+       is false.
+       * include/bits/fstream.tcc (close, overflow, _M_really_overflow,
+       seekoff): Remove redundant NULL pointer checks from tests
+       involving _M_out_* and _M_in_*, const qualify bool variables.
+       (showmanyc, pbackfail, _M_convert_to_external, imbue): Const
+       qualify bool variables.
+       * include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc, sputc):
+       Remove redundant NULL pointer checks from tests involving
+       _M_out_* and _M_in_*, const qualify bool variables.
+       * include/std/std_fstream.h (sync): Likewise.
+       (_M_is_indeterminate): Const qualify bool variables.
+       * include/std/std_streambuf.h (sgetc, uflow): Remove redundant
+       NULL pointer checks from tests involving _M_out_* and _M_in_*,
+       const qualify bool variables.
+       (_M_in_cur_move, _M_out_cur_move, uflow): Const qualify bool
+       variables.
+
 2003-04-18  Loren J. Rittle  <ljrittle@acm.org>
 
        * include/c_std/std_cmath.h (C99 FP capture): Only undefine said
index de74de6..a3dacca 100644 (file)
@@ -116,8 +116,8 @@ namespace std
        {
          bool __testfail = false;
          const int_type __eof = traits_type::eof();
-         bool __testput = this->_M_out_cur
-                          && this->_M_out_beg < this->_M_out_lim;
+         const bool __testput = this->_M_out_beg < this->_M_out_lim;
+
          if (__testput 
              && traits_type::eq_int_type(_M_really_overflow(__eof), __eof))
            __testfail = true;
@@ -152,11 +152,11 @@ namespace std
     showmanyc()
     {
       streamsize __ret = -1;
-      bool __testin = this->_M_mode & ios_base::in;
+      const bool __testin = this->_M_mode & ios_base::in;
       const locale __loc = this->getloc();
       const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc);
       // Sync with stdio.
-      bool __sync = this->_M_buf_size <= 1;
+      const bool __sync = this->_M_buf_size <= 1;
 
       if (__testin && this->is_open())
        {
@@ -178,18 +178,18 @@ namespace std
     pbackfail(int_type __i)
     {
       int_type __ret = traits_type::eof();
-      bool __testin = this->_M_mode & ios_base::in;
+      const bool __testin = this->_M_mode & ios_base::in;
 
       if (__testin)
        {
-         bool __testpb = this->_M_in_beg < this->_M_in_cur;
+         const bool __testpb = this->_M_in_beg < this->_M_in_cur;
          char_type __c = traits_type::to_char_type(__i);
-         bool __testeof = traits_type::eq_int_type(__i, __ret);
+         const bool __testeof = traits_type::eq_int_type(__i, __ret);
 
          if (__testpb)
            {
-             bool __testout = this->_M_mode & ios_base::out;
-             bool __testeq = traits_type::eq(__c, this->gptr()[-1]);
+             const bool __testout = this->_M_mode & ios_base::out;
+             const bool __testeq = traits_type::eq(__c, this->gptr()[-1]);
 
              // Try to put back __c into input sequence in one of three ways.
              // Order these tests done in is unspecified by the standard.
@@ -251,9 +251,8 @@ namespace std
     overflow(int_type __c)
     {
       int_type __ret = traits_type::eof();
-      bool __testput =
-       this->_M_out_cur && this->_M_out_cur < this->_M_out_end;
-      bool __testout = this->_M_mode & ios_base::out;
+      const bool __testput = this->_M_out_cur < this->_M_out_end;
+      const bool __testout = this->_M_mode & ios_base::out;
       
       if (__testout)
        {
@@ -282,7 +281,7 @@ namespace std
       const locale __loc = this->getloc();
       const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc);
       // Sync with stdio.
-      bool __sync = this->_M_buf_size <= 1;
+      const bool __sync = this->_M_buf_size <= 1;
 
       if (__cvt.always_noconv() && __ilen)
        {
@@ -352,10 +351,10 @@ namespace std
     _M_really_overflow(int_type __c)
     {
       int_type __ret = traits_type::eof();
-      bool __testput = this->_M_out_cur && this->_M_out_beg < this->_M_out_lim;
-      bool __testunbuffered = _M_file.is_open() && !this->_M_buf_size;
+      const bool __testput = this->_M_out_beg < this->_M_out_lim;
+      const bool __testunbuffered = _M_file.is_open() && !this->_M_buf_size;
       // Sync with stdio.
-      bool __sync = this->_M_buf_size <= 1;
+      const bool __sync = this->_M_buf_size <= 1;
 
       if (__testput || __testunbuffered)
        {
@@ -440,16 +439,16 @@ namespace std
     seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
     {
       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;
+      const bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
+      const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
       // Sync with stdio.
-      bool __sync = this->_M_buf_size <= 1;
+      const bool __sync = this->_M_buf_size <= 1;
       
       // Should probably do has_facet checks here.
       int __width = use_facet<__codecvt_type>(this->_M_buf_locale).encoding();
       if (__width < 0)
        __width = 0;
-      bool __testfail = __off != 0 && __width <= 0;
+      const bool __testfail = __off != 0 && __width <= 0;
       
       if (this->is_open() && !__testfail && (__testin || __testout)) 
        {
@@ -460,10 +459,8 @@ namespace std
            { 
              off_type __computed_off = __width * __off;
              
-             bool __testget = this->_M_in_cur
-               && this->_M_in_beg < this->_M_in_end;
-             bool __testput = this->_M_out_cur
-               && this->_M_out_beg < this->_M_out_lim;
+             const bool __testget = this->_M_in_beg < this->_M_in_end;
+             const bool __testput = this->_M_out_beg < this->_M_out_lim;
              // Sync the internal and external streams.
              // out
              if (__testput || _M_last_overflowed)
@@ -523,7 +520,7 @@ namespace std
     basic_filebuf<_CharT, _Traits>::
     imbue(const locale& __loc)
     {
-      bool __testbeg = gptr() == eback() && pptr() == pbase();
+      const bool __testbeg = gptr() == eback() && pptr() == pbase();
 
       if (__testbeg && this->_M_buf_locale != __loc)
        this->_M_buf_locale = __loc;
index 75ef518..09dd14c 100644 (file)
@@ -49,7 +49,7 @@ namespace std
     sbumpc()
     {
       int_type __ret;
-      if (_M_in_cur && _M_in_cur < _M_in_end)
+      if (_M_in_cur < _M_in_end)
        {
          char_type __c = *(this->gptr());
          _M_in_cur_move(1);
@@ -66,7 +66,7 @@ namespace std
     sputbackc(char_type __c) 
     {
       int_type __ret;
-      bool __testpos = _M_in_cur && _M_in_beg < _M_in_cur;
+      const bool __testpos = _M_in_beg < _M_in_cur;
       if (!__testpos || !traits_type::eq(__c, this->gptr()[-1]))
        __ret = this->pbackfail(traits_type::to_int_type(__c));
       else 
@@ -83,7 +83,7 @@ namespace std
     sungetc()
     {
       int_type __ret;
-      if (_M_in_cur && _M_in_beg < _M_in_cur)
+      if (_M_in_beg < _M_in_cur)
        {
          _M_in_cur_move(-1);
          __ret = traits_type::to_int_type(*_M_in_cur);
@@ -99,7 +99,7 @@ namespace std
     sputc(char_type __c)
     {
       int_type __ret;
-      if (_M_out_cur && _M_out_cur < _M_out_end)
+      if (_M_out_cur < _M_out_end)
        {
          *_M_out_cur = __c;
          _M_out_cur_move(1);
index 53d28ac..c341aaa 100644 (file)
@@ -312,10 +312,9 @@ namespace std
       sync()
       {
        int __ret = 0;
-       bool __testput = this->_M_out_cur
-         && this->_M_out_beg < this->_M_out_lim;
+       const bool __testput = this->_M_out_beg < this->_M_out_lim;
        // Sync with stdio.
-       bool __sync = this->_M_buf_size <= 1;
+       const bool __sync = this->_M_buf_size <= 1;
 
        // Make sure that the internal buffer resyncs its idea of
        // the file position with the external file.
@@ -404,8 +403,8 @@ namespace std
       void
       _M_set_determinate(off_type __off)
       {
-       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;
        if (__testin)
          this->setg(this->_M_buf, this->_M_buf, this->_M_buf + __off);
        if (__testout)
@@ -424,8 +423,8 @@ namespace std
       bool
       _M_is_indeterminate(void)
       { 
-       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;
        bool __ret = false;
        // Don't return true if unbuffered.
        if (this->_M_buf)
index a487102..b180c87 100644 (file)
@@ -303,7 +303,7 @@ namespace std
       void 
       _M_in_cur_move(off_type __n) // argument needs to be +-
       {
-       bool __testout = _M_out_cur;
+       const bool __testout = _M_out_cur;
        _M_in_cur += __n;
        if (__testout && _M_buf_unified)
          _M_out_cur += __n;
@@ -320,7 +320,7 @@ namespace std
       void 
       _M_out_cur_move(off_type __n) // argument needs to be +-
       {
-       bool __testin = _M_in_cur;
+       const bool __testin = _M_in_cur;
 
        _M_out_cur += __n;
        if (__testin && _M_buf_unified)
@@ -453,7 +453,7 @@ namespace std
       sgetc()
       {
        int_type __ret;
-       if (_M_in_cur && _M_in_cur < _M_in_end)
+       if (_M_in_cur < _M_in_end)
          __ret = traits_type::to_int_type(*(this->gptr()));
        else 
          __ret = this->underflow();
@@ -787,8 +787,9 @@ namespace std
       uflow() 
       {
        int_type __ret = traits_type::eof();
-       bool __testeof = traits_type::eq_int_type(this->underflow(), __ret);
-       bool __testpending = _M_in_cur && _M_in_cur < _M_in_end;
+       const bool __testeof =
+         traits_type::eq_int_type(this->underflow(), __ret);
+       const bool __testpending = _M_in_cur < _M_in_end;
        if (!__testeof && __testpending)
          {
            __ret = traits_type::to_int_type(*_M_in_cur);