// Input streams -*- C++ -*-
-// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
+// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.6.1 Input streams
#include <istream>
-namespace std
+namespace std _GLIBCXX_VISIBILITY(default)
{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
template<>
basic_istream<char>&
basic_istream<char>::
getline(char_type* __s, streamsize __n, char_type __delim)
{
_M_gcount = 0;
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
+ ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
- try
+ __try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
__size = __p - __sb->gptr();
traits_type::copy(__s, __sb->gptr(), __size);
__s += __size;
- __sb->gbump(__size);
+ __sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
else
__err |= ios_base::failbit;
}
- catch(...)
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ this->_M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
_M_gcount = 0;
sentry __cerb(*this, true);
- if (__cerb && __n > 0)
+ if (__n > 0 && __cerb)
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
+ ios_base::iostate __err = ios_base::goodbit;
+ __try
{
- const char_type __cdelim = traits_type::to_char_type(__delim);
+ const char_type __cdelim = traits_type::to_char_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
__cdelim);
if (__p)
__size = __p - __sb->gptr();
- __sb->gbump(__size);
+ __sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
__c = __sb->snextc();
}
}
- if (__n == numeric_limits<streamsize>::max()
+ if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __delim))
{
- _M_gcount = numeric_limits<streamsize>::min();
+ _M_gcount =
+ __gnu_cxx::__numeric_traits<streamsize>::__min;
__large_ignore = true;
}
else
}
if (__large_ignore)
- _M_gcount = numeric_limits<streamsize>::max();
+ _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (traits_type::eq_int_type(__c, __delim))
{
- if (_M_gcount < numeric_limits<streamsize>::max())
+ if (_M_gcount
+ < __gnu_cxx::__numeric_traits<streamsize>::__max)
++_M_gcount;
__sb->sbumpc();
}
}
- catch(...)
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ this->_M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
typedef __istream_type::__ctype_type __ctype_type;
streamsize __extracted = 0;
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
+ ios_base::iostate __err = ios_base::goodbit;
__istream_type::sentry __cerb(__in, false);
if (__cerb)
{
- try
+ __try
{
// Figure out how many characters to extract.
streamsize __num = __in.width();
if (__num <= 0)
- __num = numeric_limits<streamsize>::max();
+ __num = __gnu_cxx::__numeric_traits<streamsize>::__max;
const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc());
- __sb->gptr());
__traits_type::copy(__s, __sb->gptr(), __size);
__s += __size;
- __sb->gbump(__size);
+ __sb->__safe_gbump(__size);
__extracted += __size;
__c = __sb->sgetc();
}
*__s = __char_type();
__in.width(0);
}
- catch(...)
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ __in._M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
{ __in._M_setstate(ios_base::badbit); }
}
if (!__extracted)
typedef __string_type::size_type __size_type;
__size_type __extracted = 0;
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
+ ios_base::iostate __err = ios_base::goodbit;
__istream_type::sentry __cerb(__in, false);
if (__cerb)
{
- try
+ __try
{
__str.erase();
const streamsize __w = __in.width();
__sb->gptr() + __size)
- __sb->gptr());
__str.append(__sb->gptr(), __size);
- __sb->gbump(__size);
+ __sb->__safe_gbump(__size);
__extracted += __size;
__c = __sb->sgetc();
}
__err |= ios_base::eofbit;
__in.width(0);
}
- catch(...)
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ __in._M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
__size_type __extracted = 0;
const __size_type __n = __str.max_size();
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
+ ios_base::iostate __err = ios_base::goodbit;
__istream_type::sentry __cerb(__in, true);
if (__cerb)
{
- try
+ __try
{
__str.erase();
const __int_type __idelim = __traits_type::to_int_type(__delim);
if (__p)
__size = __p - __sb->gptr();
__str.append(__sb->gptr(), __size);
- __sb->gbump(__size);
+ __sb->__safe_gbump(__size);
__extracted += __size;
__c = __sb->sgetc();
}
else
__err |= ios_base::failbit;
}
- catch(...)
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ __in._M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
getline(char_type* __s, streamsize __n, char_type __delim)
{
_M_gcount = 0;
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
+ ios_base::iostate __err = ios_base::goodbit;
sentry __cerb(*this, true);
if (__cerb)
{
- try
+ __try
{
const int_type __idelim = traits_type::to_int_type(__delim);
const int_type __eof = traits_type::eof();
__size = __p - __sb->gptr();
traits_type::copy(__s, __sb->gptr(), __size);
__s += __size;
- __sb->gbump(__size);
+ __sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
else
__err |= ios_base::failbit;
}
- catch(...)
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ this->_M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
{ this->_M_setstate(ios_base::badbit); }
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
_M_gcount = 0;
sentry __cerb(*this, true);
- if (__cerb && __n > 0)
+ if (__n > 0 && __cerb)
{
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
- try
+ ios_base::iostate __err = ios_base::goodbit;
+ __try
{
- const char_type __cdelim = traits_type::to_char_type(__delim);
+ const char_type __cdelim = traits_type::to_char_type(__delim);
const int_type __eof = traits_type::eof();
__streambuf_type* __sb = this->rdbuf();
int_type __c = __sb->sgetc();
__cdelim);
if (__p)
__size = __p - __sb->gptr();
- __sb->gbump(__size);
+ __sb->__safe_gbump(__size);
_M_gcount += __size;
__c = __sb->sgetc();
}
__c = __sb->snextc();
}
}
- if (__n == numeric_limits<streamsize>::max()
+ if (__n == __gnu_cxx::__numeric_traits<streamsize>::__max
&& !traits_type::eq_int_type(__c, __eof)
&& !traits_type::eq_int_type(__c, __delim))
{
- _M_gcount = numeric_limits<streamsize>::min();
+ _M_gcount =
+ __gnu_cxx::__numeric_traits<streamsize>::__min;
__large_ignore = true;
}
else
}
if (__large_ignore)
- _M_gcount = numeric_limits<streamsize>::max();
+ _M_gcount = __gnu_cxx::__numeric_traits<streamsize>::__max;
if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit;
else if (traits_type::eq_int_type(__c, __delim))
{
- if (_M_gcount < numeric_limits<streamsize>::max())
+ if (_M_gcount
+ < __gnu_cxx::__numeric_traits<streamsize>::__max)
++_M_gcount;
__sb->sbumpc();
}
}
- catch(...)
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ this->_M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
__size_type __extracted = 0;
const __size_type __n = __str.max_size();
- ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
+ ios_base::iostate __err = ios_base::goodbit;
__istream_type::sentry __cerb(__in, true);
if (__cerb)
{
- try
+ __try
{
__str.erase();
const __int_type __idelim = __traits_type::to_int_type(__delim);
if (__p)
__size = __p - __sb->gptr();
__str.append(__sb->gptr(), __size);
- __sb->gbump(__size);
+ __sb->__safe_gbump(__size);
__extracted += __size;
__c = __sb->sgetc();
}
else
__err |= ios_base::failbit;
}
- catch(...)
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ __in._M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 91. Description of operator>> and getline() for string<>
return __in;
}
#endif
-} // namespace std
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace