diff -r e1b950c65cb4 -r 837f303aceeb epoc32/include/stdapis/stlportv5/stl/_istreambuf_iterator.h --- a/epoc32/include/stdapis/stlportv5/stl/_istreambuf_iterator.h Wed Mar 31 12:27:01 2010 +0100 +++ b/epoc32/include/stdapis/stlportv5/stl/_istreambuf_iterator.h Wed Mar 31 12:33:34 2010 +0100 @@ -2,19 +2,19 @@ * Copyright (c) 1999 * Silicon Graphics Computer Systems, Inc. * - * Copyright (c) 1999 + * Copyright (c) 1999 * Boris Fomitchev * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * - * Permission to use or copy this software for any purpose is hereby granted + * Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * - */ + */ // WARNING: This is an internal header file, included by other C++ // standard library headers. You should not attempt to use this header // file directly. @@ -37,12 +37,13 @@ template extern basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& ) ; -// We do not read any characters until operator* is called. operator* calls sgetc +// We do not read any characters until operator* is called. operator* calls sgetc // unless the iterator is unchanged from the last call in which case a cached value is // used. Calls to operator++ use sbumpc. template -class istreambuf_iterator +class istreambuf_iterator : + public iterator { public: typedef _CharT char_type; @@ -63,22 +64,26 @@ inline istreambuf_iterator(basic_istream<_CharT, _Traits>& __is); char_type operator*() const { this->_M_getc(); return _M_c; } - istreambuf_iterator<_CharT, _Traits>& operator++() { this->_M_bumpc(); return *this; } + istreambuf_iterator<_CharT, _Traits>& operator++() + { + _M_buf->sbumpc(); + _M_have_c = false; + return *this; + } istreambuf_iterator<_CharT, _Traits> operator++(int); bool equal(const istreambuf_iterator<_CharT, _Traits>& __i) const { if (this->_M_buf) this->_M_getc(); if (__i._M_buf) - __i._M_getc(); + __i._M_getc(); return this->_M_eof == __i._M_eof; } private: void _M_init(streambuf_type* __p) { _M_buf = __p; - _M_eof = !__p; - // _M_is_initialized = _M_eof; + _M_eof = (__p == 0); _M_have_c = false; } @@ -99,21 +104,15 @@ # endif } - int_type _M_bumpc() { - int_type ch = _M_buf->sbumpc(); - _M_have_c = false; - return ch; - } - private: streambuf_type* _M_buf; mutable _CharT _M_c; - mutable unsigned char _M_eof; - mutable unsigned char _M_have_c; + mutable bool _M_eof; + mutable bool _M_have_c; }; template -inline istreambuf_iterator<_CharT, _Traits>::istreambuf_iterator(basic_istream<_CharT, _Traits>& __is) +inline istreambuf_iterator<_CharT, _Traits>::istreambuf_iterator(basic_istream<_CharT, _Traits>& __is) { this->_M_init(_M_get_istreambuf(__is)); } template @@ -143,7 +142,7 @@ template inline input_iterator_tag _STLP_CALL iterator_category(const istreambuf_iterator<_CharT, _Traits>&) { return input_iterator_tag(); } template -inline streamoff* _STLP_CALL +inline streamoff* _STLP_CALL distance_type(const istreambuf_iterator<_CharT, _Traits>&) { return (streamoff*)0; } template inline _CharT* _STLP_CALL value_type(const istreambuf_iterator<_CharT, _Traits>&) { return (_CharT*)0; } @@ -152,10 +151,12 @@ template istreambuf_iterator<_CharT, _Traits> istreambuf_iterator<_CharT, _Traits>::operator++(int) { + _M_getc(); // __tmp should avoid any future actions under + // underlined buffer---during call of operator *() + // (due to buffer for *this and __tmp are the same). istreambuf_iterator<_CharT, _Traits> __tmp = *this; - __tmp._M_c = this->_M_bumpc(); - __tmp._M_have_c = true; - this->_M_have_c = false; + _M_buf->sbumpc(); + _M_have_c = false; return __tmp; }