gcc/libstdc++-v3/include/bits/ostream.tcc

705 lines
20 KiB
Plaintext
Raw Normal View History

Tune for size. 2002-02-15 Benjamin Kosnik <bkoz@redhat.com> Tune for size. * src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant explicit instantiation. (string::_Rep::_S_max_size): Same. * include/bits/basic_string.tcc: Add extern explicit instantiations for string, wstring. * include/bits/basic_ios.tcc: Add extern explicit instantiations for ios, wios. * include/bits/streambuf.tcc: Same, for streambuf, wstreambuf. * include/bits/istream.tcc: Same, for istream, wistream. * include/bits/ostream.tcc: Same for ostream, wostream, iostream, wiostream. * include/bits/sstream.tcc: Same, for stringbuf, wstringbuf, istringstream, wistringstream, ostringstream, wostringstream, stringstream, wstringstream. * include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream, wifstream, ofstream, wofstream, fstream, wfstream. * src/misc-inst.cc: Correct comments. Add iomanip instantiations for wide streams. * include/std/std_iomanip.h: Same. * include/bits/locale_facets.tcc: Same. * include/std/std_streambuf.h: Correct _GLIBCPP_FULLY_COMPLIANT_HEADERS guard. * include/std/std_sstream.h: Same. * include/std/std_ostream.h: Same. * include/std/std_istream.h: Same. * include/std/std_fstream.h: Same. * include/std/std_streambuf.h: Add definitions for private copy ctor and assignment operator. * include/std/std_istream.h: Remove declared but undefined copy ctor and assignment operator. This is taken care of in ios_base, so adding it in the derived class as well is superfluous. * include/std/std_ostream.h: Same. * include/bits/basic_ios.h (basic_ios::clear): Don't inline. * include/bits/basic_ios.tcc (basic_ios::clear): Move definition here. From-SVN: r49798
2002-02-16 01:19:13 +01:00
// ostream classes -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Tune for size. 2002-02-15 Benjamin Kosnik <bkoz@redhat.com> Tune for size. * src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant explicit instantiation. (string::_Rep::_S_max_size): Same. * include/bits/basic_string.tcc: Add extern explicit instantiations for string, wstring. * include/bits/basic_ios.tcc: Add extern explicit instantiations for ios, wios. * include/bits/streambuf.tcc: Same, for streambuf, wstreambuf. * include/bits/istream.tcc: Same, for istream, wistream. * include/bits/ostream.tcc: Same for ostream, wostream, iostream, wiostream. * include/bits/sstream.tcc: Same, for stringbuf, wstringbuf, istringstream, wistringstream, ostringstream, wostringstream, stringstream, wstringstream. * include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream, wifstream, ofstream, wofstream, fstream, wfstream. * src/misc-inst.cc: Correct comments. Add iomanip instantiations for wide streams. * include/std/std_iomanip.h: Same. * include/bits/locale_facets.tcc: Same. * include/std/std_streambuf.h: Correct _GLIBCPP_FULLY_COMPLIANT_HEADERS guard. * include/std/std_sstream.h: Same. * include/std/std_ostream.h: Same. * include/std/std_istream.h: Same. * include/std/std_fstream.h: Same. * include/std/std_streambuf.h: Add definitions for private copy ctor and assignment operator. * include/std/std_istream.h: Remove declared but undefined copy ctor and assignment operator. This is taken care of in ios_base, so adding it in the derived class as well is superfluous. * include/std/std_ostream.h: Same. * include/bits/basic_ios.h (basic_ios::clear): Don't inline. * include/bits/basic_ios.tcc (basic_ios::clear): Move definition here. From-SVN: r49798
2002-02-16 01:19:13 +01:00
// 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)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 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.
/** @file ostream.tcc
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
//
// ISO C++ 14882: 27.6.2 Output streams
//
#ifndef _OSTREAM_TCC
#define _OSTREAM_TCC 1
#pragma GCC system_header
Makefile.am (std_headers): Remove cXXX from list. 2002-01-04 Benjamin Kosnik <bkoz@redhat.com> * include/Makefile.am (std_headers): Remove cXXX from list. (c_base_srcdir): No bits subdirectory. (c_base_builddir): Same. (c_base_headers): Adjust names, add ciso646. (bits_headers): Remove std_xxx.h headers. * include/Makefile.in: Regenerate. * include/ext/iterator: Adjust includes. * include/ext/ropeimpl.h: Same. * include/ext/stl_hash_fun.h: Same. * include/ext/algorithm: Same. * include/backward/bvector.h: Adjust includes. * include/backward/vector.h: Same. * include/backward/strstream: Same. * include/backward/streambuf.h: Same. * include/backward/stack.h: Same. * include/backward/set.h: Same. * include/backward/queue.h: Same. * include/backward/multiset.h: Same. * include/backward/multimap.h: Same. * include/backward/map.h: Same. * include/backward/list.h: Same. * include/backward/iterator.h: Same. * include/backward/iostream.h: Same. * include/backward/iomanip.h: Same. * include/backward/fstream.h: Same. * include/backward/deque.h: Same. * include/backward/complex.h: Same. * include/bits/std_algorithm.h: Move to... * include/std/algorithm: ...here. * include/bits/std_iosfwd.h, std_locale.h, std_stack.h, std_bitset.h, std_ios.h, std_map.h, std_stdexcept.h, std_complex.h, std_iostream.h, std_memory.h, std_streambuf.h, std_deque.h, std_istream.h, std_numeric.h, std_string.h, std_fstream.h, std_ostream.h, std_utility.h, std_iterator.h, std_queue.h, std_valarray.h, std_functional.h, std_limits.h, std_set.h, std_vector.h, std_iomanip.h, std_list.h, std_sstream.h: Same. * include/c_std/bits/std_cassert.h: Move to... * include/c_std/cassert: Here. * include/c_std/std_cctype.h, std_cerrno.h, std_cfloat.h, std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h, std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h, std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h, std_cwctype.h: Same. * include/c_std/cmath: Adjust cmath.tcc include. * include/c_std/cstdlib: Adjust includes. * include/c_std/cwchar: Same. * include/c_std/ctime: Same. * include/c_std/cstring: Same. * include/c_std/cstdio: Same. * include/c_std/bits: Remove directory. * include/c/bits/std_cassert.h: Move to... * include/c/cassert: Here. * include/c/std_cctype.h, std_cerrno.h, std_cfloat.h, std_climits.h, std_clocale.h, std_cmath.h, std_csetjmp.h, std_csignal.h, std_cstdarg.h, std_cstddef.h, std_cstdio.h, std_cstdlib.h, std_cstring.h, std_ctime.h, std_cwchar.h, std_cwctype.h: Same. * include/c/bits: Remove directory. * include/std/cwctype: Remove. * include/std/cwchar: Remove. * include/std/ctime: Remove. * include/std/cstring: Remove. * include/std/cstdlib: Remove. * include/std/cstdio: Remove. * include/std/cstddef: Remove. * include/std/cstdarg: Remove. * include/std/csignal: Remove. * include/std/csetjmp: Remove. * include/std/cmath: Remove. * include/std/clocale: Remove. * include/std/climits: Remove. * include/std/ciso646: Remove. * include/std/cfloat: Remove. * include/std/cerrno: Remove. * include/std/cctype: Remove. * include/std/cassert: Remove. * include/bits/fpos.h: Adjust includes, removing <bits/std_xxx.h> files and subsituting <.xxx> * include/bits/valarray_array.h: Same. * include/bits/stl_uninitialized.h: Same. * include/bits/stl_alloc.h: Same. * include/bits/stl_algobase.h: Same. * include/bits/sstream.tcc: Same. * include/bits/pthread_allocimpl.h: Same. * include/bits/ostream.tcc: Same. * include/bits/localefwd.h: Same. * include/bits/locale_facets.tcc: Same. * include/bits/locale_facets.h: Same. * include/bits/istream.tcc: Same. * include/bits/char_traits.h: Same. * include/bits/boost_concept_check.h: Same. * include/bits/basic_file.h: Same. * include/std/bitset: Same. * include/std/complex: Same. * include/std/fstream: Same. * include/std/functional: Same. * include/std/ios: Same. * include/std/iostream: Same. * include/std/ostream: Same. * include/std/sstream: Same. * include/std/streambuf: Same. * include/std/string: Same. * include/std/iterator: Same. * include/std/valarray: Same. * src/ios.cc: Adjust includes. * src/valarray-inst.cc: Same. * src/string-inst.cc: Same. * src/stl-inst.cc: Same. * src/stdexcept.cc: Same. * src/misc-inst.cc: Same. * src/localename.cc: Same. * src/locale-inst.cc: Same. * src/locale.cc: Same. * src/limits.cc: Same. * src/concept-inst.cc: Same. * src/complex_io.cc: Same. * src/codecvt.cc: Same. * src/bitset.cc: Same. * src/cmath.cc: Same. From-SVN: r48544
2002-01-04 22:27:36 +01:00
#include <locale>
namespace std
{
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>::sentry::
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
sentry(basic_ostream<_CharT, _Traits>& __os)
re PR libstdc++/12854 (libstdc++ vs. -Weffc++) 2004-05-22 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/12854 Fixups for -Weffc++. * include/bits/basic_string.h (basic_string::operator=): Return pointer to this instead of result of assign. Although redundant, this doesn't impact resultant codegen. * include/bits/locale_facets.h (__numpunct_cache): Declare assignment opxserator and copy constructor private. (__timepunct_cache): Same. (__moneypunct_cache): Same. (collate): Use member initialization list for _M_c_locale_collate. * config/locale/gnu/messages_members.h: Same. * config/locale/gnu/time_members.h (__timepunct): Same. * src/codecvt.cc: Use member initialization list to initialize _M_c_locale_codecvt. * src/ctype.cc: Same, with _M_c_locale_ctype and _M_narrow_ok. * config/os/gnu-linux/ctype_noninline.h: Same. * src/locale.cc (_Impl): Same. * src/locale_init.cc: Same. * src/localename.cc: Same. * include/bits/basic_ios.h (basic_ios): Complete member initialization list. * include/bits/istream.tcc (basic_istream::sentry): Same. * include/bits/ostream.tcc (basic_ostream::sentry): Same. * include/bits/fstream.tcc (basic_filebuf): Add _M_lock and _M_pback to member initialization list. * include/std/std_streambuf.h: Same. * include/std/std_sstream.h: Same, for _M_mode. * src/ios.cc (ios_base): Same. * include/ext/rope: Make derived classes match exception specifications. Add copy constructors and assignment operators. * include/debug/safe_base.h (_Safe_sequence_base): Declare copy constructor and assignment operator protected. (_Safe_iterator_base): Same. * include/debug/formatter.h (_Error_formatter): Define copy constructor and assignment operator. * include/backward/strstream: Declare assignment operator and copy constructor private. From-SVN: r82153
2004-05-23 01:46:34 +02:00
: _M_ok(false), _M_os(__os)
{
// XXX MT
if (__os.tie() && __os.good())
__os.tie()->flush();
if (__os.good())
_M_ok = true;
else
re PR libstdc++/12854 (libstdc++ vs. -Weffc++) 2004-05-22 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/12854 Fixups for -Weffc++. * include/bits/basic_string.h (basic_string::operator=): Return pointer to this instead of result of assign. Although redundant, this doesn't impact resultant codegen. * include/bits/locale_facets.h (__numpunct_cache): Declare assignment opxserator and copy constructor private. (__timepunct_cache): Same. (__moneypunct_cache): Same. (collate): Use member initialization list for _M_c_locale_collate. * config/locale/gnu/messages_members.h: Same. * config/locale/gnu/time_members.h (__timepunct): Same. * src/codecvt.cc: Use member initialization list to initialize _M_c_locale_codecvt. * src/ctype.cc: Same, with _M_c_locale_ctype and _M_narrow_ok. * config/os/gnu-linux/ctype_noninline.h: Same. * src/locale.cc (_Impl): Same. * src/locale_init.cc: Same. * src/localename.cc: Same. * include/bits/basic_ios.h (basic_ios): Complete member initialization list. * include/bits/istream.tcc (basic_istream::sentry): Same. * include/bits/ostream.tcc (basic_ostream::sentry): Same. * include/bits/fstream.tcc (basic_filebuf): Add _M_lock and _M_pback to member initialization list. * include/std/std_streambuf.h: Same. * include/std/std_sstream.h: Same, for _M_mode. * src/ios.cc (ios_base): Same. * include/ext/rope: Make derived classes match exception specifications. Add copy constructors and assignment operators. * include/debug/safe_base.h (_Safe_sequence_base): Declare copy constructor and assignment operator protected. (_Safe_iterator_base): Same. * include/debug/formatter.h (_Error_formatter): Define copy constructor and assignment operator. * include/backward/strstream: Declare assignment operator and copy constructor private. From-SVN: r82153
2004-05-23 01:46:34 +02:00
__os.setstate(ios_base::failbit);
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
operator<<(__ostream_type& (*__pf)(__ostream_type&))
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// The inserters for manipulators are *not* formatted output functions.
return __pf(*this);
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
operator<<(__ios_type& (*__pf)(__ios_type&))
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// The inserters for manipulators are *not* formatted output functions.
__pf(*this);
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
operator<<(ios_base& (*__pf)(ios_base&))
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// The inserters for manipulators are *not* formatted output functions.
__pf(*this);
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(bool __n)
{
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_put_type& __np = __check_facet(this->_M_num_put);
if (__np.put(*this, *this, this->fill(), __n).failed())
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(long __n)
{
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
bool __b = false;
const char_type __c = this->fill();
const ios_base::fmtflags __fmt = (this->flags()
& ios_base::basefield);
const __num_put_type& __np = __check_facet(this->_M_num_put);
if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex))
acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. 2001-05-30 Benjamin Kosnik <bkoz@redat.com> * acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. (_GLIBCPP_BUGGY_COMPLEX): Remove. * config.h.in: Regenerate. * acinclude.m4 (GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT): Remove. * aclocal.m4: Regenerate. * configure.in: Don't call it. * configure: Regenerate. libstdc++/2970 * src/complex_io.cc (operator<<(ostream&, const complex&): Fix. * testsuite/26_numerics/complex_inserters_extractors.cc (test01): New test. libstdc++/2985 * include/bits/std_complex.h: Include sstream. Put definitions for complex inserters and extractors here, and remove them from... * src/complex_io.cc: ...here. * include/bits/basic_ios.h (basic_ios::__numput_type): Add _Traits parameter. (basic_ios::__numget_type): Same. * include/bits/std_istream.h: Same. * include/bits/std_ostream.h: Same. * include/bits/sbuf_iter.h (ostreambuf_iterator): Fix typo in base class iterator template arguments. * src/locale-inst.cc: Add explicit has_facet instantiations. * include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove. (_M_get_fnumput): Remove. (_M_get_fnumget): Remove. (basic_ios::_M_check_facet): New function. (basic_ios::_M_cache_facets): New function. * include/bits/basic_ios.tcc: Definition for _M_cache_facets. (basic_ios::imbue): Call _M_cache_facets. (basic_ios::init): Same. * include/bits/istream.tcc: Format, use _M_check_facet. * include/bits/ostream.tcc: Same. * include/bits/locale_facets.tcc (__output_float): Change signature, add _Traits. * testsuite/26_numerics/complex_inserters_extractors.cc (test02): New test. From-SVN: r42743
2001-05-31 14:14:56 +02:00
{
const unsigned long __l = static_cast<unsigned long>(__n);
__b = __np.put(*this, *this, __c, __l).failed();
acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. 2001-05-30 Benjamin Kosnik <bkoz@redat.com> * acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. (_GLIBCPP_BUGGY_COMPLEX): Remove. * config.h.in: Regenerate. * acinclude.m4 (GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT): Remove. * aclocal.m4: Regenerate. * configure.in: Don't call it. * configure: Regenerate. libstdc++/2970 * src/complex_io.cc (operator<<(ostream&, const complex&): Fix. * testsuite/26_numerics/complex_inserters_extractors.cc (test01): New test. libstdc++/2985 * include/bits/std_complex.h: Include sstream. Put definitions for complex inserters and extractors here, and remove them from... * src/complex_io.cc: ...here. * include/bits/basic_ios.h (basic_ios::__numput_type): Add _Traits parameter. (basic_ios::__numget_type): Same. * include/bits/std_istream.h: Same. * include/bits/std_ostream.h: Same. * include/bits/sbuf_iter.h (ostreambuf_iterator): Fix typo in base class iterator template arguments. * src/locale-inst.cc: Add explicit has_facet instantiations. * include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove. (_M_get_fnumput): Remove. (_M_get_fnumget): Remove. (basic_ios::_M_check_facet): New function. (basic_ios::_M_cache_facets): New function. * include/bits/basic_ios.tcc: Definition for _M_cache_facets. (basic_ios::imbue): Call _M_cache_facets. (basic_ios::init): Same. * include/bits/istream.tcc: Format, use _M_check_facet. * include/bits/ostream.tcc: Same. * include/bits/locale_facets.tcc (__output_float): Change signature, add _Traits. * testsuite/26_numerics/complex_inserters_extractors.cc (test02): New test. From-SVN: r42743
2001-05-31 14:14:56 +02:00
}
else
__b = __np.put(*this, *this, __c, __n).failed();
if (__b)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(unsigned long __n)
{
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_put_type& __np = __check_facet(this->_M_num_put);
if (__np.put(*this, *this, this->fill(), __n).failed())
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
#ifdef _GLIBCXX_USE_LONG_LONG
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(long long __n)
{
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
bool __b = false;
const char_type __c = this->fill();
const ios_base::fmtflags __fmt = (this->flags()
& ios_base::basefield);
const __num_put_type& __np = __check_facet(this->_M_num_put);
if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex))
acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. 2001-05-30 Benjamin Kosnik <bkoz@redat.com> * acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. (_GLIBCPP_BUGGY_COMPLEX): Remove. * config.h.in: Regenerate. * acinclude.m4 (GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT): Remove. * aclocal.m4: Regenerate. * configure.in: Don't call it. * configure: Regenerate. libstdc++/2970 * src/complex_io.cc (operator<<(ostream&, const complex&): Fix. * testsuite/26_numerics/complex_inserters_extractors.cc (test01): New test. libstdc++/2985 * include/bits/std_complex.h: Include sstream. Put definitions for complex inserters and extractors here, and remove them from... * src/complex_io.cc: ...here. * include/bits/basic_ios.h (basic_ios::__numput_type): Add _Traits parameter. (basic_ios::__numget_type): Same. * include/bits/std_istream.h: Same. * include/bits/std_ostream.h: Same. * include/bits/sbuf_iter.h (ostreambuf_iterator): Fix typo in base class iterator template arguments. * src/locale-inst.cc: Add explicit has_facet instantiations. * include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove. (_M_get_fnumput): Remove. (_M_get_fnumget): Remove. (basic_ios::_M_check_facet): New function. (basic_ios::_M_cache_facets): New function. * include/bits/basic_ios.tcc: Definition for _M_cache_facets. (basic_ios::imbue): Call _M_cache_facets. (basic_ios::init): Same. * include/bits/istream.tcc: Format, use _M_check_facet. * include/bits/ostream.tcc: Same. * include/bits/locale_facets.tcc (__output_float): Change signature, add _Traits. * testsuite/26_numerics/complex_inserters_extractors.cc (test02): New test. From-SVN: r42743
2001-05-31 14:14:56 +02:00
{
const unsigned long long __l = (static_cast<
unsigned long long>(__n));
__b = __np.put(*this, *this, __c, __l).failed();
acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. 2001-05-30 Benjamin Kosnik <bkoz@redat.com> * acconfig.h (_GLIBCPP_BUGGY_FLOAT_COMPLEX): Remove. (_GLIBCPP_BUGGY_COMPLEX): Remove. * config.h.in: Regenerate. * acinclude.m4 (GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT): Remove. * aclocal.m4: Regenerate. * configure.in: Don't call it. * configure: Regenerate. libstdc++/2970 * src/complex_io.cc (operator<<(ostream&, const complex&): Fix. * testsuite/26_numerics/complex_inserters_extractors.cc (test01): New test. libstdc++/2985 * include/bits/std_complex.h: Include sstream. Put definitions for complex inserters and extractors here, and remove them from... * src/complex_io.cc: ...here. * include/bits/basic_ios.h (basic_ios::__numput_type): Add _Traits parameter. (basic_ios::__numget_type): Same. * include/bits/std_istream.h: Same. * include/bits/std_ostream.h: Same. * include/bits/sbuf_iter.h (ostreambuf_iterator): Fix typo in base class iterator template arguments. * src/locale-inst.cc: Add explicit has_facet instantiations. * include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove. (_M_get_fnumput): Remove. (_M_get_fnumget): Remove. (basic_ios::_M_check_facet): New function. (basic_ios::_M_cache_facets): New function. * include/bits/basic_ios.tcc: Definition for _M_cache_facets. (basic_ios::imbue): Call _M_cache_facets. (basic_ios::init): Same. * include/bits/istream.tcc: Format, use _M_check_facet. * include/bits/ostream.tcc: Same. * include/bits/locale_facets.tcc (__output_float): Change signature, add _Traits. * testsuite/26_numerics/complex_inserters_extractors.cc (test02): New test. From-SVN: r42743
2001-05-31 14:14:56 +02:00
}
else
__b = __np.put(*this, *this, __c, __n).failed();
if (__b)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(unsigned long long __n)
{
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_put_type& __np = __check_facet(this->_M_num_put);
if (__np.put(*this, *this, this->fill(), __n).failed())
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
#endif
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(double __n)
{
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_put_type& __np = __check_facet(this->_M_num_put);
if (__np.put(*this, *this, this->fill(), __n).failed())
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(long double __n)
{
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_put_type& __np = __check_facet(this->_M_num_put);
if (__np.put(*this, *this, this->fill(), __n).failed())
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(const void* __n)
{
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const __num_put_type& __np = __check_facet(this->_M_num_put);
if (__np.put(*this, *this, this->fill(), __n).failed())
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
operator<<(__streambuf_type* __sbin)
{
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
sentry __cerb(*this);
if (__cerb && __sbin)
{
try
{
if (!__copy_streambufs(__sbin, this->rdbuf()))
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::failbit;
}
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
catch(...)
{ this->_M_setstate(ios_base::failbit); }
}
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
else if (!__sbin)
__err |= ios_base::badbit;
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
put(char_type __c)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::put(char_type) is an unformatted output function.
// DR 63. Exception-handling policy for unformatted output.
// Unformatted output functions should catch exceptions thrown
// from streambuf members.
sentry __cerb(*this);
if (__cerb)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
const int_type __put = this->rdbuf()->sputc(__c);
if (traits_type::eq_int_type(__put, traits_type::eof()))
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
__err |= ios_base::badbit;
}
catch (...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
write(const _CharT* __s, streamsize __n)
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::write(const char_type*, streamsize) is an
// unformatted output function.
// DR 63. Exception-handling policy for unformatted output.
// Unformatted output functions should catch exceptions thrown
// from streambuf members.
sentry __cerb(*this);
if (__cerb)
{
try
{ _M_write(__s, __n); }
catch (...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ this->_M_setstate(ios_base::badbit); }
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
flush()
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// DR 60. What is a formatted input function?
// basic_ostream::flush() is *not* an unformatted output function.
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
if (this->rdbuf() && this->rdbuf()->pubsync() == -1)
__err |= ios_base::badbit;
}
catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
typename basic_ostream<_CharT, _Traits>::pos_type
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
tellp()
{
pos_type __ret = pos_type(-1);
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
try
{
if (!this->fail())
__ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
}
catch(...)
{ this->_M_setstate(ios_base::badbit); }
return __ret;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
basic_ostream<_CharT, _Traits>::
seekp(pos_type __pos)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
if (!this->fail())
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 136. seekp, seekg setting wrong streams?
const pos_type __p = this->rdbuf()->pubseekpos(__pos,
ios_base::out);
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
// 129. Need error indication from seekp() and seekg()
if (__p == pos_type(off_type(-1)))
__err |= ios_base::failbit;
}
}
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
seekp(off_type __off, ios_base::seekdir __dir)
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
ios_base::iostate __err = ios_base::iostate(ios_base::goodbit);
try
{
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
if (!this->fail())
{
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 136. seekp, seekg setting wrong streams?
const pos_type __p = this->rdbuf()->pubseekoff(__off, __dir,
ios_base::out);
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
// 129. Need error indication from seekp() and seekg()
if (__p == pos_type(off_type(-1)))
__err |= ios_base::failbit;
}
}
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
catch(...)
{ this->_M_setstate(ios_base::badbit); }
if (__err)
this->setstate(__err);
return *this;
}
num_put_members_wchar_t.cc (test03): Use _GLIBCPP_HAVE_SETENV. 2002-01-24 Benjamin Kosnik <bkoz@redhat.com> * testsuite/22_locale/num_put_members_wchar_t.cc (test03): Use _GLIBCPP_HAVE_SETENV. * testsuite/22_locale/codecvt_members_wchar_t_char.cc (test02): Same. * testsuite/22_locale/collate_members_char.cc (test02): Same. * testsuite/22_locale/ctype_members_char.cc (test03): Same. * testsuite/22_locale/ctype_members_wchar_t.cc (test03): Same. * testsuite/22_locale/messages_members_char.cc (test02): Same. * testsuite/22_locale/moneypunct_members_char.cc (test02): Same. * testsuite/22_locale/moneypunct_members_wchar_t.cc (test02): Same. * testsuite/22_locale/money_put_members_char.cc (test04): Same. * testsuite/22_locale/money_put_members_wchar_t.cc (test04): Same. * testsuite/22_locale/num_get_members_char.cc (test03): Same. * testsuite/22_locale/num_get_members_wchar_t.cc (test03): Same. * testsuite/22_locale/numpunct_members_char.cc (test02): Same. * testsuite/22_locale/numpunct_members_wchar_t.cc (test02): Same. * testsuite/22_locale/time_get_members_char.cc (test07): Same. * testsuite/22_locale/time_get_members_wchar_t.cc (test07): Same. * testsuite/22_locale/time_put_members_char.cc (test03): Same. * testsuite/22_locale/time_put_members_wchar_t.cc (test03): Same. * testsuite/22_locale/num_put_members_char.cc (test03): Same. * acinclude.m4 (GLIBCPP_CONFIGURE_TESTSUITE): Check for setenv. * aclocal.m4: Regenerate. * configure: Regenerate. * config.h.in: Regenerate. From-SVN: r49191
2002-01-24 21:46:34 +01:00
// 27.6.2.5.4 Character inserters.
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
{
typedef basic_ostream<_CharT, _Traits> __ostream_type;
typename __ostream_type::sentry __cerb(__out);
if (__cerb)
{
try
{
const streamsize __w = __out.width();
streamsize __len = 1;
_CharT* __cs = &__c;
if (__w > __len)
{
__cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w));
__pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs,
char_traits.h: Remove generic definitions. 2002-07-30 Benjamin Kosnik <bkoz@redhat.com> Gabriel Dos Reis <gdr@nerim.net> * include/bits/char_traits.h: Remove generic definitions. * include/bits/streambuf_iterator.h (istreambuf_iterator): Use eof, not -2. * include/bits/istream.tcc (istream::readsome): Don't check against eof, instead use constants. (istream::sync): Same. (istream::sentry::sentry): Use eq_int_type. (istream::get): Same. * include/bits/ostream.tcc: Change __pad to __pad<_CharT, _Traits>::_S_pad. * include/bits/locale_facets.h: Add __pad_traits generic and ostreambuf_iterator specialization. * include/bits/locale_facets.tcc: Change __pad into struct __pad with a _CharT and _Traits template parameter and _S_pad static member function. * src/locale-inst.cc: Update __pad instantiations. * include/std/std_fstream.h: Declare _M_underflow_common specializations. * src/fstream.cc: New. Add _M_underflow_common specializations. * include/bits/fstream.tcc (filebuf::close): Use traits_type. (filebuf::_M_underflow_common(bool)): Remove generic version, as sys_ungetc and custom int_types don't get along. * include/std/std_streambuf.h: Add _M_pos. * src/Makefile.am (sources): Add fstream.cc. * src/Makefile.in: Regenerate. * testsuite/21_strings/capacity.cc: Add char_traits specializations. * testsuite/22_locale/codecvt_members_unicode_char.cc: Same. * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same. * testsuite/22_locale/ctor_copy_dtor.cc: Same. * testsuite/27_io/filebuf_virtuals.cc (test07): Move to... * testsuite/27_io/filebuf.cc: ...here. * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits specialization for both. * testsuite/27_io/streambuf.cc: Add instantiation test, testsuite_hooks include. * testsuite/27_io/istream.cc: Same. * testsuite/27_io/ostream.cc: Same. * testsuite/27_io/fstream.cc: Same. * testsuite/27_io/stringstream.cc: Same. * testsuite/27_io/filebuf.cc: Same. * testsuite/27_io/stringbuf.cc: Same. Co-Authored-By: Gabriel Dos Reis <gdr@nerim.net> From-SVN: r55893
2002-07-31 04:47:36 +02:00
&__c, __w, __len, false);
__len = __w;
}
__out._M_write(__cs, __len);
__out.width(0);
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ __out._M_setstate(ios_base::badbit); }
}
return __out;
}
num_put_members_wchar_t.cc (test03): Use _GLIBCPP_HAVE_SETENV. 2002-01-24 Benjamin Kosnik <bkoz@redhat.com> * testsuite/22_locale/num_put_members_wchar_t.cc (test03): Use _GLIBCPP_HAVE_SETENV. * testsuite/22_locale/codecvt_members_wchar_t_char.cc (test02): Same. * testsuite/22_locale/collate_members_char.cc (test02): Same. * testsuite/22_locale/ctype_members_char.cc (test03): Same. * testsuite/22_locale/ctype_members_wchar_t.cc (test03): Same. * testsuite/22_locale/messages_members_char.cc (test02): Same. * testsuite/22_locale/moneypunct_members_char.cc (test02): Same. * testsuite/22_locale/moneypunct_members_wchar_t.cc (test02): Same. * testsuite/22_locale/money_put_members_char.cc (test04): Same. * testsuite/22_locale/money_put_members_wchar_t.cc (test04): Same. * testsuite/22_locale/num_get_members_char.cc (test03): Same. * testsuite/22_locale/num_get_members_wchar_t.cc (test03): Same. * testsuite/22_locale/numpunct_members_char.cc (test02): Same. * testsuite/22_locale/numpunct_members_wchar_t.cc (test02): Same. * testsuite/22_locale/time_get_members_char.cc (test07): Same. * testsuite/22_locale/time_get_members_wchar_t.cc (test07): Same. * testsuite/22_locale/time_put_members_char.cc (test03): Same. * testsuite/22_locale/time_put_members_wchar_t.cc (test03): Same. * testsuite/22_locale/num_put_members_char.cc (test03): Same. * acinclude.m4 (GLIBCPP_CONFIGURE_TESTSUITE): Check for setenv. * aclocal.m4: Regenerate. * configure: Regenerate. * config.h.in: Regenerate. From-SVN: r49191
2002-01-24 21:46:34 +01:00
// Specializations.
template <class _Traits>
basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __out, char __c)
{
typedef basic_ostream<char, _Traits> __ostream_type;
typename __ostream_type::sentry __cerb(__out);
if (__cerb)
{
try
{
const streamsize __w = __out.width();
streamsize __len = 1;
char* __cs = &__c;
if (__w > __len)
{
__cs = static_cast<char*>(__builtin_alloca(__w));
__pad<char, _Traits>::_S_pad(__out, __out.fill(), __cs,
char_traits.h: Remove generic definitions. 2002-07-30 Benjamin Kosnik <bkoz@redhat.com> Gabriel Dos Reis <gdr@nerim.net> * include/bits/char_traits.h: Remove generic definitions. * include/bits/streambuf_iterator.h (istreambuf_iterator): Use eof, not -2. * include/bits/istream.tcc (istream::readsome): Don't check against eof, instead use constants. (istream::sync): Same. (istream::sentry::sentry): Use eq_int_type. (istream::get): Same. * include/bits/ostream.tcc: Change __pad to __pad<_CharT, _Traits>::_S_pad. * include/bits/locale_facets.h: Add __pad_traits generic and ostreambuf_iterator specialization. * include/bits/locale_facets.tcc: Change __pad into struct __pad with a _CharT and _Traits template parameter and _S_pad static member function. * src/locale-inst.cc: Update __pad instantiations. * include/std/std_fstream.h: Declare _M_underflow_common specializations. * src/fstream.cc: New. Add _M_underflow_common specializations. * include/bits/fstream.tcc (filebuf::close): Use traits_type. (filebuf::_M_underflow_common(bool)): Remove generic version, as sys_ungetc and custom int_types don't get along. * include/std/std_streambuf.h: Add _M_pos. * src/Makefile.am (sources): Add fstream.cc. * src/Makefile.in: Regenerate. * testsuite/21_strings/capacity.cc: Add char_traits specializations. * testsuite/22_locale/codecvt_members_unicode_char.cc: Same. * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same. * testsuite/22_locale/ctor_copy_dtor.cc: Same. * testsuite/27_io/filebuf_virtuals.cc (test07): Move to... * testsuite/27_io/filebuf.cc: ...here. * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits specialization for both. * testsuite/27_io/streambuf.cc: Add instantiation test, testsuite_hooks include. * testsuite/27_io/istream.cc: Same. * testsuite/27_io/ostream.cc: Same. * testsuite/27_io/fstream.cc: Same. * testsuite/27_io/stringstream.cc: Same. * testsuite/27_io/filebuf.cc: Same. * testsuite/27_io/stringbuf.cc: Same. Co-Authored-By: Gabriel Dos Reis <gdr@nerim.net> From-SVN: r55893
2002-07-31 04:47:36 +02:00
&__c, __w, __len, false);
__len = __w;
}
__out._M_write(__cs, __len);
__out.width(0);
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ __out._M_setstate(ios_base::badbit); }
}
return __out;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
{
typedef basic_ostream<_CharT, _Traits> __ostream_type;
typename __ostream_type::sentry __cerb(__out);
if (__cerb && __s)
{
try
{
const streamsize __w = __out.width();
streamsize __len = static_cast<streamsize>(_Traits::length(__s));
if (__w > __len)
{
_CharT* __cs = (static_cast<
_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w)));
__pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs,
char_traits.h: Remove generic definitions. 2002-07-30 Benjamin Kosnik <bkoz@redhat.com> Gabriel Dos Reis <gdr@nerim.net> * include/bits/char_traits.h: Remove generic definitions. * include/bits/streambuf_iterator.h (istreambuf_iterator): Use eof, not -2. * include/bits/istream.tcc (istream::readsome): Don't check against eof, instead use constants. (istream::sync): Same. (istream::sentry::sentry): Use eq_int_type. (istream::get): Same. * include/bits/ostream.tcc: Change __pad to __pad<_CharT, _Traits>::_S_pad. * include/bits/locale_facets.h: Add __pad_traits generic and ostreambuf_iterator specialization. * include/bits/locale_facets.tcc: Change __pad into struct __pad with a _CharT and _Traits template parameter and _S_pad static member function. * src/locale-inst.cc: Update __pad instantiations. * include/std/std_fstream.h: Declare _M_underflow_common specializations. * src/fstream.cc: New. Add _M_underflow_common specializations. * include/bits/fstream.tcc (filebuf::close): Use traits_type. (filebuf::_M_underflow_common(bool)): Remove generic version, as sys_ungetc and custom int_types don't get along. * include/std/std_streambuf.h: Add _M_pos. * src/Makefile.am (sources): Add fstream.cc. * src/Makefile.in: Regenerate. * testsuite/21_strings/capacity.cc: Add char_traits specializations. * testsuite/22_locale/codecvt_members_unicode_char.cc: Same. * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same. * testsuite/22_locale/ctor_copy_dtor.cc: Same. * testsuite/27_io/filebuf_virtuals.cc (test07): Move to... * testsuite/27_io/filebuf.cc: ...here. * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits specialization for both. * testsuite/27_io/streambuf.cc: Add instantiation test, testsuite_hooks include. * testsuite/27_io/istream.cc: Same. * testsuite/27_io/ostream.cc: Same. * testsuite/27_io/fstream.cc: Same. * testsuite/27_io/stringstream.cc: Same. * testsuite/27_io/filebuf.cc: Same. * testsuite/27_io/stringbuf.cc: Same. Co-Authored-By: Gabriel Dos Reis <gdr@nerim.net> From-SVN: r55893
2002-07-31 04:47:36 +02:00
__s, __w, __len, false);
__s = __cs;
__len = __w;
}
__out._M_write(__s, __len);
__out.width(0);
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ __out._M_setstate(ios_base::badbit); }
}
else if (!__s)
__out.setstate(ios_base::badbit);
return __out;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
{
typedef basic_ostream<_CharT, _Traits> __ostream_type;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 167. Improper use of traits_type::length()
// Note that this is only in 'Review' status.
typedef char_traits<char> __traits_type;
typename __ostream_type::sentry __cerb(__out);
if (__cerb && __s)
{
size_t __clen = __traits_type::length(__s);
_CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __clen));
for (size_t __i = 0; __i < __clen; ++__i)
__ws[__i] = __out.widen(__s[__i]);
_CharT* __str = __ws;
try
{
const streamsize __w = __out.width();
streamsize __len = static_cast<streamsize>(__clen);
if (__w > __len)
{
_CharT* __cs = (static_cast<
_CharT*>(__builtin_alloca(sizeof(_CharT)
* __w)));
__pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs,
char_traits.h: Remove generic definitions. 2002-07-30 Benjamin Kosnik <bkoz@redhat.com> Gabriel Dos Reis <gdr@nerim.net> * include/bits/char_traits.h: Remove generic definitions. * include/bits/streambuf_iterator.h (istreambuf_iterator): Use eof, not -2. * include/bits/istream.tcc (istream::readsome): Don't check against eof, instead use constants. (istream::sync): Same. (istream::sentry::sentry): Use eq_int_type. (istream::get): Same. * include/bits/ostream.tcc: Change __pad to __pad<_CharT, _Traits>::_S_pad. * include/bits/locale_facets.h: Add __pad_traits generic and ostreambuf_iterator specialization. * include/bits/locale_facets.tcc: Change __pad into struct __pad with a _CharT and _Traits template parameter and _S_pad static member function. * src/locale-inst.cc: Update __pad instantiations. * include/std/std_fstream.h: Declare _M_underflow_common specializations. * src/fstream.cc: New. Add _M_underflow_common specializations. * include/bits/fstream.tcc (filebuf::close): Use traits_type. (filebuf::_M_underflow_common(bool)): Remove generic version, as sys_ungetc and custom int_types don't get along. * include/std/std_streambuf.h: Add _M_pos. * src/Makefile.am (sources): Add fstream.cc. * src/Makefile.in: Regenerate. * testsuite/21_strings/capacity.cc: Add char_traits specializations. * testsuite/22_locale/codecvt_members_unicode_char.cc: Same. * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same. * testsuite/22_locale/ctor_copy_dtor.cc: Same. * testsuite/27_io/filebuf_virtuals.cc (test07): Move to... * testsuite/27_io/filebuf.cc: ...here. * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits specialization for both. * testsuite/27_io/streambuf.cc: Add instantiation test, testsuite_hooks include. * testsuite/27_io/istream.cc: Same. * testsuite/27_io/ostream.cc: Same. * testsuite/27_io/fstream.cc: Same. * testsuite/27_io/stringstream.cc: Same. * testsuite/27_io/filebuf.cc: Same. * testsuite/27_io/stringbuf.cc: Same. Co-Authored-By: Gabriel Dos Reis <gdr@nerim.net> From-SVN: r55893
2002-07-31 04:47:36 +02:00
__ws, __w, __len, false);
__str = __cs;
__len = __w;
}
__out._M_write(__str, __len);
__out.width(0);
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ __out._M_setstate(ios_base::badbit); }
}
else if (!__s)
__out.setstate(ios_base::badbit);
return __out;
}
num_put_members_wchar_t.cc (test03): Use _GLIBCPP_HAVE_SETENV. 2002-01-24 Benjamin Kosnik <bkoz@redhat.com> * testsuite/22_locale/num_put_members_wchar_t.cc (test03): Use _GLIBCPP_HAVE_SETENV. * testsuite/22_locale/codecvt_members_wchar_t_char.cc (test02): Same. * testsuite/22_locale/collate_members_char.cc (test02): Same. * testsuite/22_locale/ctype_members_char.cc (test03): Same. * testsuite/22_locale/ctype_members_wchar_t.cc (test03): Same. * testsuite/22_locale/messages_members_char.cc (test02): Same. * testsuite/22_locale/moneypunct_members_char.cc (test02): Same. * testsuite/22_locale/moneypunct_members_wchar_t.cc (test02): Same. * testsuite/22_locale/money_put_members_char.cc (test04): Same. * testsuite/22_locale/money_put_members_wchar_t.cc (test04): Same. * testsuite/22_locale/num_get_members_char.cc (test03): Same. * testsuite/22_locale/num_get_members_wchar_t.cc (test03): Same. * testsuite/22_locale/numpunct_members_char.cc (test02): Same. * testsuite/22_locale/numpunct_members_wchar_t.cc (test02): Same. * testsuite/22_locale/time_get_members_char.cc (test07): Same. * testsuite/22_locale/time_get_members_wchar_t.cc (test07): Same. * testsuite/22_locale/time_put_members_char.cc (test03): Same. * testsuite/22_locale/time_put_members_wchar_t.cc (test03): Same. * testsuite/22_locale/num_put_members_char.cc (test03): Same. * acinclude.m4 (GLIBCPP_CONFIGURE_TESTSUITE): Check for setenv. * aclocal.m4: Regenerate. * configure: Regenerate. * config.h.in: Regenerate. From-SVN: r49191
2002-01-24 21:46:34 +01:00
// Partial specializations.
template<class _Traits>
basic_ostream<char, _Traits>&
operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
{
typedef basic_ostream<char, _Traits> __ostream_type;
typename __ostream_type::sentry __cerb(__out);
if (__cerb && __s)
{
try
{
const streamsize __w = __out.width();
streamsize __len = static_cast<streamsize>(_Traits::length(__s));
if (__w > __len)
{
char* __cs = static_cast<char*>(__builtin_alloca(__w));
__pad<char, _Traits>::_S_pad(__out, __out.fill(), __cs,
char_traits.h: Remove generic definitions. 2002-07-30 Benjamin Kosnik <bkoz@redhat.com> Gabriel Dos Reis <gdr@nerim.net> * include/bits/char_traits.h: Remove generic definitions. * include/bits/streambuf_iterator.h (istreambuf_iterator): Use eof, not -2. * include/bits/istream.tcc (istream::readsome): Don't check against eof, instead use constants. (istream::sync): Same. (istream::sentry::sentry): Use eq_int_type. (istream::get): Same. * include/bits/ostream.tcc: Change __pad to __pad<_CharT, _Traits>::_S_pad. * include/bits/locale_facets.h: Add __pad_traits generic and ostreambuf_iterator specialization. * include/bits/locale_facets.tcc: Change __pad into struct __pad with a _CharT and _Traits template parameter and _S_pad static member function. * src/locale-inst.cc: Update __pad instantiations. * include/std/std_fstream.h: Declare _M_underflow_common specializations. * src/fstream.cc: New. Add _M_underflow_common specializations. * include/bits/fstream.tcc (filebuf::close): Use traits_type. (filebuf::_M_underflow_common(bool)): Remove generic version, as sys_ungetc and custom int_types don't get along. * include/std/std_streambuf.h: Add _M_pos. * src/Makefile.am (sources): Add fstream.cc. * src/Makefile.in: Regenerate. * testsuite/21_strings/capacity.cc: Add char_traits specializations. * testsuite/22_locale/codecvt_members_unicode_char.cc: Same. * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same. * testsuite/22_locale/ctor_copy_dtor.cc: Same. * testsuite/27_io/filebuf_virtuals.cc (test07): Move to... * testsuite/27_io/filebuf.cc: ...here. * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits specialization for both. * testsuite/27_io/streambuf.cc: Add instantiation test, testsuite_hooks include. * testsuite/27_io/istream.cc: Same. * testsuite/27_io/ostream.cc: Same. * testsuite/27_io/fstream.cc: Same. * testsuite/27_io/stringstream.cc: Same. * testsuite/27_io/filebuf.cc: Same. * testsuite/27_io/stringbuf.cc: Same. Co-Authored-By: Gabriel Dos Reis <gdr@nerim.net> From-SVN: r55893
2002-07-31 04:47:36 +02:00
__s, __w, __len, false);
__s = __cs;
__len = __w;
}
__out._M_write(__s, __len);
__out.width(0);
}
catch(...)
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
{ __out._M_setstate(ios_base::badbit); }
}
else if (!__s)
__out.setstate(ios_base::badbit);
return __out;
}
// 21.3.7.9 basic_string::operator<<
template<typename _CharT, typename _Traits, typename _Alloc>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __out,
const basic_string<_CharT, _Traits, _Alloc>& __str)
{
typedef basic_ostream<_CharT, _Traits> __ostream_type;
typename __ostream_type::sentry __cerb(__out);
if (__cerb)
{
const streamsize __w = __out.width();
streamsize __len = static_cast<streamsize>(__str.size());
const _CharT* __s = __str.data();
re PR libstdc++/9371 (Bad exception handling in i/ostream::operator>>/<<(streambuf*)) 2003-11-26 Benjamin Kosnik <bkoz@redhat.com> PR libstdc++/9371 PR libstdc++/9546 PR libstdc++/10093 PR libstdc++/10095 * include/bits/basic_ios.h (basic_ios::setstate): Elide if goodbit. (basic_ios::_M_setstate): Consolidate common error handling code. * include/bits/basic_ios.tcc: Tweak. * include/bits/fstream.tcc: Tweak. * include/bits/istream.tcc: Use _M_setstate for common exception handling. Move setstate calls after catch. (basic_istream::tellg): Check for exceptions thrown by streambuf virtual functions. (basic_istream::seekg): Same. * include/bits/ostream.tcc: Same, but for ostream. (basic_ostream::flush): Check for exceptions thrown by streambuf virtual functions. (basic_istream::tellp): Same. (basic_istream::seekp): Same. * include/bits/locale_facets.tcc: Tweak. * include/bits/streambuf.tcc: Tweak. (__copy_streambufs): Propagate exceptions. * testsuite/testsuite_io.h (fail_streambuf): New. (fail_num_get): New. (fail_num_put): New. (facet_error): New. (underflow_error): New. (overflow_error): New. (positioning_error): New. * testsuite/27_io/basic_istream/exceptions/char/9561.cc: Tweak. * testsuite/27_io/basic_istream/extractors_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_istream/extractors_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_arithmetic/char/ exceptions_badbit_throw.cc, exceptions_failbit_throw.cc: New. * testsuite/27_io/basic_ostream/inserters_other/char/ error_failbit.cc, exceptions_badbit_throw.cc, exceptions_failbit_throw.cc, exceptions_null.cc: New. * testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc: New. * testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc: New. From-SVN: r73979
2003-11-27 09:14:25 +01:00
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 25. String operator<< uses width() value wrong
if (__w > __len)
{
_CharT* __cs = (static_cast<
_CharT*>(__builtin_alloca(sizeof(_CharT) * __w)));
__pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __cs, __s,
char_traits.h: Remove generic definitions. 2002-07-30 Benjamin Kosnik <bkoz@redhat.com> Gabriel Dos Reis <gdr@nerim.net> * include/bits/char_traits.h: Remove generic definitions. * include/bits/streambuf_iterator.h (istreambuf_iterator): Use eof, not -2. * include/bits/istream.tcc (istream::readsome): Don't check against eof, instead use constants. (istream::sync): Same. (istream::sentry::sentry): Use eq_int_type. (istream::get): Same. * include/bits/ostream.tcc: Change __pad to __pad<_CharT, _Traits>::_S_pad. * include/bits/locale_facets.h: Add __pad_traits generic and ostreambuf_iterator specialization. * include/bits/locale_facets.tcc: Change __pad into struct __pad with a _CharT and _Traits template parameter and _S_pad static member function. * src/locale-inst.cc: Update __pad instantiations. * include/std/std_fstream.h: Declare _M_underflow_common specializations. * src/fstream.cc: New. Add _M_underflow_common specializations. * include/bits/fstream.tcc (filebuf::close): Use traits_type. (filebuf::_M_underflow_common(bool)): Remove generic version, as sys_ungetc and custom int_types don't get along. * include/std/std_streambuf.h: Add _M_pos. * src/Makefile.am (sources): Add fstream.cc. * src/Makefile.in: Regenerate. * testsuite/21_strings/capacity.cc: Add char_traits specializations. * testsuite/22_locale/codecvt_members_unicode_char.cc: Same. * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same. * testsuite/22_locale/ctor_copy_dtor.cc: Same. * testsuite/27_io/filebuf_virtuals.cc (test07): Move to... * testsuite/27_io/filebuf.cc: ...here. * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits specialization for both. * testsuite/27_io/streambuf.cc: Add instantiation test, testsuite_hooks include. * testsuite/27_io/istream.cc: Same. * testsuite/27_io/ostream.cc: Same. * testsuite/27_io/fstream.cc: Same. * testsuite/27_io/stringstream.cc: Same. * testsuite/27_io/filebuf.cc: Same. * testsuite/27_io/stringbuf.cc: Same. Co-Authored-By: Gabriel Dos Reis <gdr@nerim.net> From-SVN: r55893
2002-07-31 04:47:36 +02:00
__w, __len, false);
__s = __cs;
__len = __w;
}
__out._M_write(__s, __len);
__out.width(0);
}
return __out;
}
Tune for size. 2002-02-15 Benjamin Kosnik <bkoz@redhat.com> Tune for size. * src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant explicit instantiation. (string::_Rep::_S_max_size): Same. * include/bits/basic_string.tcc: Add extern explicit instantiations for string, wstring. * include/bits/basic_ios.tcc: Add extern explicit instantiations for ios, wios. * include/bits/streambuf.tcc: Same, for streambuf, wstreambuf. * include/bits/istream.tcc: Same, for istream, wistream. * include/bits/ostream.tcc: Same for ostream, wostream, iostream, wiostream. * include/bits/sstream.tcc: Same, for stringbuf, wstringbuf, istringstream, wistringstream, ostringstream, wostringstream, stringstream, wstringstream. * include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream, wifstream, ofstream, wofstream, fstream, wfstream. * src/misc-inst.cc: Correct comments. Add iomanip instantiations for wide streams. * include/std/std_iomanip.h: Same. * include/bits/locale_facets.tcc: Same. * include/std/std_streambuf.h: Correct _GLIBCPP_FULLY_COMPLIANT_HEADERS guard. * include/std/std_sstream.h: Same. * include/std/std_ostream.h: Same. * include/std/std_istream.h: Same. * include/std/std_fstream.h: Same. * include/std/std_streambuf.h: Add definitions for private copy ctor and assignment operator. * include/std/std_istream.h: Remove declared but undefined copy ctor and assignment operator. This is taken care of in ios_base, so adding it in the derived class as well is superfluous. * include/std/std_ostream.h: Same. * include/bits/basic_ios.h (basic_ios::clear): Don't inline. * include/bits/basic_ios.tcc (basic_ios::clear): Move definition here. From-SVN: r49798
2002-02-16 01:19:13 +01:00
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
Tune for size. 2002-02-15 Benjamin Kosnik <bkoz@redhat.com> Tune for size. * src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant explicit instantiation. (string::_Rep::_S_max_size): Same. * include/bits/basic_string.tcc: Add extern explicit instantiations for string, wstring. * include/bits/basic_ios.tcc: Add extern explicit instantiations for ios, wios. * include/bits/streambuf.tcc: Same, for streambuf, wstreambuf. * include/bits/istream.tcc: Same, for istream, wistream. * include/bits/ostream.tcc: Same for ostream, wostream, iostream, wiostream. * include/bits/sstream.tcc: Same, for stringbuf, wstringbuf, istringstream, wistringstream, ostringstream, wostringstream, stringstream, wstringstream. * include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream, wifstream, ofstream, wofstream, fstream, wfstream. * src/misc-inst.cc: Correct comments. Add iomanip instantiations for wide streams. * include/std/std_iomanip.h: Same. * include/bits/locale_facets.tcc: Same. * include/std/std_streambuf.h: Correct _GLIBCPP_FULLY_COMPLIANT_HEADERS guard. * include/std/std_sstream.h: Same. * include/std/std_ostream.h: Same. * include/std/std_istream.h: Same. * include/std/std_fstream.h: Same. * include/std/std_streambuf.h: Add definitions for private copy ctor and assignment operator. * include/std/std_istream.h: Remove declared but undefined copy ctor and assignment operator. This is taken care of in ios_base, so adding it in the derived class as well is superfluous. * include/std/std_ostream.h: Same. * include/bits/basic_ios.h (basic_ios::clear): Don't inline. * include/bits/basic_ios.tcc (basic_ios::clear): Move definition here. From-SVN: r49798
2002-02-16 01:19:13 +01:00
// NB: This syntax is a GNU extension.
#if _GLIBCXX_EXTERN_TEMPLATE
Tune for size. 2002-02-15 Benjamin Kosnik <bkoz@redhat.com> Tune for size. * src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant explicit instantiation. (string::_Rep::_S_max_size): Same. * include/bits/basic_string.tcc: Add extern explicit instantiations for string, wstring. * include/bits/basic_ios.tcc: Add extern explicit instantiations for ios, wios. * include/bits/streambuf.tcc: Same, for streambuf, wstreambuf. * include/bits/istream.tcc: Same, for istream, wistream. * include/bits/ostream.tcc: Same for ostream, wostream, iostream, wiostream. * include/bits/sstream.tcc: Same, for stringbuf, wstringbuf, istringstream, wistringstream, ostringstream, wostringstream, stringstream, wstringstream. * include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream, wifstream, ofstream, wofstream, fstream, wfstream. * src/misc-inst.cc: Correct comments. Add iomanip instantiations for wide streams. * include/std/std_iomanip.h: Same. * include/bits/locale_facets.tcc: Same. * include/std/std_streambuf.h: Correct _GLIBCPP_FULLY_COMPLIANT_HEADERS guard. * include/std/std_sstream.h: Same. * include/std/std_ostream.h: Same. * include/std/std_istream.h: Same. * include/std/std_fstream.h: Same. * include/std/std_streambuf.h: Add definitions for private copy ctor and assignment operator. * include/std/std_istream.h: Remove declared but undefined copy ctor and assignment operator. This is taken care of in ios_base, so adding it in the derived class as well is superfluous. * include/std/std_ostream.h: Same. * include/bits/basic_ios.h (basic_ios::clear): Don't inline. * include/bits/basic_ios.tcc (basic_ios::clear): Move definition here. From-SVN: r49798
2002-02-16 01:19:13 +01:00
extern template class basic_ostream<char>;
extern template ostream& endl(ostream&);
extern template ostream& ends(ostream&);
extern template ostream& flush(ostream&);
extern template ostream& operator<<(ostream&, char);
extern template ostream& operator<<(ostream&, unsigned char);
extern template ostream& operator<<(ostream&, signed char);
extern template ostream& operator<<(ostream&, const char*);
extern template ostream& operator<<(ostream&, const unsigned char*);
extern template ostream& operator<<(ostream&, const signed char*);
#ifdef _GLIBCXX_USE_WCHAR_T
Tune for size. 2002-02-15 Benjamin Kosnik <bkoz@redhat.com> Tune for size. * src/string-inst.cc (string::_Rep::_S_terminal): Remove redundant explicit instantiation. (string::_Rep::_S_max_size): Same. * include/bits/basic_string.tcc: Add extern explicit instantiations for string, wstring. * include/bits/basic_ios.tcc: Add extern explicit instantiations for ios, wios. * include/bits/streambuf.tcc: Same, for streambuf, wstreambuf. * include/bits/istream.tcc: Same, for istream, wistream. * include/bits/ostream.tcc: Same for ostream, wostream, iostream, wiostream. * include/bits/sstream.tcc: Same, for stringbuf, wstringbuf, istringstream, wistringstream, ostringstream, wostringstream, stringstream, wstringstream. * include/bits/fstream.tcc: Same, for filebuf, wfilebuf, ifstream, wifstream, ofstream, wofstream, fstream, wfstream. * src/misc-inst.cc: Correct comments. Add iomanip instantiations for wide streams. * include/std/std_iomanip.h: Same. * include/bits/locale_facets.tcc: Same. * include/std/std_streambuf.h: Correct _GLIBCPP_FULLY_COMPLIANT_HEADERS guard. * include/std/std_sstream.h: Same. * include/std/std_ostream.h: Same. * include/std/std_istream.h: Same. * include/std/std_fstream.h: Same. * include/std/std_streambuf.h: Add definitions for private copy ctor and assignment operator. * include/std/std_istream.h: Remove declared but undefined copy ctor and assignment operator. This is taken care of in ios_base, so adding it in the derived class as well is superfluous. * include/std/std_ostream.h: Same. * include/bits/basic_ios.h (basic_ios::clear): Don't inline. * include/bits/basic_ios.tcc (basic_ios::clear): Move definition here. From-SVN: r49798
2002-02-16 01:19:13 +01:00
extern template class basic_ostream<wchar_t>;
extern template wostream& endl(wostream&);
extern template wostream& ends(wostream&);
extern template wostream& flush(wostream&);
extern template wostream& operator<<(wostream&, wchar_t);
extern template wostream& operator<<(wostream&, char);
extern template wostream& operator<<(wostream&, const wchar_t*);
extern template wostream& operator<<(wostream&, const char*);
#endif
#endif
} // namespace std
#endif