{
_M_gcount = 0;
sentry __cerb(*this, true);
- if (__cerb && __n > 1)
+ if (__cerb)
{
try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
- int_type __c = __sb->sbumpc();
- bool __testdelim = __c == __idelim;
- bool __testeof = __c == __eof;
+ int_type __c = __sb->sgetc();
- while (_M_gcount < __n - 1 && !__testeof && !__testdelim)
+ while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim)
{
*__s++ = traits_type::to_char_type(__c);
+ __c = __sb->snextc();
++_M_gcount;
- __c = __sb->sbumpc();
- __testeof = __c == __eof;
- __testdelim = __c == __idelim;
}
- if (__testdelim || _M_gcount == __n - 1)
- __sb->sputbackc(__c);
- if (__testeof)
+ if (__c == __eof)
this->setstate(ios_base::eofbit);
}
catch(exception& __fail)
sentry __cerb(*this, true);
if (__cerb)
{
- int_type __c;
- __streambuf_type* __this_sb = this->rdbuf();
try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
- __c = __this_sb->sbumpc();
- bool __testdelim = __c == __idelim;
- bool __testeof = __c == __eof;
- bool __testput = true;
+ __streambuf_type* __this_sb = this->rdbuf();
+ int_type __c = __this_sb->sgetc();
- while (!__testeof && !__testdelim
- && (__testput = __sb.sputc(traits_type::to_char_type(__c))
- != __eof))
+ while (__c != __eof && __c != __idelim
+ && (__sb.sputc(traits_type::to_char_type(__c)) != __eof))
{
++_M_gcount;
- __c = __this_sb->sbumpc();
- __testeof = __c == __eof;
- __testdelim = __c == __idelim;
+ __c = __this_sb->snextc();
}
- if (__testdelim || !__testput)
- __this_sb->sputbackc(traits_type::to_char_type(__c));
- if (__testeof)
+ if (__c == __eof)
this->setstate(ios_base::eofbit);
}
catch(exception& __fail)
{
- // Exception may result from sputc->overflow.
- __this_sb->sputbackc(traits_type::to_char_type(__c));
+ // 27.6.1.3 paragraph 1
+ // Turn this on without causing an ios::failure to be thrown.
+ this->setstate(ios_base::badbit);
+ if ((this->exceptions() & ios_base::badbit) != 0)
+ __throw_exception_again;
}
}
if (!_M_gcount)
{
try
{
- __streambuf_type* __sb = this->rdbuf();
- int_type __c = __sb->sbumpc();
- ++_M_gcount;
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
- bool __testdelim = __c == __idelim;
- bool __testeof = __c == __eof;
+ __streambuf_type* __sb = this->rdbuf();
+ int_type __c = __sb->sgetc();
- while (_M_gcount < __n && !__testeof && !__testdelim)
+ while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim)
{
*__s++ = traits_type::to_char_type(__c);
- __c = __sb->sbumpc();
+ __c = __sb->snextc();
++_M_gcount;
- __testeof = __c == __eof;
- __testdelim = __c == __idelim;
}
-
- if (__testeof)
- {
- --_M_gcount;
- this->setstate(ios_base::eofbit);
- }
- else if (!__testdelim)
+ if (__c == __eof)
+ this->setstate(ios_base::eofbit);
+ else
{
- --_M_gcount;
- __sb->sputbackc(traits_type::to_char_type(__c));
- this->setstate(ios_base::failbit);
+ if (__c == __idelim)
+ {
+ __sb->snextc();
+ ++_M_gcount;
+ }
+ else
+ this->setstate(ios_base::failbit);
}
}
catch(exception& __fail)
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
const int_type __eof = _Traits::eof();
__streambuf_type* __sb = __in.rdbuf();
- int_type __c = __sb->sbumpc();
- bool __testeof = __c == __eof;
- bool __testsp = __ctype.is(ctype_base::space, __c);
+ int_type __c = __sb->sgetc();
- while (__extracted < __num - 1 && !__testeof && !__testsp)
+ while (__extracted < __num - 1
+ && __c != __eof && !__ctype.is(ctype_base::space, __c))
{
*__s++ = __c;
++__extracted;
- __c = __sb->sbumpc();
- __testeof = __c == __eof;
- __testsp = __ctype.is(ctype_base::space, __c);
+ __c = __sb->snextc();
}
-
- if (!__testeof)
- __sb->sputbackc(__c);
- else
+ if (__c == __eof)
__in.setstate(ios_base::eofbit);
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
typedef typename __istream_type::__streambuf_type __streambuf_type;
typedef typename __istream_type::__ctype_type __ctype_type;
typedef typename __istream_type::int_type __int_type;
- typedef typename __istream_type::char_type __char_type;
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
- __streambuf_type* __sb = __in.rdbuf();
const __int_type __eof = _Traits::eof();
- __int_type __c;
- bool __testeof;
- bool __testsp;
-
- do
- {
- __c = __sb->sbumpc();
- __testeof = __c == __eof;
- __testsp = __ctype.is(ctype_base::space, __c);
- }
- while (!__testeof && __testsp);
+ __streambuf_type* __sb = __in.rdbuf();
+ __int_type __c = __sb->sgetc();
- if (!__testeof && !__testsp)
- __sb->sputbackc(__c);
- else
+ while (__c != __eof && __ctype.is(ctype_base::space, __c))
+ __c = __sb->snextc();
+ if (__c == __eof)
__in.setstate(ios_base::eofbit);
return __in;
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
const __int_type __eof = _Traits::eof();
__streambuf_type* __sb = __in.rdbuf();
- __int_type __c = __sb->sbumpc();
- bool __testeof = __c == __eof;
- bool __testsp = __ctype.is(ctype_base::space, __c);
-
- while (__extracted < __n && !__testeof && !__testsp)
+ __int_type __c = __sb->sgetc();
+
+ while (__extracted < __n
+ && __c != __eof && !__ctype.is(ctype_base::space, __c))
{
__str += _Traits::to_char_type(__c);
++__extracted;
- __c = __sb->sbumpc();
- __testeof = __c == __eof;
- __testsp = __ctype.is(ctype_base::space, __c);
+ __c = __sb->snextc();
}
- if (!__testeof)
- __sb->sputbackc(__c);
- else
+ if (__c == __eof)
__in.setstate(ios_base::eofbit);
__in.width(0);
}
__int_type __c = __sb->sbumpc();
const __int_type __eof = _Traits::eof();
__testdelim = __c == __idelim;
- bool __testeof = __c == __eof;
- while (__extracted <= __n && !__testeof && !__testdelim)
+ while (__extracted <= __n && __c != __eof && !__testdelim)
{
__str += _Traits::to_char_type(__c);
++__extracted;
__c = __sb->sbumpc();
- __testeof = __c == __eof;
__testdelim = __c == __idelim;
}
- if (__testeof)
+ if (__c == __eof)
__in.setstate(ios_base::eofbit);
}
if (!__extracted && !__testdelim)
// Concept checking instantiations -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation
+// Copyright (C) 2001, 2002 Free Software Foundation
//
// This file is part of GNU CC.
//
#ifdef _GLIBCPP_CONCEPT_CHECKS
#include <memory>
-#include <vector>
#include <ostream>
#define _Instantiate(...) template void __function_requires< __VA_ARGS__ > ()
{
template void __aux_require_boolean_expr<bool>(bool const&);
- _Instantiate(_BidirectionalIteratorConcept<
- __normal_iterator< std::locale::facet**,
- std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
-
- _Instantiate(_BidirectionalIteratorConcept<
- __normal_iterator< unsigned*,
- std::vector<unsigned, std::allocator<unsigned> > > > );
-
- _Instantiate(_ConvertibleConcept<std::locale::facet*, std::locale::facet*> );
-
_Instantiate(_ConvertibleConcept<unsigned, unsigned> );
_Instantiate(_InputIteratorConcept<char*> );
_Instantiate(_InputIteratorConcept<char const*> );
- _Instantiate(_InputIteratorConcept<std::locale::facet**> );
-
- _Instantiate(_InputIteratorConcept<
- __normal_iterator< std::locale::facet* const*,
- std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
-
- _Instantiate(_InputIteratorConcept<
- __normal_iterator< std::locale::facet**,
- std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
-
- _Instantiate(_InputIteratorConcept<
- __normal_iterator< unsigned*,
- std::vector<unsigned, std::allocator<unsigned> > > > );
-
#ifdef _GLIBCPP_USE_WCHAR_T
_Instantiate(_InputIteratorConcept<wchar_t*> );
_Instantiate(_LessThanComparableConcept<unsigned> );
- _Instantiate(_Mutable_BidirectionalIteratorConcept<
- __normal_iterator< std::locale::facet**,
- std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
-
- _Instantiate(_Mutable_BidirectionalIteratorConcept<
- __normal_iterator< unsigned*,
- std::vector<unsigned, std::allocator<unsigned> > > > );
-
- _Instantiate(_Mutable_ForwardIteratorConcept<
- __normal_iterator< std::locale::facet**,
- std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > );
-
- _Instantiate(_OutputIteratorConcept<
- std::locale::facet**, std::locale::facet*> );
-
- _Instantiate(_OutputIteratorConcept<
- __normal_iterator< std::locale::facet**,
- std::vector<std::locale::facet*, std::allocator<std::locale::facet* > > >,
- std::locale::facet* > );
-
- _Instantiate(_OutputIteratorConcept<__normal_iterator<
- unsigned*, std::vector<unsigned, std::allocator<unsigned> > >, unsigned> );
-
_Instantiate(_OutputIteratorConcept<std::ostreambuf_iterator<
char, std::char_traits<char> >, char> );
_Instantiate(_RandomAccessIteratorConcept<wchar_t const*> );
#endif
-
} // namespace __gnu_cxx
#undef _Instantiate