aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2002-05-01 22:40:27 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2002-05-01 22:40:27 +0000
commit9875ea057d92d0efcc232b6e1595d7c4c48974e4 (patch)
tree5ebb7ea39bad25a2ff6d4899a81d2f287c857171
parentea619b46b171183a410173ae69eaa7d7c6cf07eb (diff)
downloadgcc-9875ea057d92d0efcc232b6e1595d7c4c48974e4.zip
gcc-9875ea057d92d0efcc232b6e1595d7c4c48974e4.tar.gz
gcc-9875ea057d92d0efcc232b6e1595d7c4c48974e4.tar.bz2
re PR libstdc++/6533 (libstdc++ broken on unsigned char platforms)
2002-05-01 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/6533 * include/bits/streambuf_iterator.h (istreambuf_iterator::_M_get): New. (istreambuf_iterator::equal): Use it. (istreambuf_iterator::operator*): Use it. From-SVN: r53024
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/streambuf_iterator.h38
2 files changed, 27 insertions, 18 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ab09780..7eba269 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2002-05-01 Benjamin Kosnik <bkoz@redhat.com>
+
+ PR libstdc++/6533
+ * include/bits/streambuf_iterator.h (istreambuf_iterator::_M_get): New.
+ (istreambuf_iterator::equal): Use it.
+ (istreambuf_iterator::operator*): Use it.
+
2002-05-01 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/6513
diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h b/libstdc++-v3/include/bits/streambuf_iterator.h
index f7317b2..659caec 100644
--- a/libstdc++-v3/include/bits/streambuf_iterator.h
+++ b/libstdc++-v3/include/bits/streambuf_iterator.h
@@ -77,24 +77,10 @@ namespace std
istreambuf_iterator(streambuf_type* __s) throw()
: _M_sbuf(__s), _M_c(-2) { }
- // NB: This should really have an int_type return
- // value, so "end of stream" postion can be checked without
- // hacking.
+ // NB: The result of operator*() on an end of stream is undefined.
char_type
operator*() const
- {
- // The result of operator*() on an end of stream is undefined.
- int_type __ret = traits_type::eof();
- if (_M_sbuf)
- {
- if (_M_c != static_cast<int_type>(-2))
- __ret = _M_c;
- else
- if ((__ret = _M_sbuf->sgetc()) == traits_type::eof())
- _M_sbuf = 0;
- }
- return traits_type::to_char_type(__ret);
- }
+ { return traits_type::to_char_type(_M_get()); }
istreambuf_iterator&
operator++()
@@ -124,11 +110,27 @@ namespace std
equal(const istreambuf_iterator& __b) const
{
const int_type __eof = traits_type::eof();
- bool __thiseof = traits_type::eq_int_type(this->operator*(), __eof);
- bool __beof = traits_type::eq_int_type(__b.operator*(), __eof);
+ bool __thiseof = _M_get() == __eof;
+ bool __beof = __b._M_get() == __eof;
return (__thiseof && __beof || (!__thiseof && !__beof));
}
#endif
+
+ private:
+ int_type
+ _M_get() const
+ {
+ int_type __ret = traits_type::eof();
+ if (_M_sbuf)
+ {
+ if (_M_c != static_cast<int_type>(-2))
+ __ret = _M_c;
+ else
+ if ((__ret = _M_sbuf->sgetc()) == traits_type::eof())
+ _M_sbuf = 0;
+ }
+ return __ret;
+ }
};
template<typename _CharT, typename _Traits>