1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_istreambuf_iterator.h Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_istreambuf_iterator.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -2,19 +2,19 @@
1.4 * Copyright (c) 1999
1.5 * Silicon Graphics Computer Systems, Inc.
1.6 *
1.7 - * Copyright (c) 1999
1.8 + * Copyright (c) 1999
1.9 * Boris Fomitchev
1.10 *
1.11 * This material is provided "as is", with absolutely no warranty expressed
1.12 * or implied. Any use is at your own risk.
1.13 *
1.14 - * Permission to use or copy this software for any purpose is hereby granted
1.15 + * Permission to use or copy this software for any purpose is hereby granted
1.16 * without fee, provided the above notices are retained on all copies.
1.17 * Permission to modify the code and to distribute modified code is granted,
1.18 * provided the above notices are retained, and a notice that the code was
1.19 * modified is included with the above copyright notice.
1.20 *
1.21 - */
1.22 + */
1.23 // WARNING: This is an internal header file, included by other C++
1.24 // standard library headers. You should not attempt to use this header
1.25 // file directly.
1.26 @@ -37,12 +37,13 @@
1.27 template <class _CharT, class _Traits>
1.28 extern basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& ) ;
1.29
1.30 -// We do not read any characters until operator* is called. operator* calls sgetc
1.31 +// We do not read any characters until operator* is called. operator* calls sgetc
1.32 // unless the iterator is unchanged from the last call in which case a cached value is
1.33 // used. Calls to operator++ use sbumpc.
1.34
1.35 template<class _CharT, class _Traits>
1.36 -class istreambuf_iterator
1.37 +class istreambuf_iterator :
1.38 + public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT&>
1.39 {
1.40 public:
1.41 typedef _CharT char_type;
1.42 @@ -63,22 +64,26 @@
1.43 inline istreambuf_iterator(basic_istream<_CharT, _Traits>& __is);
1.44
1.45 char_type operator*() const { this->_M_getc(); return _M_c; }
1.46 - istreambuf_iterator<_CharT, _Traits>& operator++() { this->_M_bumpc(); return *this; }
1.47 + istreambuf_iterator<_CharT, _Traits>& operator++()
1.48 + {
1.49 + _M_buf->sbumpc();
1.50 + _M_have_c = false;
1.51 + return *this;
1.52 + }
1.53 istreambuf_iterator<_CharT, _Traits> operator++(int);
1.54
1.55 bool equal(const istreambuf_iterator<_CharT, _Traits>& __i) const {
1.56 if (this->_M_buf)
1.57 this->_M_getc();
1.58 if (__i._M_buf)
1.59 - __i._M_getc();
1.60 + __i._M_getc();
1.61 return this->_M_eof == __i._M_eof;
1.62 }
1.63
1.64 private:
1.65 void _M_init(streambuf_type* __p) {
1.66 _M_buf = __p;
1.67 - _M_eof = !__p;
1.68 - // _M_is_initialized = _M_eof;
1.69 + _M_eof = (__p == 0);
1.70 _M_have_c = false;
1.71 }
1.72
1.73 @@ -99,21 +104,15 @@
1.74 # endif
1.75 }
1.76
1.77 - int_type _M_bumpc() {
1.78 - int_type ch = _M_buf->sbumpc();
1.79 - _M_have_c = false;
1.80 - return ch;
1.81 - }
1.82 -
1.83 private:
1.84 streambuf_type* _M_buf;
1.85 mutable _CharT _M_c;
1.86 - mutable unsigned char _M_eof;
1.87 - mutable unsigned char _M_have_c;
1.88 + mutable bool _M_eof;
1.89 + mutable bool _M_have_c;
1.90 };
1.91
1.92 template<class _CharT, class _Traits>
1.93 -inline istreambuf_iterator<_CharT, _Traits>::istreambuf_iterator(basic_istream<_CharT, _Traits>& __is)
1.94 +inline istreambuf_iterator<_CharT, _Traits>::istreambuf_iterator(basic_istream<_CharT, _Traits>& __is)
1.95 { this->_M_init(_M_get_istreambuf(__is)); }
1.96
1.97 template<class _CharT, class _Traits>
1.98 @@ -143,7 +142,7 @@
1.99 template <class _CharT, class _Traits>
1.100 inline input_iterator_tag _STLP_CALL iterator_category(const istreambuf_iterator<_CharT, _Traits>&) { return input_iterator_tag(); }
1.101 template <class _CharT, class _Traits>
1.102 -inline streamoff* _STLP_CALL
1.103 +inline streamoff* _STLP_CALL
1.104 distance_type(const istreambuf_iterator<_CharT, _Traits>&) { return (streamoff*)0; }
1.105 template <class _CharT, class _Traits>
1.106 inline _CharT* _STLP_CALL value_type(const istreambuf_iterator<_CharT, _Traits>&) { return (_CharT*)0; }
1.107 @@ -152,10 +151,12 @@
1.108 template <class _CharT, class _Traits>
1.109 istreambuf_iterator<_CharT, _Traits>
1.110 istreambuf_iterator<_CharT, _Traits>::operator++(int) {
1.111 + _M_getc(); // __tmp should avoid any future actions under
1.112 + // underlined buffer---during call of operator *()
1.113 + // (due to buffer for *this and __tmp are the same).
1.114 istreambuf_iterator<_CharT, _Traits> __tmp = *this;
1.115 - __tmp._M_c = this->_M_bumpc();
1.116 - __tmp._M_have_c = true;
1.117 - this->_M_have_c = false;
1.118 + _M_buf->sbumpc();
1.119 + _M_have_c = false;
1.120 return __tmp;
1.121 }
1.122