1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_istream.c Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_istream.c Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -1,5 +1,4 @@
1.4 /*
1.5 - * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.6 * Copyright (c) 1999
1.7 * Silicon Graphics Computer Systems, Inc.
1.8 *
1.9 @@ -19,36 +18,36 @@
1.10 #ifndef _STLP_ISTREAM_C
1.11 #define _STLP_ISTREAM_C
1.12
1.13 -#ifndef _STLP_INTERNAL_ISTREAM_H
1.14 -# include <stl/_istream.h>
1.15 +#ifndef _STLP_INTERNAL_ISTREAM
1.16 +# include <stl/_istream.h>
1.17 #endif
1.18
1.19 -# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
1.20 -
1.21 -#ifndef _STLP_LIMITS_H
1.22 -# include <stl/_limits.h>
1.23 +#ifndef _STLP_INTERNAL_LIMITS
1.24 +# include <stl/_limits.h>
1.25 #endif
1.26
1.27 #ifndef _STLP_INTERNAL_NUM_GET_H
1.28 -# include <stl/_num_get.h>
1.29 +# include <stl/_num_get.h>
1.30 #endif
1.31
1.32 -# if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
1.33 +#if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
1.34 // no wchar_t is supported for this mode
1.35 -# define __BIS_int_type__ int
1.36 -# define __BIS_pos_type__ streampos
1.37 -# define __BIS_off_type__ streamoff
1.38 -# else
1.39 -# define __BIS_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::int_type
1.40 -# define __BIS_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::pos_type
1.41 -# define __BIS_off_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::off_type
1.42 -# endif
1.43 +# define __BIS_int_type__ int
1.44 +# define __BIS_pos_type__ streampos
1.45 +# define __BIS_off_type__ streamoff
1.46 +#else
1.47 +# define __BIS_int_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::int_type
1.48 +# define __BIS_pos_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::pos_type
1.49 +# define __BIS_off_type__ _STLP_TYPENAME_ON_RETURN_TYPE basic_istream<_CharT, _Traits>::off_type
1.50 +#endif
1.51
1.52 _STLP_BEGIN_NAMESPACE
1.53
1.54 //----------------------------------------------------------------------
1.55 // Function object structs used by some member functions.
1.56
1.57 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.58 +
1.59 template <class _Traits>
1.60 struct _Is_not_wspace {
1.61 typedef typename _Traits::char_type argument_type;
1.62 @@ -126,8 +125,7 @@
1.63 };
1.64
1.65 template <class _Traits>
1.66 -struct _Scan_for_char_val
1.67 -{
1.68 +struct _Scan_for_char_val {
1.69 typedef typename _Traits::char_type char_type;
1.70 typedef char_type* first_argument_type;
1.71 typedef char_type* second_argument_type;
1.72 @@ -144,8 +142,7 @@
1.73 };
1.74
1.75 template <class _Traits>
1.76 -struct _Scan_for_int_val
1.77 -{
1.78 +struct _Scan_for_int_val {
1.79 typedef typename _Traits::char_type char_type;
1.80 typedef typename _Traits::int_type int_type;
1.81 typedef char_type* first_argument_type;
1.82 @@ -168,8 +165,7 @@
1.83
1.84 template <class _CharT, class _Traits>
1.85 bool _STLP_CALL
1.86 -__pushback(basic_streambuf<_CharT, _Traits>* __buf, _CharT __c)
1.87 -{
1.88 +__pushback(basic_streambuf<_CharT, _Traits>* __buf, _CharT __c) {
1.89 bool ret;
1.90 _STLP_TRY {
1.91 const typename _Traits::int_type __eof = _Traits::eof();
1.92 @@ -181,58 +177,13 @@
1.93 return ret;
1.94 }
1.95
1.96 -template <class _CharT, class _Traits>
1.97 -basic_istream<_CharT, _Traits>& _STLP_CALL
1.98 -ws(basic_istream<_CharT, _Traits>& __is)
1.99 -{
1.100 - typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
1.101 - _Sentry __sentry(__is, _No_Skip_WS()); // Don't skip whitespace.
1.102 - if (__sentry)
1.103 - __is._M_skip_whitespace(false);
1.104 - return __is;
1.105 -}
1.106 -
1.107 -// Helper functions for istream<>::sentry constructor.
1.108 -template <class _CharT, class _Traits>
1.109 -bool
1.110 -_M_init_skip(basic_istream<_CharT, _Traits>& __is) {
1.111 - if (__is.good()) {
1.112 - if (__is.tie())
1.113 - __is.tie()->flush();
1.114 -
1.115 - __is._M_skip_whitespace(true);
1.116 - }
1.117 -
1.118 - if (!__is.good()) {
1.119 - __is.setstate(ios_base::failbit);
1.120 - return false;
1.121 - } else
1.122 - return true;
1.123 -}
1.124 -
1.125 -template <class _CharT, class _Traits>
1.126 -bool
1.127 -_M_init_noskip(basic_istream<_CharT, _Traits>& __is){
1.128 - if (__is.good()) {
1.129 - if (__is.tie())
1.130 - __is.tie()->flush();
1.131 -
1.132 - if (!__is.rdbuf())
1.133 - __is.setstate(ios_base::badbit);
1.134 - }
1.135 - else
1.136 - __is.setstate(ios_base::failbit);
1.137 - return __is.good();
1.138 -}
1.139 -
1.140 //----------------------------------------------------------------------
1.141 // Definitions of basic_istream<>'s noninline member functions.
1.142
1.143 // Helper function for formatted input of numbers.
1.144 template <class _CharT, class _Traits, class _Number>
1.145 ios_base::iostate _STLP_CALL
1.146 -_M_get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val)
1.147 -{
1.148 +__get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val) {
1.149 typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
1.150 ios_base::iostate __err = 0;
1.151 _Sentry __sentry( __that ); // Skip whitespace.
1.152 @@ -240,7 +191,7 @@
1.153 typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > _Num_get;
1.154 _STLP_TRY {
1.155 ((const _Num_get&)use_facet<_Num_get>(__that.getloc())).get(istreambuf_iterator<_CharT, _Traits>(__that.rdbuf()),
1.156 - 0, __that, __err, __val);
1.157 + 0, __that, __err, __val);
1.158 }
1.159 _STLP_CATCH_ALL {
1.160 __that._M_handle_exception(ios_base::badbit);
1.161 @@ -250,13 +201,117 @@
1.162 return __err;
1.163 }
1.164
1.165 +_STLP_MOVE_TO_STD_NAMESPACE
1.166 +
1.167 +template <class _CharT, class _Traits>
1.168 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (short& __val) {
1.169 + long __lval;
1.170 + _STLP_PRIV __get_num(*this, __lval);
1.171 + if ( this->fail() ) {
1.172 + return *this;
1.173 + }
1.174 + short __tmp = __STATIC_CAST(short, __lval);
1.175 + unsigned short __uval = __STATIC_CAST(unsigned short, __lval);
1.176 + // check if we lose digits
1.177 + // if ((__val != __lval) && ((unsigned short)__val != __lval))
1.178 + if ((__tmp != __lval) && ((long)__uval != __lval))
1.179 + this->setstate(ios_base::failbit);
1.180 + else
1.181 + __val = __tmp;
1.182 + return *this;
1.183 +}
1.184 +
1.185 +template <class _CharT, class _Traits>
1.186 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (int& __val) {
1.187 + long __lval;
1.188 + _STLP_PRIV __get_num(*this, __lval);
1.189 + if ( this->fail() ) {
1.190 + return *this;
1.191 + }
1.192 + int __tmp = __lval;
1.193 + unsigned int __uval = __lval;
1.194 + // check if we lose digits
1.195 + // if ((__val != __lval) && ((unsigned int)__val != __lval))
1.196 + if ((__tmp != __lval) && ((long)__uval != __lval))
1.197 + this->setstate(ios_base::failbit);
1.198 + else
1.199 + __val = __tmp;
1.200 + return *this;
1.201 +}
1.202 +
1.203 +template <class _CharT, class _Traits>
1.204 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (unsigned short& __val) {
1.205 + _STLP_PRIV __get_num(*this, __val);
1.206 + return *this;
1.207 +}
1.208 +
1.209 +template <class _CharT, class _Traits>
1.210 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (unsigned int& __val) {
1.211 + _STLP_PRIV __get_num(*this, __val);
1.212 + return *this;
1.213 +}
1.214 +
1.215 +template <class _CharT, class _Traits>
1.216 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (long& __val) {
1.217 + _STLP_PRIV __get_num(*this, __val);
1.218 + return *this;
1.219 +}
1.220 +
1.221 +template <class _CharT, class _Traits>
1.222 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (unsigned long& __val) {
1.223 + _STLP_PRIV __get_num(*this, __val);
1.224 + return *this;
1.225 +}
1.226 +
1.227 +#if defined (_STLP_LONG_LONG)
1.228 +template <class _CharT, class _Traits>
1.229 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (_STLP_LONG_LONG& __val) {
1.230 + _STLP_PRIV __get_num(*this, __val);
1.231 + return *this;
1.232 +}
1.233 +
1.234 +template <class _CharT, class _Traits>
1.235 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (unsigned _STLP_LONG_LONG& __val) {
1.236 + _STLP_PRIV __get_num(*this, __val);
1.237 + return *this;
1.238 +}
1.239 +#endif
1.240 +template <class _CharT, class _Traits>
1.241 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (float& __val) {
1.242 + _STLP_PRIV __get_num(*this, __val);
1.243 + return *this;
1.244 +}
1.245 +template <class _CharT, class _Traits>
1.246 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (double& __val) {
1.247 + _STLP_PRIV __get_num(*this, __val);
1.248 + return *this;
1.249 +}
1.250 +#if !defined (_STLP_NO_LONG_DOUBLE)
1.251 +template <class _CharT, class _Traits>
1.252 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (long double& __val) {
1.253 + _STLP_PRIV __get_num(*this, __val);
1.254 + return *this;
1.255 +}
1.256 +#endif
1.257 +#if !defined (_STLP_NO_BOOL)
1.258 +template <class _CharT, class _Traits>
1.259 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (bool& __val) {
1.260 + _STLP_PRIV __get_num(*this, __val);
1.261 + return *this;
1.262 +}
1.263 +#endif
1.264 +
1.265 +template <class _CharT, class _Traits>
1.266 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>> (void*& __val) {
1.267 + _STLP_PRIV __get_num(*this, __val);
1.268 + return *this;
1.269 +}
1.270
1.271 // Unformatted input
1.272
1.273 template <class _CharT, class _Traits>
1.274 __BIS_int_type__
1.275 -basic_istream<_CharT, _Traits>::peek()
1.276 -{
1.277 +basic_istream<_CharT, _Traits>::peek() {
1.278 typename _Traits::int_type __tmp = _Traits::eof();
1.279
1.280 this->_M_gcount = 0;
1.281 @@ -269,23 +324,17 @@
1.282 _STLP_CATCH_ALL {
1.283 this->_M_handle_exception(ios_base::badbit);
1.284 }
1.285 + if (this->_S_eof(__tmp))
1.286 + this->setstate(ios_base::eofbit);
1.287 }
1.288 - else
1.289 - {
1.290 - if (this->_S_eof(__tmp))
1.291 - {
1.292 - this->clear();
1.293 - this->setstate(ios_base::eofbit);
1.294 - }
1.295 - }
1.296 +
1.297 return __tmp;
1.298 }
1.299
1.300
1.301 template <class _CharT, class _Traits>
1.302 __BIS_int_type__
1.303 -basic_istream<_CharT, _Traits>::get()
1.304 -{
1.305 +basic_istream<_CharT, _Traits>::get() {
1.306 typename _Traits::int_type __tmp = _Traits::eof();
1.307 sentry __sentry(*this, _No_Skip_WS());
1.308 this->_M_gcount = 0;
1.309 @@ -310,8 +359,7 @@
1.310
1.311 template <class _CharT, class _Traits>
1.312 basic_istream<_CharT, _Traits>&
1.313 -basic_istream<_CharT, _Traits>::get(_CharT& __c)
1.314 -{
1.315 +basic_istream<_CharT, _Traits>::get(_CharT& __c) {
1.316 sentry __sentry(*this, _No_Skip_WS());
1.317 this->_M_gcount = 0;
1.318
1.319 @@ -337,14 +385,12 @@
1.320 }
1.321
1.322
1.323 -
1.324 // Read characters and discard them. The standard specifies a single
1.325 // function with two arguments, each with a default. We instead use
1.326 // three overloded functions, because it's possible to implement the
1.327 // first two more efficiently than the fully general third version.
1.328 template <class _CharT, class _Traits>
1.329 -basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore()
1.330 -{
1.331 +basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore() {
1.332 sentry __sentry(*this, _No_Skip_WS());
1.333 this->_M_gcount = 0;
1.334
1.335 @@ -407,13 +453,7 @@
1.336 // if (!__buf || _Traits::eq_int_type(__buf->sungetc(), _Traits::eof()))
1.337 if (__buf) {
1.338 _STLP_TRY {
1.339 - _CharT __tmp;
1.340 - __tmp = __buf->sungetc();
1.341 -#ifdef __SYMBIAN32__
1.342 - if (__tmp == (_CharT)-1) //chek for eof
1.343 -#else
1.344 - if (this->_S_eof(__tmp))
1.345 -#endif
1.346 + if (this->_S_eof(__buf->sungetc()))
1.347 this->setstate(ios_base::badbit);
1.348 }
1.349 _STLP_CATCH_ALL {
1.350 @@ -450,9 +490,8 @@
1.351 template <class _CharT, class _Traits>
1.352 __BIS_pos_type__
1.353 basic_istream<_CharT, _Traits>::tellg() {
1.354 -#ifndef __SYMBIAN32__
1.355 sentry __sentry(*this, _No_Skip_WS());
1.356 -#endif
1.357 +
1.358 basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.359 return (__buf && !this->fail()) ? __buf->pubseekoff(0, ios_base::cur, ios_base::in)
1.360 : pos_type(-1);
1.361 @@ -461,48 +500,38 @@
1.362 template <class _CharT, class _Traits>
1.363 basic_istream<_CharT, _Traits>&
1.364 basic_istream<_CharT, _Traits>::seekg(pos_type __pos) {
1.365 -#ifndef __SYMBIAN32__
1.366 sentry __sentry(*this, _No_Skip_WS());
1.367 -#endif
1.368 +
1.369 basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.370 - if (!this->fail() && __buf)
1.371 - {
1.372 - pos_type pos = __buf->pubseekpos(__pos, ios_base::in);
1.373 - if(pos == pos_type(off_type(-1)))
1.374 - this->setstate(ios_base::failbit);
1.375 + if (!this->fail() && __buf) {
1.376 + if (__buf->pubseekpos(__pos) == pos_type(-1)) {
1.377 + this->setstate(ios_base::failbit);
1.378 + }
1.379 }
1.380 return *this;
1.381 }
1.382
1.383 template <class _CharT, class _Traits>
1.384 basic_istream<_CharT, _Traits>&
1.385 -basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
1.386 -{
1.387 -#ifndef __SYMBIAN32__
1.388 +basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) {
1.389 sentry __sentry(*this, _No_Skip_WS());
1.390 -#endif
1.391 +
1.392 basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.393 if (!this->fail() && __buf)
1.394 - {
1.395 -
1.396 - pos_type pos = __buf->pubseekoff(__off, __dir, ios_base::in);
1.397 - if(pos == pos_type(off_type(-1)))
1.398 - this->setstate(ios_base::failbit);
1.399 - }
1.400 + __buf->pubseekoff(__off, __dir);
1.401 return *this;
1.402 }
1.403
1.404 // Formatted input of characters and character arrays.
1.405
1.406 template <class _CharT, class _Traits>
1.407 -void basic_istream<_CharT, _Traits>::_M_formatted_get(_CharT& __c)
1.408 -{
1.409 +void basic_istream<_CharT, _Traits>::_M_formatted_get(_CharT& __c) {
1.410 // typename _Traits::int_type __tmp = _Traits::eof();
1.411
1.412 sentry __sentry(*this); // Skip whitespace.
1.413
1.414 if (__sentry) {
1.415 - typename _Traits::int_type __tmp = _Traits::eof();
1.416 + typename _Traits::int_type __tmp;// = _Traits::eof();
1.417
1.418 _STLP_TRY {
1.419 __tmp = this->rdbuf()->sbumpc();
1.420 @@ -541,87 +570,48 @@
1.421 // delimiter if it is extracted. Note that the number of characaters
1.422 // extracted isn't necessarily the same as the number stored.
1.423
1.424 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.425 +
1.426 template < class _CharT, class _Traits, class _Is_Delim>
1.427 streamsize _STLP_CALL
1.428 -_M_read_unbuffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __buf,
1.429 - streamsize _Num, _CharT* __s,
1.430 - _Is_Delim __is_delim,
1.431 - bool __extract_delim, bool __append_null,
1.432 - bool __is_getline)
1.433 -{
1.434 +__read_unbuffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __buf,
1.435 + streamsize _Num, _CharT* __s,
1.436 + _Is_Delim __is_delim,
1.437 + bool __extract_delim, bool __append_null,
1.438 + bool __is_getline) {
1.439 streamsize __n = 0;
1.440 ios_base::iostate __status = 0;
1.441
1.442 typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
1.443 // The operations that can potentially throw are sbumpc, snextc, and sgetc.
1.444 _STLP_TRY {
1.445 -# if 0
1.446 - int_type __c = __buf->sgetc();
1.447 - while (true) {
1.448 + for (;;) {
1.449 + int_type __c = __buf->sbumpc(); // sschwarz
1.450 +
1.451 if (__that->_S_eof(__c)) {
1.452 if (__n < _Num || __is_getline)
1.453 __status |= ios_base::eofbit;
1.454 break;
1.455 }
1.456 -
1.457 - else if (__is_delim(__c)) {
1.458 - if (__extract_delim) { // Extract and discard current character.
1.459 - __buf->sbumpc();
1.460 + else if (__is_delim(_Traits::to_char_type(__c))) {
1.461 + if (__extract_delim) { // Extract and discard current character.
1.462 ++__n;
1.463 + } else if ( !__pushback(__buf, _Traits::to_char_type(__c)) ) { // leave delimiter
1.464 + __status |= ios_base::failbit;
1.465 }
1.466 break;
1.467 }
1.468 + else { // regular character
1.469 + *__s++ = _Traits::to_char_type(__c);
1.470 + ++__n;
1.471 + }
1.472
1.473 - else if (__n == _Num) {
1.474 - if (__is_getline)
1.475 + if (__n == _Num) {
1.476 + if (__is_getline) // didn't find delimiter as one of the _Num chars
1.477 __status |= ios_base::failbit;
1.478 break;
1.479 }
1.480 -
1.481 - *__s++ = _Traits::to_char_type(__c);
1.482 - ++__n;
1.483 - __c = __buf->snextc();
1.484 }
1.485 -# else
1.486 -// int_type __c = __buf->sbumpc(); // __buf->sgetc();
1.487 -while (true) {
1.488 -
1.489 -int_type __c = __buf->sbumpc(); // sschwarz
1.490 -
1.491 -if (__that->_S_eof(__c)) {
1.492 -if (__n < _Num || __is_getline)
1.493 -__status |= ios_base::eofbit;
1.494 -break;
1.495 -}
1.496 -
1.497 -else if (__is_delim(__c)) {
1.498 -if (__extract_delim) { // Extract and discard current character.
1.499 -// __buf->sbumpc();
1.500 -++__n;
1.501 -}
1.502 -break;
1.503 -}
1.504 -
1.505 -else { // regular character
1.506 -
1.507 -*__s++ = _Traits::to_char_type(__c);
1.508 -++__n;
1.509 -
1.510 -}
1.511 -
1.512 -if (__n == _Num) {
1.513 -if (__is_getline) // didn't find delimiter as one of the _Num chars
1.514 -__status |= ios_base::failbit;
1.515 -break;
1.516 -}
1.517 -
1.518 -// *__s++ = _Traits::to_char_type(__c);
1.519 -// ++__n;
1.520 -
1.521 -}
1.522 -
1.523 -# endif
1.524 -
1.525 }
1.526 _STLP_CATCH_ALL {
1.527 __that->_M_handle_exception(ios_base::badbit);
1.528 @@ -636,18 +626,17 @@
1.529 return __n;
1.530 }
1.531
1.532 -// Much like _M_read_unbuffered, but with one additional function object:
1.533 +// Much like __read_unbuffered, but with one additional function object:
1.534 // __scan_delim(first, last) returns the first pointer p in [first, last)
1.535 // such that __is_delim(p) is true.
1.536
1.537 template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim>
1.538 streamsize _STLP_CALL
1.539 -_M_read_buffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __buf,
1.540 - streamsize _Num, _CharT* __s,
1.541 - _Is_Delim __is_delim, _Scan_Delim __scan_delim,
1.542 - bool __extract_delim, bool __append_null,
1.543 - bool __is_getline)
1.544 -{
1.545 +__read_buffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __buf,
1.546 + streamsize _Num, _CharT* __s,
1.547 + _Is_Delim __is_delim, _Scan_Delim __scan_delim,
1.548 + bool __extract_delim, bool __append_null,
1.549 + bool __is_getline) {
1.550 streamsize __n = 0;
1.551 ios_base::iostate __status = 0;
1.552 bool __done = false;
1.553 @@ -656,7 +645,11 @@
1.554 while (__buf->_M_egptr() != __buf->_M_gptr() && !__done) {
1.555 const _CharT* __first = __buf->_M_gptr();
1.556 const _CharT* __last = __buf->_M_egptr();
1.557 - ptrdiff_t __request = _Num - __n;
1.558 + //casting numeric_limits<ptrdiff_t>::max to streamsize only works is ptrdiff_t is signed or streamsize representation
1.559 + //is larger than ptrdiff_t one.
1.560 + _STLP_STATIC_ASSERT((sizeof(streamsize) > sizeof(ptrdiff_t)) ||
1.561 + (sizeof(streamsize) == sizeof(ptrdiff_t)) && numeric_limits<ptrdiff_t>::is_signed)
1.562 + ptrdiff_t __request = __STATIC_CAST(ptrdiff_t, (min) (__STATIC_CAST(streamsize, (numeric_limits<ptrdiff_t>::max)()), _Num - __n));
1.563
1.564 const _CharT* __p = __scan_delim(__first, __last);
1.565 ptrdiff_t __chunk = (min) (ptrdiff_t(__p - __first), __request);
1.566 @@ -675,7 +668,7 @@
1.567 }
1.568
1.569 // We terminated by reading all the characters we were asked for.
1.570 - else if(__n == _Num) {
1.571 + else if (__n == _Num) {
1.572
1.573 // Find out if we have reached eof. This matters for getline.
1.574 if (__is_getline) {
1.575 @@ -692,7 +685,7 @@
1.576 // The buffer contained fewer than _Num - __n characters. Either we're
1.577 // at eof, or we should refill the buffer and try again.
1.578 else {
1.579 - if (__that->_S_eof(__buf->sgetc())) {
1.580 + if (__that->_S_eof(__buf->sgetc())) {
1.581 __status |= ios_base::eofbit;
1.582 __done = true;
1.583 }
1.584 @@ -715,14 +708,13 @@
1.585 // If execution has reached this point, then we have an empty buffer but
1.586 // we have not reached eof. What that means is that the streambuf has
1.587 // decided to switch from buffered to unbuffered input. We switch to
1.588 - // to _M_read_unbuffered.
1.589 + // to __read_unbuffered.
1.590
1.591 - return __n + _M_read_unbuffered(__that, __buf, _Num - __n, __s, __is_delim,
1.592 - __extract_delim,__append_null,__is_getline);
1.593 + return __n + __read_unbuffered(__that, __buf, _Num - __n, __s, __is_delim,
1.594 + __extract_delim,__append_null,__is_getline);
1.595 }
1.596
1.597 -
1.598 -
1.599 +_STLP_MOVE_TO_STD_NAMESPACE
1.600
1.601 template <class _CharT, class _Traits>
1.602 basic_istream<_CharT, _Traits>&
1.603 @@ -737,20 +729,18 @@
1.604
1.605 if (__buf->egptr() != __buf->gptr())
1.606 this->_M_gcount =
1.607 - _M_read_buffered(this, __buf, __n - 1, __s,
1.608 - _Eq_char_bound<_Traits>(__delim),
1.609 - _Scan_for_char_val<_Traits>(__delim),
1.610 - false, true, false);
1.611 + _STLP_PRIV __read_buffered(this, __buf, __n - 1, __s,
1.612 + _STLP_PRIV _Eq_char_bound<_Traits>(__delim),
1.613 + _STLP_PRIV _Scan_for_char_val<_Traits>(__delim),
1.614 + false, true, false);
1.615 else
1.616 this->_M_gcount =
1.617 - _M_read_unbuffered(this, __buf, __n - 1, __s,
1.618 - _Eq_char_bound<_Traits>(__delim),
1.619 - false, true, false);
1.620 + _STLP_PRIV __read_unbuffered(this, __buf, __n - 1, __s,
1.621 + _STLP_PRIV _Eq_char_bound<_Traits>(__delim),
1.622 + false, true, false);
1.623 }
1.624 }
1.625 -#ifdef __SYMBIAN32__
1.626 - *(__s + this->_M_gcount) = _STLP_DEFAULT_CONSTRUCTED(_CharT);
1.627 -#endif //__SYMBIAN32__
1.628 +
1.629 if (this->_M_gcount == 0)
1.630 this->setstate(ios_base::failbit);
1.631
1.632 @@ -770,13 +760,13 @@
1.633 if (__n > 0) {
1.634 basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.635 this->_M_gcount = __buf->egptr() != __buf->gptr()
1.636 - ? _M_read_buffered(this, __buf, __n - 1, __s,
1.637 - _Eq_char_bound<_Traits>(__delim),
1.638 - _Scan_for_char_val<_Traits>(__delim),
1.639 - true, true, true)
1.640 - : _M_read_unbuffered(this, __buf, __n - 1, __s,
1.641 - _Eq_char_bound<_Traits>(__delim),
1.642 - true, true, true);
1.643 + ? _STLP_PRIV __read_buffered(this, __buf, __n - 1, __s,
1.644 + _STLP_PRIV _Eq_char_bound<_Traits>(__delim),
1.645 + _STLP_PRIV _Scan_for_char_val<_Traits>(__delim),
1.646 + true, true, true)
1.647 + : _STLP_PRIV __read_unbuffered(this, __buf, __n - 1, __s,
1.648 + _STLP_PRIV _Eq_char_bound<_Traits>(__delim),
1.649 + true, true, true);
1.650 }
1.651 }
1.652
1.653 @@ -790,8 +780,7 @@
1.654 // put in a terminating null character.
1.655 template <class _CharT, class _Traits>
1.656 basic_istream<_CharT, _Traits>&
1.657 -basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
1.658 -{
1.659 +basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n) {
1.660 sentry __sentry(*this, _No_Skip_WS());
1.661 this->_M_gcount = 0;
1.662
1.663 @@ -799,15 +788,15 @@
1.664 basic_streambuf<_CharT, _Traits>*__buf = this->rdbuf();
1.665 if (__buf->gptr() != __buf->egptr())
1.666 _M_gcount
1.667 - = _M_read_buffered(this, __buf, __n, __s,
1.668 - _Constant_unary_fun<bool, int_type>(false),
1.669 - _Project2nd<const _CharT*, const _CharT*>(),
1.670 - false, false, false);
1.671 + = _STLP_PRIV __read_buffered(this, __buf, __n, __s,
1.672 + _STLP_PRIV _Constant_unary_fun<bool, int_type>(false),
1.673 + _STLP_PRIV _Project2nd<const _CharT*, const _CharT*>(),
1.674 + false, false, false);
1.675 else
1.676 _M_gcount
1.677 - = _M_read_unbuffered(this, __buf, __n, __s,
1.678 - _Constant_unary_fun<bool, int_type>(false),
1.679 - false, false, false);
1.680 + = _STLP_PRIV __read_unbuffered(this, __buf, __n, __s,
1.681 + _STLP_PRIV _Constant_unary_fun<bool, int_type>(false),
1.682 + false, false, false);
1.683 }
1.684 else
1.685 this->setstate(ios_base::failbit);
1.686 @@ -823,8 +812,7 @@
1.687 // we don't put in a terminating null character.
1.688 template <class _CharT, class _Traits>
1.689 streamsize
1.690 -basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __nmax)
1.691 -{
1.692 +basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __nmax) {
1.693 sentry __sentry(*this, _No_Skip_WS());
1.694 this->_M_gcount = 0;
1.695
1.696 @@ -841,15 +829,15 @@
1.697
1.698 if (__buf->gptr() != __buf->egptr())
1.699 _M_gcount
1.700 - = _M_read_buffered(this, __buf, (min) (__avail, __nmax), __s,
1.701 - _Constant_unary_fun<bool, int_type>(false),
1.702 - _Project2nd<const _CharT*, const _CharT*>(),
1.703 - false, false, false);
1.704 + = _STLP_PRIV __read_buffered(this, __buf, (min) (__avail, __nmax), __s,
1.705 + _STLP_PRIV _Constant_unary_fun<bool, int_type>(false),
1.706 + _STLP_PRIV _Project2nd<const _CharT*, const _CharT*>(),
1.707 + false, false, false);
1.708 else
1.709 _M_gcount
1.710 - = _M_read_unbuffered(this, __buf, (min) (__avail, __nmax), __s,
1.711 - _Constant_unary_fun<bool, int_type>(false),
1.712 - false, false, false);
1.713 + = _STLP_PRIV __read_unbuffered(this, __buf, (min) (__avail, __nmax), __s,
1.714 + _STLP_PRIV _Constant_unary_fun<bool, int_type>(false),
1.715 + false, false, false);
1.716 }
1.717 }
1.718 else {
1.719 @@ -857,17 +845,7 @@
1.720 if (this->eof())
1.721 this->setstate(ios_base::eofbit | ios_base::failbit);
1.722 else
1.723 - {
1.724 - if (__nmax < 0)
1.725 - {
1.726 - basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.727 - streamsize __avail = __buf->in_avail();
1.728 - if(__avail == -1)
1.729 - this->setstate(ios_base::eofbit);
1.730 - }
1.731 - else
1.732 - this->setstate(ios_base::failbit);
1.733 - }
1.734 + this->setstate(ios_base::failbit);
1.735 }
1.736
1.737 // if (this->eof())
1.738 @@ -877,24 +855,23 @@
1.739 }
1.740
1.741 template <class _CharT, class _Traits>
1.742 -void basic_istream<_CharT, _Traits>::_M_formatted_get(_CharT* __s)
1.743 -{
1.744 +void basic_istream<_CharT, _Traits>::_M_formatted_get(_CharT* __s) {
1.745 sentry __sentry(*this); // Skip whitespace.
1.746
1.747 if (__sentry) {
1.748 basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.749 streamsize __nmax = this->width() > 0
1.750 ? this->width() - 1
1.751 - : (numeric_limits<streamsize>::max)() / sizeof(_CharT) - 1;
1.752 + : ((numeric_limits<streamsize>::max)() / sizeof(_CharT)) - 1;
1.753
1.754 streamsize __n = __buf->gptr() != __buf->egptr()
1.755 - ? _M_read_buffered(this, __buf, __nmax, __s,
1.756 - _Is_wspace_null<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
1.757 - _Scan_wspace_null<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
1.758 - false, true, false)
1.759 - : _M_read_unbuffered(this, __buf, __nmax, __s,
1.760 - _Is_wspace_null<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
1.761 - false, true, false);
1.762 + ? _STLP_PRIV __read_buffered(this, __buf, __nmax, __s,
1.763 + _STLP_PRIV _Is_wspace_null<_Traits>(__STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())),
1.764 + _STLP_PRIV _Scan_wspace_null<_Traits>(__STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())),
1.765 + false, true, false)
1.766 + : _STLP_PRIV __read_unbuffered(this, __buf, __nmax, __s,
1.767 + _STLP_PRIV _Is_wspace_null<_Traits>(__STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())),
1.768 + false, true, false);
1.769 if (__n == 0)
1.770 this->setstate(ios_base::failbit);
1.771 }
1.772 @@ -909,36 +886,14 @@
1.773 template < class _CharT, class _Traits, class _Is_Delim>
1.774 void _STLP_CALL
1.775 _M_ignore_unbuffered(basic_istream<_CharT, _Traits>* __that,
1.776 - basic_streambuf<_CharT, _Traits>* __buf,
1.777 - _Is_Delim __is_delim,
1.778 - bool __extract_delim, bool __set_failbit)
1.779 -{
1.780 + basic_streambuf<_CharT, _Traits>* __buf,
1.781 + _Is_Delim __is_delim,
1.782 + bool __extract_delim, bool __set_failbit) {
1.783 bool __done = false;
1.784 ios_base::iostate __status = 0;
1.785 typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
1.786
1.787 _STLP_TRY {
1.788 -#ifdef __SYMBIAN32__
1.789 - int_type __c = __buf->sgetc();
1.790 - do {
1.791 -
1.792 - if (__that->_S_eof(__c)) {
1.793 - __done = true;
1.794 - __status |= __set_failbit ? ios_base::eofbit | ios_base::failbit
1.795 - : ios_base::eofbit;
1.796 - break;
1.797 - }
1.798 -
1.799 - else if (__is_delim(__c)) {
1.800 - __done = true;
1.801 - if (__extract_delim)
1.802 - __buf->snextc();
1.803 - break;
1.804 -
1.805 - }
1.806 - __c = __buf->snextc();
1.807 - } while(!__done);
1.808 -#else
1.809 while (!__done) {
1.810 int_type __c = __buf->sbumpc();
1.811
1.812 @@ -948,14 +903,13 @@
1.813 : ios_base::eofbit;
1.814 }
1.815
1.816 - else if (__is_delim(__c)) {
1.817 + else if (__is_delim(_Traits::to_char_type(__c))) {
1.818 __done = true;
1.819 if (!__extract_delim)
1.820 if (__that->_S_eof(__buf->sputbackc(_Traits::to_char_type(__c))))
1.821 __status |= ios_base::failbit;
1.822 }
1.823 }
1.824 -#endif
1.825 }
1.826 _STLP_CATCH_ALL {
1.827 __that->_M_handle_exception(ios_base::badbit);
1.828 @@ -972,10 +926,9 @@
1.829 template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim>
1.830 void _STLP_CALL
1.831 _M_ignore_buffered(basic_istream<_CharT, _Traits>* __that,
1.832 - basic_streambuf<_CharT, _Traits>* __buf,
1.833 - _Is_Delim __is_delim, _Scan_Delim __scan_delim,
1.834 - bool __extract_delim, bool __set_failbit)
1.835 -{
1.836 + basic_streambuf<_CharT, _Traits>* __buf,
1.837 + _Is_Delim __is_delim, _Scan_Delim __scan_delim,
1.838 + bool __extract_delim, bool __set_failbit) {
1.839 bool __at_eof = false;
1.840 bool __found_delim = false;
1.841
1.842 @@ -1028,11 +981,10 @@
1.843 template < class _CharT, class _Traits, class _Max_Chars, class _Is_Delim>
1.844 streamsize _STLP_CALL
1.845 _M_ignore_unbuffered(basic_istream<_CharT, _Traits>* __that,
1.846 - basic_streambuf<_CharT, _Traits>* __buf,
1.847 - streamsize _Num, _Max_Chars __max_chars,
1.848 - _Is_Delim __is_delim,
1.849 - bool __extract_delim, bool __set_failbit)
1.850 -{
1.851 + basic_streambuf<_CharT, _Traits>* __buf,
1.852 + streamsize _Num, _Max_Chars __max_chars,
1.853 + _Is_Delim __is_delim,
1.854 + bool __extract_delim, bool __set_failbit) {
1.855 streamsize __n = 0;
1.856 ios_base::iostate __status = 0;
1.857 typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
1.858 @@ -1047,7 +999,7 @@
1.859 break;
1.860 }
1.861
1.862 - else if (__is_delim(__c)) {
1.863 + else if (__is_delim(_Traits::to_char_type(__c))) {
1.864 if (__extract_delim)
1.865 ++__n;
1.866 else if (__that->_S_eof(__buf->sputbackc(_Traits::to_char_type(__c))))
1.867 @@ -1071,12 +1023,11 @@
1.868 template < class _CharT, class _Traits, class _Max_Chars, class _Is_Delim, class _Scan_Delim>
1.869 streamsize _STLP_CALL
1.870 _M_ignore_buffered(basic_istream<_CharT, _Traits>* __that,
1.871 - basic_streambuf<_CharT, _Traits>* __buf,
1.872 - streamsize _Num,
1.873 - _Max_Chars __max_chars,
1.874 - _Is_Delim __is_delim, _Scan_Delim __scan_delim,
1.875 - bool __extract_delim, bool __set_failbit)
1.876 -{
1.877 + basic_streambuf<_CharT, _Traits>* __buf,
1.878 + streamsize _Num,
1.879 + _Max_Chars __max_chars,
1.880 + _Is_Delim __is_delim, _Scan_Delim __scan_delim,
1.881 + bool __extract_delim, bool __set_failbit) {
1.882 streamsize __n = 0;
1.883 bool __at_eof = false;
1.884 bool __done = false;
1.885 @@ -1087,7 +1038,7 @@
1.886 streamsize __m = __max_chars(_Num, __n);
1.887
1.888 if (__avail >= __m) { // We have more characters than we need.
1.889 - const _CharT* __last = __buf->_M_gptr() + __m;
1.890 + const _CharT* __last = __buf->_M_gptr() + __STATIC_CAST(ptrdiff_t, __m);
1.891 const _CharT* __p = __scan_delim(__buf->_M_gptr(), __last);
1.892 ptrdiff_t __chunk = __p - __buf->_M_gptr();
1.893 __n += __chunk;
1.894 @@ -1141,33 +1092,30 @@
1.895 // decided to switch from buffered to unbuffered input. We switch to
1.896 // to _M_ignore_unbuffered.
1.897
1.898 - return __n + _M_ignore_unbuffered( __that, __buf, _Num, __max_chars,
1.899 + return __n + _M_ignore_unbuffered(__that, __buf, _Num, __max_chars,
1.900 __is_delim, __extract_delim, __set_failbit);
1.901 }
1.902
1.903
1.904 template <class _CharT, class _Traits>
1.905 basic_istream<_CharT, _Traits>&
1.906 -basic_istream<_CharT, _Traits>::ignore(streamsize __n)
1.907 -{
1.908 +basic_istream<_CharT, _Traits>::ignore(streamsize __n) {
1.909 sentry __sentry(*this, _No_Skip_WS());
1.910 this->_M_gcount = 0;
1.911
1.912 if (__sentry) {
1.913 basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.914 - typedef _Constant_unary_fun<bool, int_type> _Const_bool;
1.915 - typedef _Constant_binary_fun<streamsize, streamsize, streamsize>
1.916 - _Const_streamsize;
1.917 + typedef _STLP_PRIV _Constant_unary_fun<bool, int_type> _Const_bool;
1.918 + typedef _STLP_PRIV _Constant_binary_fun<streamsize, streamsize, streamsize> _Const_streamsize;
1.919 const streamsize __maxss = (numeric_limits<streamsize>::max)();
1.920
1.921 if (__n == (numeric_limits<int>::max)()) {
1.922 if (__buf->gptr() != __buf->egptr())
1.923 - _M_gcount
1.924 - = _M_ignore_buffered(this, __buf,
1.925 - __maxss, _Const_streamsize(__maxss),
1.926 - _Const_bool(false),
1.927 - _Project2nd<const _CharT*, const _CharT*>(),
1.928 - false, false);
1.929 + _M_gcount = _M_ignore_buffered(this, __buf,
1.930 + __maxss, _Const_streamsize(__maxss),
1.931 + _Const_bool(false),
1.932 + _STLP_PRIV _Project2nd<const _CharT*, const _CharT*>(),
1.933 + false, false);
1.934 else
1.935 _M_gcount = _M_ignore_unbuffered(this, __buf,
1.936 __maxss, _Const_streamsize(__maxss),
1.937 @@ -1175,12 +1123,11 @@
1.938 }
1.939 else {
1.940 if (__buf->gptr() != __buf->egptr())
1.941 - _M_gcount
1.942 - = _M_ignore_buffered(this, __buf,
1.943 - __n, minus<streamsize>(),
1.944 - _Const_bool(false),
1.945 - _Project2nd<const _CharT*, const _CharT*>(),
1.946 - false, false);
1.947 + _M_gcount = _M_ignore_buffered(this, __buf,
1.948 + __n, minus<streamsize>(),
1.949 + _Const_bool(false),
1.950 + _STLP_PRIV _Project2nd<const _CharT*, const _CharT*>(),
1.951 + false, false);
1.952 else
1.953 _M_gcount = _M_ignore_unbuffered(this, __buf, __n, minus<streamsize>(),
1.954 _Const_bool(false), false, false);
1.955 @@ -1192,15 +1139,14 @@
1.956
1.957 template <class _CharT, class _Traits>
1.958 basic_istream<_CharT, _Traits>&
1.959 -basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __delim)
1.960 -{
1.961 +basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __delim) {
1.962 sentry __sentry(*this, _No_Skip_WS());
1.963 this->_M_gcount = 0;
1.964
1.965 if (__sentry) {
1.966 basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.967 - typedef _Constant_unary_fun<bool, int_type> _Const_bool;
1.968 - typedef _Constant_binary_fun<streamsize, streamsize, streamsize>
1.969 + typedef _STLP_PRIV _Constant_unary_fun<bool, int_type> _Const_bool;
1.970 + typedef _STLP_PRIV _Constant_binary_fun<streamsize, streamsize, streamsize>
1.971 _Const_streamsize;
1.972 const streamsize __maxss = (numeric_limits<streamsize>::max)();
1.973
1.974 @@ -1208,26 +1154,25 @@
1.975 if (__buf->gptr() != __buf->egptr())
1.976 _M_gcount = _M_ignore_buffered(this, __buf,
1.977 __maxss, _Const_streamsize(__maxss),
1.978 - _Eq_int_bound<_Traits>(__delim),
1.979 - _Scan_for_int_val<_Traits>(__delim),
1.980 + _STLP_PRIV _Eq_int_bound<_Traits>(__delim),
1.981 + _STLP_PRIV _Scan_for_int_val<_Traits>(__delim),
1.982 true, false);
1.983 else
1.984 _M_gcount = _M_ignore_unbuffered(this, __buf,
1.985 __maxss, _Const_streamsize(__maxss),
1.986 - _Eq_int_bound<_Traits>(__delim),
1.987 + _STLP_PRIV _Eq_int_bound<_Traits>(__delim),
1.988 true, false);
1.989 }
1.990 else {
1.991 if (__buf->gptr() != __buf->egptr())
1.992 _M_gcount = _M_ignore_buffered(this, __buf,
1.993 __n, minus<streamsize>(),
1.994 - _Eq_int_bound<_Traits>(
1.995 - __delim),
1.996 - _Scan_for_int_val<_Traits>(__delim),
1.997 + _STLP_PRIV _Eq_int_bound<_Traits>(__delim),
1.998 + _STLP_PRIV _Scan_for_int_val<_Traits>(__delim),
1.999 true, false);
1.1000 else
1.1001 _M_gcount = _M_ignore_unbuffered(this, __buf, __n, minus<streamsize>(),
1.1002 - _Eq_int_bound<_Traits>(__delim),
1.1003 + _STLP_PRIV _Eq_int_bound<_Traits>(__delim),
1.1004 true, false);
1.1005 }
1.1006 }
1.1007 @@ -1238,19 +1183,18 @@
1.1008 // This member function does not construct a sentry object, because
1.1009 // it is called from sentry's constructor.
1.1010 template <class _CharT, class _Traits>
1.1011 -void basic_istream<_CharT, _Traits>::_M_skip_whitespace(bool __set_failbit)
1.1012 -{
1.1013 +void basic_istream<_CharT, _Traits>::_M_skip_whitespace(bool __set_failbit) {
1.1014 basic_streambuf<_CharT, _Traits>* __buf = this->rdbuf();
1.1015 if (!__buf)
1.1016 this->setstate(ios_base::badbit);
1.1017 else if (__buf->gptr() != __buf->egptr())
1.1018 _M_ignore_buffered(this, __buf,
1.1019 - _Is_not_wspace<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
1.1020 - _Scan_for_not_wspace<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
1.1021 + _STLP_PRIV _Is_not_wspace<_Traits>(__STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())),
1.1022 + _STLP_PRIV _Scan_for_not_wspace<_Traits>(__STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())),
1.1023 false, __set_failbit);
1.1024 else
1.1025 _M_ignore_unbuffered(this, __buf,
1.1026 - _Is_not_wspace<_Traits>((const ctype<_CharT>*)this->_M_ctype_facet()),
1.1027 + _STLP_PRIV _Is_not_wspace<_Traits>(__STATIC_CAST(const ctype<_CharT>*, this->_M_ctype_facet())),
1.1028 false, __set_failbit);
1.1029 }
1.1030
1.1031 @@ -1262,55 +1206,21 @@
1.1032 // We stop when we get an exception, when we fail to insert into the
1.1033 // output streambuf, or when __is_delim is true.
1.1034
1.1035 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.1036 +
1.1037 template < class _CharT, class _Traits, class _Is_Delim>
1.1038 streamsize _STLP_CALL
1.1039 -_M_copy_unbuffered( basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __src,
1.1040 - basic_streambuf<_CharT, _Traits>* __dest,
1.1041 - _Is_Delim __is_delim,
1.1042 - bool __extract_delim, bool __rethrow)
1.1043 -{
1.1044 +__copy_unbuffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __src,
1.1045 + basic_streambuf<_CharT, _Traits>* __dest,
1.1046 + _Is_Delim __is_delim,
1.1047 + bool __extract_delim, bool __rethrow) {
1.1048 streamsize __extracted = 0;
1.1049 ios_base::iostate __status = 0;
1.1050 typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
1.1051 int_type __c;
1.1052
1.1053 _STLP_TRY {
1.1054 -#ifdef __SYMBIAN32__
1.1055 - __c = __src->sgetc();
1.1056 - for(;; __c = __src->snextc()){
1.1057 -
1.1058 - // If we failed to get a character, then quit.
1.1059 - if (__that->_S_eof(__c)) {
1.1060 - __status |= ios_base::eofbit;
1.1061 - break;
1.1062 - }
1.1063 - // If it's the delimiter, then quit.
1.1064 - else if (__is_delim(__c)) {
1.1065 - if (!__extract_delim)
1.1066 - __status |= ios_base::failbit;
1.1067 - break;
1.1068 - }
1.1069 -
1.1070 - else {
1.1071 -
1.1072 - // Try to put the character in the output streambuf.
1.1073 - _STLP_TRY {
1.1074 - if (!__that->_S_eof(__dest->sputc(__c)))
1.1075 - ++__extracted;
1.1076 - else
1.1077 - break;
1.1078 - }
1.1079 - _STLP_CATCH_ALL {
1.1080 - __status |= ios_base::failbit;
1.1081 - break;
1.1082 - }
1.1083 -
1.1084 - }
1.1085 -
1.1086 - } /* while (true) */
1.1087 -#else
1.1088 - while (true) {
1.1089 -
1.1090 + for (;;) {
1.1091 // Get a character. If there's an exception, catch and (maybe) rethrow it.
1.1092 __c = __src->sbumpc();
1.1093
1.1094 @@ -1320,18 +1230,16 @@
1.1095 break;
1.1096 }
1.1097 // If it's the delimiter, then quit.
1.1098 - else if (__is_delim(__c)) {
1.1099 + else if (__is_delim(_Traits::to_char_type(__c))) {
1.1100 if (!__extract_delim && !__pushback(__src, _Traits::to_char_type(__c)))
1.1101 __status |= ios_base::failbit;
1.1102 break;
1.1103 }
1.1104 -
1.1105 else {
1.1106 -
1.1107 // Try to put the character in the output streambuf.
1.1108 bool __failed = false;
1.1109 _STLP_TRY {
1.1110 - if (!__that->_S_eof(__dest->sputc(__c)))
1.1111 + if (!__that->_S_eof(__dest->sputc(_Traits::to_char_type(__c))))
1.1112 ++__extracted;
1.1113 else
1.1114 __failed = true;
1.1115 @@ -1350,8 +1258,8 @@
1.1116 break;
1.1117 }
1.1118
1.1119 - } /* while (true) */
1.1120 -#endif
1.1121 + } /* for (;;) */
1.1122 +
1.1123 }
1.1124 // fbp : this try/catch moved here in reasonable assumption
1.1125 // __is_delim never throw (__pushback is guaranteed not to)
1.1126 @@ -1366,28 +1274,27 @@
1.1127
1.1128 // Buffered copying from one streambuf to another. We copy the characters
1.1129 // in chunks, rather than one at a time. We still have to worry about all
1.1130 -// of the error conditions we checked in _M_copy_unbuffered, plus one more:
1.1131 +// of the error conditions we checked in __copy_unbuffered, plus one more:
1.1132 // the streambuf might decide to switch from a buffered to an unbuffered mode.
1.1133
1.1134 template < class _CharT, class _Traits, class _Is_Delim, class _Scan_Delim>
1.1135 streamsize _STLP_CALL
1.1136 -_M_copy_buffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __src,
1.1137 - basic_streambuf<_CharT, _Traits>* __dest,
1.1138 - _Scan_Delim __scan_delim, _Is_Delim __is_delim,
1.1139 - bool __extract_delim, bool __rethrow)
1.1140 -{
1.1141 +__copy_buffered(basic_istream<_CharT, _Traits>* __that, basic_streambuf<_CharT, _Traits>* __src,
1.1142 + basic_streambuf<_CharT, _Traits>* __dest,
1.1143 + _Scan_Delim __scan_delim, _Is_Delim __is_delim,
1.1144 + bool __extract_delim, bool __rethrow) {
1.1145 streamsize __extracted = 0;
1.1146 ios_base::iostate __status = 0;
1.1147 typedef typename basic_istream<_CharT, _Traits>::int_type int_type;
1.1148 - int_type __c = _Traits::eof();
1.1149 + //Borland compiler generates a warning if assignment because value is never used:
1.1150 + int_type __c /*= _Traits::eof()*/;
1.1151 _CharT* __first = __src->_M_gptr();
1.1152 ptrdiff_t __avail = __src->_M_egptr() - __first;
1.1153 // fbp : introduced to move catch/try blocks out of the loop
1.1154 - bool __do_handle_exceptions;
1.1155 + bool __do_handle_exceptions = false;
1.1156
1.1157 _STLP_TRY {
1.1158 - while (true) {
1.1159 - __do_handle_exceptions = false ;
1.1160 + for (;;) {
1.1161 const _CharT* __last = __scan_delim(__first, __src->_M_egptr());
1.1162
1.1163 // Try to copy the entire input buffer to the output buffer.
1.1164 @@ -1411,15 +1318,18 @@
1.1165 __avail = __src->_M_egptr() - __first;
1.1166
1.1167 if (__avail > 0)
1.1168 - {} // dwa 1/16/00 -- suppress a Metrowerks warning
1.1169 + {} // dwa 1/16/00 -- suppress a Metrowerks warning
1.1170 else if (__that->_S_eof(__c)) {
1.1171 __status |= ios_base::eofbit;
1.1172 break;
1.1173 }
1.1174 - else
1.1175 - return __extracted + _M_copy_unbuffered(__that, __src, __dest, __is_delim,
1.1176 + else {
1.1177 + return __extracted + __copy_unbuffered(__that, __src, __dest, __is_delim,
1.1178 __extract_delim, __rethrow);
1.1179 - } /* while */
1.1180 + }
1.1181 +
1.1182 + __do_handle_exceptions = false;
1.1183 + }
1.1184 }
1.1185
1.1186 _STLP_CATCH_ALL {
1.1187 @@ -1433,13 +1343,12 @@
1.1188 return __extracted;
1.1189 }
1.1190
1.1191 -
1.1192 +_STLP_MOVE_TO_STD_NAMESPACE
1.1193
1.1194 template <class _CharT, class _Traits>
1.1195 basic_istream<_CharT, _Traits>&
1.1196 basic_istream<_CharT, _Traits>
1.1197 - ::get(basic_streambuf<_CharT, _Traits>& __dest, _CharT __delim)
1.1198 -{
1.1199 + ::get(basic_streambuf<_CharT, _Traits>& __dest, _CharT __delim) {
1.1200 sentry __sentry(*this, _No_Skip_WS());
1.1201 this->_M_gcount = 0;
1.1202
1.1203 @@ -1448,13 +1357,13 @@
1.1204
1.1205 if (__src)
1.1206 this->_M_gcount = __src->egptr() != __src->gptr()
1.1207 - ? _M_copy_buffered(this, __src, &__dest,
1.1208 - _Scan_for_char_val<_Traits>(__delim),
1.1209 - _Eq_char_bound<_Traits>(__delim),
1.1210 - false, false)
1.1211 - : _M_copy_unbuffered(this, __src, &__dest,
1.1212 - _Eq_char_bound<_Traits>(__delim),
1.1213 - false, false);
1.1214 + ? _STLP_PRIV __copy_buffered(this, __src, &__dest,
1.1215 + _STLP_PRIV _Scan_for_char_val<_Traits>(__delim),
1.1216 + _STLP_PRIV _Eq_char_bound<_Traits>(__delim),
1.1217 + false, false)
1.1218 + : _STLP_PRIV __copy_unbuffered(this, __src, &__dest,
1.1219 + _STLP_PRIV _Eq_char_bound<_Traits>(__delim),
1.1220 + false, false);
1.1221 }
1.1222
1.1223 if (this->_M_gcount == 0)
1.1224 @@ -1467,8 +1376,7 @@
1.1225 template <class _CharT, class _Traits>
1.1226 basic_istream<_CharT, _Traits>&
1.1227 basic_istream<_CharT, _Traits>
1.1228 - ::operator>>(basic_streambuf<_CharT, _Traits>* __dest)
1.1229 -{
1.1230 + ::operator>>(basic_streambuf<_CharT, _Traits>* __dest) {
1.1231 streamsize __n = 0;
1.1232 typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry;
1.1233 _Sentry __sentry(*this);
1.1234 @@ -1476,13 +1384,13 @@
1.1235 basic_streambuf<_CharT, _Traits>* __src = this->rdbuf();
1.1236 if (__src && __dest)
1.1237 __n = __src->egptr() != __src->gptr()
1.1238 - ? _M_copy_buffered(this, __src, __dest,
1.1239 - _Project2nd<const _CharT*, const _CharT*>(),
1.1240 - _Constant_unary_fun<bool, int_type>(false),
1.1241 - false, true)
1.1242 - : _M_copy_unbuffered(this, __src, __dest,
1.1243 - _Constant_unary_fun<bool, int_type>(false),
1.1244 - false, true);
1.1245 + ? _STLP_PRIV __copy_buffered(this, __src, __dest,
1.1246 + _STLP_PRIV _Project2nd<const _CharT*, const _CharT*>(),
1.1247 + _STLP_PRIV _Constant_unary_fun<bool, int_type>(false),
1.1248 + false, true)
1.1249 + : _STLP_PRIV __copy_unbuffered(this, __src, __dest,
1.1250 + _STLP_PRIV _Constant_unary_fun<bool, int_type>(false),
1.1251 + false, true);
1.1252 }
1.1253
1.1254 if (__n == 0)
1.1255 @@ -1496,39 +1404,26 @@
1.1256 // ----------------------------------------------------------------
1.1257
1.1258 template <class _CharT, class _Traits>
1.1259 -_STLP_EXP_DECLSPEC basic_iostream<_CharT, _Traits>
1.1260 +basic_iostream<_CharT, _Traits>
1.1261 ::basic_iostream(basic_streambuf<_CharT, _Traits>* __buf)
1.1262 : basic_ios<_CharT, _Traits>(),
1.1263 basic_istream<_CharT, _Traits>(__buf),
1.1264 - basic_ostream<_CharT, _Traits>(__buf)
1.1265 -{
1.1266 + basic_ostream<_CharT, _Traits>(__buf) {
1.1267 this->init(__buf);
1.1268 }
1.1269
1.1270 template <class _CharT, class _Traits>
1.1271 -_STLP_EXP_DECLSPEC basic_iostream<_CharT, _Traits>::~basic_iostream()
1.1272 +basic_iostream<_CharT, _Traits>::~basic_iostream()
1.1273 {}
1.1274
1.1275 -
1.1276 -template <class _CharT, class _Traits>
1.1277 -_STLP_EXP_DECLSPEC basic_istream<_CharT, _Traits>
1.1278 - ::basic_istream(basic_streambuf<_CharT, _Traits>* __buf) :
1.1279 - basic_ios<_CharT, _Traits>(), _M_gcount(0) {
1.1280 - this->init(__buf);
1.1281 - }
1.1282 -
1.1283 -template <class _CharT, class _Traits>
1.1284 -_STLP_EXP_DECLSPEC basic_istream<_CharT, _Traits>
1.1285 - ::~basic_istream() {}
1.1286 -
1.1287 -
1.1288 -
1.1289 _STLP_END_NAMESPACE
1.1290
1.1291 -# undef __BIS_int_type__
1.1292 -# undef __BIS_pos_type__
1.1293 -# undef __BIS_off_type__
1.1294 -
1.1295 -# endif /* defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) */
1.1296 +#undef __BIS_int_type__
1.1297 +#undef __BIS_pos_type__
1.1298 +#undef __BIS_off_type__
1.1299
1.1300 #endif /* _STLP_ISTREAM_C */
1.1301 +
1.1302 +// Local Variables:
1.1303 +// mode:C++
1.1304 +// End: