From c31428d2117318fc5d72e9868d7d34eee52c4eba Mon Sep 17 00:00:00 2001 From: kan Date: Sun, 1 Sep 2002 20:39:13 +0000 Subject: Gcc 3.2.1-prerelease libf2c bits from the FSF anoncvs repo gcc-3_2-branch on 1-Sep-2002 00:00:01 EDT. --- contrib/libstdc++/src/Makefile.am | 8 +- contrib/libstdc++/src/Makefile.in | 41 +- contrib/libstdc++/src/ext-inst.cc | 30 +- contrib/libstdc++/src/fstream-inst.cc | 62 +++ contrib/libstdc++/src/fstream.cc | 193 ++++++++++ contrib/libstdc++/src/io-inst.cc | 60 +++ contrib/libstdc++/src/istream-inst.cc | 70 ++++ contrib/libstdc++/src/locale-inst.cc | 37 +- contrib/libstdc++/src/locale.cc | 2 +- contrib/libstdc++/src/localename.cc | 16 +- contrib/libstdc++/src/misc-inst.cc | 184 +-------- contrib/libstdc++/src/ostream-inst.cc | 76 ++++ contrib/libstdc++/src/sstream-inst.cc | 62 +++ contrib/libstdc++/src/streambuf-inst.cc | 56 +++ contrib/libstdc++/src/strstream.cc | 657 +++++++++++++++----------------- 15 files changed, 954 insertions(+), 600 deletions(-) create mode 100644 contrib/libstdc++/src/fstream-inst.cc create mode 100644 contrib/libstdc++/src/fstream.cc create mode 100644 contrib/libstdc++/src/io-inst.cc create mode 100644 contrib/libstdc++/src/istream-inst.cc create mode 100644 contrib/libstdc++/src/ostream-inst.cc create mode 100644 contrib/libstdc++/src/sstream-inst.cc create mode 100644 contrib/libstdc++/src/streambuf-inst.cc (limited to 'contrib/libstdc++/src') diff --git a/contrib/libstdc++/src/Makefile.am b/contrib/libstdc++/src/Makefile.am index dde80dd..4e24041 100644 --- a/contrib/libstdc++/src/Makefile.am +++ b/contrib/libstdc++/src/Makefile.am @@ -41,7 +41,7 @@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@ # or configure.in to see how they are set. See GLIBCPP_EXPORT_FLAGS # NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden. CONFIG_CXXFLAGS = \ - @EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@ + @EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @DEBUG_FLAGS@ # Warning flags to use. WARN_CXXFLAGS = \ @@ -63,12 +63,14 @@ INCLUDES = \ sources = \ globals.cc limits.cc \ basic_file.cc complex_io.cc ios.cc strstream.cc \ - cmath.cc bitset.cc \ + bitset.cc \ functexcept.cc stdexcept.cc vterminate.cc \ c++locale.cc locale.cc localename.cc codecvt.cc \ collate.cc ctype.cc messages.cc monetary.cc numeric.cc time.cc \ concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \ - string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc + string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc \ + fstream.cc fstream-inst.cc io-inst.cc istream-inst.cc \ + ostream-inst.cc streambuf-inst.cc sstream-inst.cc VPATH = $(top_srcdir)/src:$(top_srcdir) diff --git a/contrib/libstdc++/src/Makefile.in b/contrib/libstdc++/src/Makefile.in index 51e25be..d285079 100644 --- a/contrib/libstdc++/src/Makefile.in +++ b/contrib/libstdc++/src/Makefile.in @@ -67,9 +67,6 @@ AS = @AS@ ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@ AWK = @AWK@ BASIC_FILE_H = @BASIC_FILE_H@ -BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ -CATALOGS = @CATALOGS@ -CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCODECVT_C = @CCODECVT_C@ CCODECVT_H = @CCODECVT_H@ @@ -77,28 +74,16 @@ CLOCALE_H = @CLOCALE_H@ CMESSAGES_H = @CMESSAGES_H@ CPP = @CPP@ CPU_LIMITS_INC_SRCDIR = @CPU_LIMITS_INC_SRCDIR@ -CSHADOW_FLAGS = @CSHADOW_FLAGS@ CSTDIO_H = @CSTDIO_H@ CXXCPP = @CXXCPP@ C_INCLUDE_DIR = @C_INCLUDE_DIR@ -DATADIRNAME = @DATADIRNAME@ DEBUG_FLAGS = @DEBUG_FLAGS@ DLLTOOL = @DLLTOOL@ EXEEXT = @EXEEXT@ EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@ GCJ = @GCJ@ GCJFLAGS = @GCJFLAGS@ -GENCAT = @GENCAT@ -GLIBC21 = @GLIBC21@ GLIBCPP_IS_CROSS_COMPILING = @GLIBCPP_IS_CROSS_COMPILING@ -GMOFILES = @GMOFILES@ -GMSGFMT = @GMSGFMT@ -INSTOBJEXT = @INSTOBJEXT@ -INTLBISON = @INTLBISON@ -INTLLIBS = @INTLLIBS@ -INTLOBJS = @INTLOBJS@ -INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ -LIBICONV = @LIBICONV@ LIBMATHOBJS = @LIBMATHOBJS@ LIBSUPCXX_PICFLAGS = @LIBSUPCXX_PICFLAGS@ LIBTOOL = @LIBTOOL@ @@ -106,24 +91,20 @@ LIBUNWIND_FLAG = @LIBUNWIND_FLAG@ LN_S = @LN_S@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ -MKINSTALLDIRS = @MKINSTALLDIRS@ -MSGFMT = @MSGFMT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPT_LDFLAGS = @OPT_LDFLAGS@ OS_INC_SRCDIR = @OS_INC_SRCDIR@ PACKAGE = @PACKAGE@ -POFILES = @POFILES@ -POSUB = @POSUB@ RANLIB = @RANLIB@ SECTION_FLAGS = @SECTION_FLAGS@ SECTION_LDFLAGS = @SECTION_LDFLAGS@ STRIP = @STRIP@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ WARN_FLAGS = @WARN_FLAGS@ WERROR = @WERROR@ +baseline_file = @baseline_file@ check_msgfmt = @check_msgfmt@ enable_shared = @enable_shared@ enable_static = @enable_static@ @@ -142,7 +123,6 @@ gxx_include_dir = @gxx_include_dir@ ifGNUmake = @ifGNUmake@ libio_la = @libio_la@ libtool_VERSION = @libtool_VERSION@ -release_VERSION = @release_VERSION@ toplevel_srcdir = @toplevel_srcdir@ AUTOMAKE_OPTIONS = 1.3 gnits @@ -164,7 +144,7 @@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@ # or configure.in to see how they are set. See GLIBCPP_EXPORT_FLAGS # NB: DEBUGFLAGS have to be at the end so that -O2 can be overridden. CONFIG_CXXFLAGS = \ - @EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @CSHADOW_FLAGS@ @DEBUG_FLAGS@ + @EXTRA_CXX_FLAGS@ @SECTION_FLAGS@ @DEBUG_FLAGS@ # Warning flags to use. @@ -189,12 +169,14 @@ INCLUDES = \ sources = \ globals.cc limits.cc \ basic_file.cc complex_io.cc ios.cc strstream.cc \ - cmath.cc bitset.cc \ + bitset.cc \ functexcept.cc stdexcept.cc vterminate.cc \ c++locale.cc locale.cc localename.cc codecvt.cc \ collate.cc ctype.cc messages.cc monetary.cc numeric.cc time.cc \ concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \ - string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc + string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc \ + fstream.cc fstream-inst.cc io-inst.cc istream-inst.cc \ + ostream-inst.cc streambuf-inst.cc sstream-inst.cc VPATH = $(top_srcdir)/src:$(top_srcdir) @@ -273,11 +255,12 @@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ libstdc___la_OBJECTS = globals.lo limits.lo basic_file.lo complex_io.lo \ -ios.lo strstream.lo cmath.lo bitset.lo functexcept.lo stdexcept.lo \ -vterminate.lo c++locale.lo locale.lo localename.lo codecvt.lo \ -collate.lo ctype.lo messages.lo monetary.lo numeric.lo time.lo \ -concept-inst.lo locale-inst.lo misc-inst.lo stl-inst.lo string-inst.lo \ -wstring-inst.lo valarray-inst.lo ext-inst.lo +ios.lo strstream.lo bitset.lo functexcept.lo stdexcept.lo vterminate.lo \ +c++locale.lo locale.lo localename.lo codecvt.lo collate.lo ctype.lo \ +messages.lo monetary.lo numeric.lo time.lo concept-inst.lo \ +locale-inst.lo misc-inst.lo stl-inst.lo string-inst.lo wstring-inst.lo \ +valarray-inst.lo ext-inst.lo fstream.lo fstream-inst.lo io-inst.lo \ +istream-inst.lo ostream-inst.lo streambuf-inst.lo sstream-inst.lo CXXFLAGS = @CXXFLAGS@ CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) diff --git a/contrib/libstdc++/src/ext-inst.cc b/contrib/libstdc++/src/ext-inst.cc index 21b98c8..4896b11 100644 --- a/contrib/libstdc++/src/ext-inst.cc +++ b/contrib/libstdc++/src/ext-inst.cc @@ -1,6 +1,6 @@ // Explicit instantiation file. -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002 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 @@ -32,9 +32,31 @@ // #include +#include -namespace std +namespace __gnu_cxx { template - const unsigned long __gnu_cxx::rope >::_S_min_len; -} // namespace std + const unsigned long + rope >::_S_min_len; + + template + char + rope >:: + _S_fetch(_Rope_RopeRep >*, size_type); + + template class stdio_filebuf; + +#ifdef _GLIBCPP_USE_WCHAR_T + template + const unsigned long + rope >::_S_min_len; + + template + wchar_t + rope >:: + _S_fetch(_Rope_RopeRep >*, size_type); + + template class stdio_filebuf; +#endif +} // namespace __gnu_cxx diff --git a/contrib/libstdc++/src/fstream-inst.cc b/contrib/libstdc++/src/fstream-inst.cc new file mode 100644 index 0000000..34f3819 --- /dev/null +++ b/contrib/libstdc++/src/fstream-inst.cc @@ -0,0 +1,62 @@ +// Explicit instantiation file. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// 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. + +// +// ISO C++ 14882: +// + +#include + +namespace std +{ + // filebuf + template class basic_filebuf >; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_filebuf >; +#endif + + // ifstream + template class basic_ifstream; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ifstream; +#endif + + // ofstream + template class basic_ofstream; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ofstream; +#endif + + // fstream + template class basic_fstream; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_fstream; +#endif +} //std diff --git a/contrib/libstdc++/src/fstream.cc b/contrib/libstdc++/src/fstream.cc new file mode 100644 index 0000000..be71133 --- /dev/null +++ b/contrib/libstdc++/src/fstream.cc @@ -0,0 +1,193 @@ +// File based streams -*- C++ -*- + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// 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. + +// +// ISO C++ 14882: 27.8 File-based streams +// + +#include + +namespace std +{ + template<> + basic_filebuf::int_type + basic_filebuf::_M_underflow_common(bool __bump) + { + int_type __ret = traits_type::eof(); + bool __testin = _M_mode & ios_base::in; + bool __testout = _M_mode & ios_base::out; + + if (__testin) + { + // Check for pback madness, and if so swich back to the + // normal buffers and jet outta here before expensive + // fileops happen... + if (_M_pback_init) + { + _M_pback_destroy(); + if (_M_in_cur < _M_in_end) + return traits_type::to_int_type(*_M_in_cur); + } + + // Sync internal and external buffers. + // NB: __testget -> __testput as _M_buf_unified here. + bool __testget = _M_in_cur && _M_in_beg < _M_in_cur; + bool __testinit = _M_is_indeterminate(); + if (__testget) + { + if (__testout) + _M_really_overflow(); + else if (_M_in_cur != _M_filepos) + _M_file.seekoff(_M_in_cur - _M_filepos, + ios_base::cur, ios_base::in); + } + + if (__testinit || __testget) + { + streamsize __elen = 0; + streamsize __ilen = 0; + __elen = _M_file.xsgetn(reinterpret_cast(_M_in_beg), + _M_buf_size); + __ilen = __elen; + + if (0 < __ilen) + { + _M_set_determinate(__ilen); + if (__testout) + _M_out_cur = _M_in_cur; + __ret = traits_type::to_int_type(*_M_in_cur); + if (__bump) + _M_in_cur_move(1); + else if (_M_buf_size == 1) + { + // If we are synced with stdio, we have to unget the + // character we just read so that the file pointer + // doesn't move. + _M_file.sys_ungetc(traits_type::to_int_type(*_M_in_cur)); + _M_set_indeterminate(); + } + } + } + } + _M_last_overflowed = false; + return __ret; + } + +#ifdef _GLIBCPP_USE_WCHAR_T + template<> + basic_filebuf::int_type + basic_filebuf::_M_underflow_common(bool __bump) + { + int_type __ret = traits_type::eof(); + bool __testin = _M_mode & ios_base::in; + bool __testout = _M_mode & ios_base::out; + + if (__testin) + { + // Check for pback madness, and if so swich back to the + // normal buffers and jet outta here before expensive + // fileops happen... + if (_M_pback_init) + { + _M_pback_destroy(); + if (_M_in_cur < _M_in_end) + return traits_type::to_int_type(*_M_in_cur); + } + + // Sync internal and external buffers. + // NB: __testget -> __testput as _M_buf_unified here. + bool __testget = _M_in_cur && _M_in_beg < _M_in_cur; + bool __testinit = _M_is_indeterminate(); + if (__testget) + { + if (__testout) + _M_really_overflow(); + else if (_M_in_cur != _M_filepos) + _M_file.seekoff(_M_in_cur - _M_filepos, + ios_base::cur, ios_base::in); + } + + if (__testinit || __testget) + { + const locale __loc = this->getloc(); + const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc); + + streamsize __elen = 0; + streamsize __ilen = 0; + if (__cvt.always_noconv()) + { + __elen = _M_file.xsgetn(reinterpret_cast(_M_in_beg), + _M_buf_size); + __ilen = __elen; + } + else + { + char* __buf = static_cast(__builtin_alloca(_M_buf_size)); + __elen = _M_file.xsgetn(__buf, _M_buf_size); + + const char* __eend; + char_type* __iend; + __res_type __r = __cvt.in(_M_state_cur, __buf, + __buf + __elen, __eend, _M_in_beg, + _M_in_beg + _M_buf_size, __iend); + if (__r == codecvt_base::ok) + __ilen = __iend - _M_in_beg; + else + { + // Unwind. + __ilen = 0; + _M_file.seekoff(-__elen, ios_base::cur, ios_base::in); + } + } + + if (0 < __ilen) + { + _M_set_determinate(__ilen); + if (__testout) + _M_out_cur = _M_in_cur; + __ret = traits_type::to_int_type(*_M_in_cur); + if (__bump) + _M_in_cur_move(1); + else if (_M_buf_size == 1) + { + // If we are synced with stdio, we have to unget the + // character we just read so that the file pointer + // doesn't move. + _M_file.sys_ungetc(traits_type::to_int_type(*_M_in_cur)); + _M_set_indeterminate(); + } + } + } + } + _M_last_overflowed = false; + return __ret; + } +#endif +} // namespace std diff --git a/contrib/libstdc++/src/io-inst.cc b/contrib/libstdc++/src/io-inst.cc new file mode 100644 index 0000000..f5773c9 --- /dev/null +++ b/contrib/libstdc++/src/io-inst.cc @@ -0,0 +1,60 @@ +// Explicit instantiation file. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// 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. + +// +// ISO C++ 14882: +// + +#include +#include +#include + +namespace std +{ + // basic_ios + template class basic_ios; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ios; +#endif + + // iomanip + template class _Setfill; + template _Setfill setfill(char); +#ifdef _GLIBCPP_USE_WCHAR_T + template class _Setfill; + template _Setfill setfill(wchar_t); +#endif + + // iostream + template class basic_iostream; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_iostream; +#endif +} //std diff --git a/contrib/libstdc++/src/istream-inst.cc b/contrib/libstdc++/src/istream-inst.cc new file mode 100644 index 0000000..6112509 --- /dev/null +++ b/contrib/libstdc++/src/istream-inst.cc @@ -0,0 +1,70 @@ +// Explicit instantiation file. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// 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. + +// +// ISO C++ 14882: +// + +#include +#include + +namespace std +{ + // istream + template class basic_istream; + template istream& ws(istream&); + template istream& operator>>(istream&, char&); + template istream& operator>>(istream&, unsigned char&); + template istream& operator>>(istream&, signed char&); + template istream& operator>>(istream&, char*); + template istream& operator>>(istream&, unsigned char*); + template istream& operator>>(istream&, signed char*); + + template istream& operator>>(istream&, _Setfill); + template istream& operator>>(istream&, _Setiosflags); + template istream& operator>>(istream&, _Resetiosflags); + template istream& operator>>(istream&, _Setbase); + template istream& operator>>(istream&, _Setprecision); + template istream& operator>>(istream&, _Setw); + +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_istream; + template wistream& ws(wistream&); + template wistream& operator>>(wistream&, wchar_t&); + template wistream& operator>>(wistream&, wchar_t*); + + template wistream& operator>>(wistream&, _Setfill); + template wistream& operator>>(wistream&, _Setiosflags); + template wistream& operator>>(wistream&, _Resetiosflags); + template wistream& operator>>(wistream&, _Setbase); + template wistream& operator>>(wistream&, _Setprecision); + template wistream& operator>>(wistream&, _Setw); +#endif +} //std diff --git a/contrib/libstdc++/src/locale-inst.cc b/contrib/libstdc++/src/locale-inst.cc index 7ac147f..5e6c675 100644 --- a/contrib/libstdc++/src/locale-inst.cc +++ b/contrib/libstdc++/src/locale-inst.cc @@ -181,9 +181,9 @@ namespace std // codecvt inline template class __codecvt_abstract_base; - inline template class __codecvt_abstract_base; template class codecvt_byname; #ifdef _GLIBCPP_USE_WCHAR_T + inline template class __codecvt_abstract_base; template class codecvt_byname; #endif @@ -420,15 +420,7 @@ namespace std bool __verify_grouping(const basic_string&, basic_string&); - template - void - __pad(ios_base&, char, char*, const char *, streamsize, - streamsize, const bool); - - template - void - __pad >(ios_base&, char, char*, const char *, - streamsize, streamsize, const bool); + template class __pad >; #ifdef _GLIBCPP_USE_WCHAR_T template @@ -440,29 +432,23 @@ namespace std __verify_grouping(const basic_string&, basic_string&); - template - void - __pad(ios_base&, wchar_t, wchar_t*, const wchar_t*, - streamsize, streamsize, const bool); - - template - void - __pad >(ios_base&, wchar_t, wchar_t*, - const wchar_t*, streamsize, - streamsize, const bool); -#endif // _GLIBCPP_USE_WCHAR_T + template class __pad >; +#endif template int - __convert_from_v(char*, const int, const char*, double, const __c_locale&, int); + __convert_from_v(char*, const int, const char*, double, + const __c_locale&, int); template int - __convert_from_v(char*, const int, const char*, long double, const __c_locale&, int); + __convert_from_v(char*, const int, const char*, long double, + const __c_locale&, int); template int - __convert_from_v(char*, const int, const char*, long, const __c_locale&, int); + __convert_from_v(char*, const int, const char*, long, + const __c_locale&, int); template int @@ -471,7 +457,8 @@ namespace std template int - __convert_from_v(char*, const int, const char*, long long, const __c_locale&, int); + __convert_from_v(char*, const int, const char*, long long, + const __c_locale&, int); template int diff --git a/contrib/libstdc++/src/locale.cc b/contrib/libstdc++/src/locale.cc index 26c2834..3cb9d1b 100644 --- a/contrib/libstdc++/src/locale.cc +++ b/contrib/libstdc++/src/locale.cc @@ -202,7 +202,7 @@ namespace std if (strcmp(__s, "C") == 0 || strcmp(__s, "POSIX") == 0) (_M_impl = _S_classic)->_M_add_reference(); else if (strcmp(__s, "") == 0) - _M_impl = new _Impl(setlocale(LC_ALL, __s), 1); + _M_impl = new _Impl(setlocale(LC_ALL, NULL), 1); else _M_impl = new _Impl(__s, 1); } diff --git a/contrib/libstdc++/src/localename.cc b/contrib/libstdc++/src/localename.cc index 1b40e0c..8fa9118 100644 --- a/contrib/libstdc++/src/localename.cc +++ b/contrib/libstdc++/src/localename.cc @@ -132,8 +132,8 @@ namespace std _M_init_facet(new num_get); _M_init_facet(new num_put); _M_init_facet(new std::collate(__cloc)); - _M_init_facet(new moneypunct(__cloc)); - _M_init_facet(new moneypunct(__cloc)); + _M_init_facet(new moneypunct(__cloc, __s)); + _M_init_facet(new moneypunct(__cloc, __s)); _M_init_facet(new money_get); _M_init_facet(new money_put); _M_init_facet(new __timepunct(__cloc, __s)); @@ -148,8 +148,8 @@ namespace std _M_init_facet(new num_get); _M_init_facet(new num_put); _M_init_facet(new std::collate(__cloc)); - _M_init_facet(new moneypunct(__cloc)); - _M_init_facet(new moneypunct(__cloc)); + _M_init_facet(new moneypunct(__cloc, __s)); + _M_init_facet(new moneypunct(__cloc, __s)); _M_init_facet(new money_get); _M_init_facet(new money_put); _M_init_facet(new __timepunct(__cloc, __s)); @@ -255,13 +255,7 @@ namespace std facet** __old = _M_facets; facet** __new; const size_t __new_size = __index + 4; - try - { __new = new facet*[__new_size]; } - catch(...) - { - delete [] __new; - __throw_exception_again; - } + __new = new facet*[__new_size]; for (size_t __i = 0; __i < _M_facets_size; ++__i) __new[__i] = _M_facets[__i]; for (size_t __i2 = _M_facets_size; __i2 < __new_size; ++__i2) diff --git a/contrib/libstdc++/src/misc-inst.cc b/contrib/libstdc++/src/misc-inst.cc index 07a4b1a..5576d2c 100644 --- a/contrib/libstdc++/src/misc-inst.cc +++ b/contrib/libstdc++/src/misc-inst.cc @@ -33,173 +33,13 @@ // #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include -#include - -// NB: Unnecessary if the .h headers already include these. -#ifndef _GLIBCPP_FULLY_COMPLIANT_HEADERS -#include -#include -#include -#include -#include -#endif +#include +#include namespace std { - // streambuf - template class basic_streambuf; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_streambuf; -#endif - - // stringbuf - template class basic_stringbuf; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_stringbuf; -#endif - - // filebuf - template class basic_filebuf >; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_filebuf >; -#endif - - // basic_ios - template class basic_ios; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ios; -#endif - - // iomanip - template class _Setfill; - template _Setfill setfill(char); -#ifdef _GLIBCPP_USE_WCHAR_T - template class _Setfill; - template _Setfill setfill(wchar_t); -#endif - - // istream - template class basic_istream; - template istream& ws(istream&); - template istream& operator>>(istream&, char&); - template istream& operator>>(istream&, unsigned char&); - template istream& operator>>(istream&, signed char&); - template istream& operator>>(istream&, char*); - template istream& operator>>(istream&, unsigned char*); - template istream& operator>>(istream&, signed char*); - - template istream& operator>>(istream&, _Setfill); - template istream& operator>>(istream&, _Setiosflags); - template istream& operator>>(istream&, _Resetiosflags); - template istream& operator>>(istream&, _Setbase); - template istream& operator>>(istream&, _Setprecision); - template istream& operator>>(istream&, _Setw); - -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_istream; - template wistream& ws(wistream&); - template wistream& operator>>(wistream&, wchar_t&); - template wistream& operator>>(wistream&, wchar_t*); - - template wistream& operator>>(wistream&, _Setfill); - template wistream& operator>>(wistream&, _Setiosflags); - template wistream& operator>>(wistream&, _Resetiosflags); - template wistream& operator>>(wistream&, _Setbase); - template wistream& operator>>(wistream&, _Setprecision); - template wistream& operator>>(wistream&, _Setw); -#endif - - // ostream - template class basic_ostream; - template ostream& endl(ostream&); - template ostream& ends(ostream&); - template ostream& flush(ostream&); - template ostream& operator<<(ostream&, char); - template ostream& operator<<(ostream&, unsigned char); - template ostream& operator<<(ostream&, signed char); - template ostream& operator<<(ostream&, const char*); - template ostream& operator<<(ostream&, const unsigned char*); - template ostream& operator<<(ostream&, const signed char*); - - template ostream& operator<<(ostream&, _Setfill); - template ostream& operator<<(ostream&, _Setiosflags); - template ostream& operator<<(ostream&, _Resetiosflags); - template ostream& operator<<(ostream&, _Setbase); - template ostream& operator<<(ostream&, _Setprecision); - template ostream& operator<<(ostream&, _Setw); - -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ostream; - template wostream& endl(wostream&); - template wostream& ends(wostream&); - template wostream& flush(wostream&); - template wostream& operator<<(wostream&, wchar_t); - template wostream& operator<<(wostream&, char); - template wostream& operator<<(wostream&, const wchar_t*); - template wostream& operator<<(wostream&, const char*); - - template wostream& operator<<(wostream&, _Setfill); - template wostream& operator<<(wostream&, _Setiosflags); - template wostream& operator<<(wostream&, _Resetiosflags); - template wostream& operator<<(wostream&, _Setbase); - template wostream& operator<<(wostream&, _Setprecision); - template wostream& operator<<(wostream&, _Setw); -#endif - - - // iostream - template class basic_iostream; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_iostream; -#endif - - // ifstream - template class basic_ifstream; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ifstream; -#endif - - // ofstream - template class basic_ofstream; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ofstream; -#endif - - // fstream - template class basic_fstream; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_fstream; -#endif - - // istringstream - template class basic_istringstream; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_istringstream; -#endif - - // ostringstream - template class basic_ostringstream; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ostringstream; -#endif - - // stringstream - template class basic_stringstream; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_stringstream; -#endif - // string related to iostreams template basic_istream& @@ -228,6 +68,10 @@ namespace std getline(basic_istream&, wstring&); #endif +#if 1 + // XXX + // 2002-05-24 These are no longer needed and should be deleted. + // algorithm typedef _Char_traits_match > char_match; @@ -254,21 +98,5 @@ namespace std __uninitialized_copy_aux::const_iterator, string *> (vector::const_iterator, vector::const_iterator, string*, __false_type); - - template - streamsize - __copy_streambufs(basic_ios&, basic_streambuf*, - basic_streambuf*); -#ifdef _GLIBCPP_USE_WCHAR_T - template - streamsize - __copy_streambufs(basic_ios&, basic_streambuf*, - basic_streambuf*); -#endif - - using __gnu_cxx::stdio_filebuf; - template class stdio_filebuf; -#ifdef _GLIBCPP_USE_WCHAR_T - template class stdio_filebuf; #endif } //std diff --git a/contrib/libstdc++/src/ostream-inst.cc b/contrib/libstdc++/src/ostream-inst.cc new file mode 100644 index 0000000..e43b0c7 --- /dev/null +++ b/contrib/libstdc++/src/ostream-inst.cc @@ -0,0 +1,76 @@ +// Explicit instantiation file. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// 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. + +// +// ISO C++ 14882: +// + +#include +#include + +namespace std +{ + // ostream + template class basic_ostream; + template ostream& endl(ostream&); + template ostream& ends(ostream&); + template ostream& flush(ostream&); + template ostream& operator<<(ostream&, char); + template ostream& operator<<(ostream&, unsigned char); + template ostream& operator<<(ostream&, signed char); + template ostream& operator<<(ostream&, const char*); + template ostream& operator<<(ostream&, const unsigned char*); + template ostream& operator<<(ostream&, const signed char*); + + template ostream& operator<<(ostream&, _Setfill); + template ostream& operator<<(ostream&, _Setiosflags); + template ostream& operator<<(ostream&, _Resetiosflags); + template ostream& operator<<(ostream&, _Setbase); + template ostream& operator<<(ostream&, _Setprecision); + template ostream& operator<<(ostream&, _Setw); + +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ostream; + template wostream& endl(wostream&); + template wostream& ends(wostream&); + template wostream& flush(wostream&); + template wostream& operator<<(wostream&, wchar_t); + template wostream& operator<<(wostream&, char); + template wostream& operator<<(wostream&, const wchar_t*); + template wostream& operator<<(wostream&, const char*); + + template wostream& operator<<(wostream&, _Setfill); + template wostream& operator<<(wostream&, _Setiosflags); + template wostream& operator<<(wostream&, _Resetiosflags); + template wostream& operator<<(wostream&, _Setbase); + template wostream& operator<<(wostream&, _Setprecision); + template wostream& operator<<(wostream&, _Setw); +#endif +} //std diff --git a/contrib/libstdc++/src/sstream-inst.cc b/contrib/libstdc++/src/sstream-inst.cc new file mode 100644 index 0000000..e341f5f --- /dev/null +++ b/contrib/libstdc++/src/sstream-inst.cc @@ -0,0 +1,62 @@ +// Explicit instantiation file. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// 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. + +// +// ISO C++ 14882: +// + +#include + +namespace std +{ + // stringbuf + template class basic_stringbuf; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_stringbuf; +#endif + + // istringstream + template class basic_istringstream; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_istringstream; +#endif + + // ostringstream + template class basic_ostringstream; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ostringstream; +#endif + + // stringstream + template class basic_stringstream; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_stringstream; +#endif +} //std diff --git a/contrib/libstdc++/src/streambuf-inst.cc b/contrib/libstdc++/src/streambuf-inst.cc new file mode 100644 index 0000000..438752e --- /dev/null +++ b/contrib/libstdc++/src/streambuf-inst.cc @@ -0,0 +1,56 @@ +// Explicit instantiation file. + +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// 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. + +// +// ISO C++ 14882: +// + +#include +#include + +namespace std +{ + // streambuf + template class basic_streambuf; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_streambuf; +#endif + + template + streamsize + __copy_streambufs(basic_ios&, basic_streambuf*, + basic_streambuf*); +#ifdef _GLIBCPP_USE_WCHAR_T + template + streamsize + __copy_streambufs(basic_ios&, basic_streambuf*, + basic_streambuf*); +#endif +} //std diff --git a/contrib/libstdc++/src/strstream.cc b/contrib/libstdc++/src/strstream.cc index 2160c44..0576472 100644 --- a/contrib/libstdc++/src/strstream.cc +++ b/contrib/libstdc++/src/strstream.cc @@ -1,6 +1,6 @@ // strstream definitions -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation +// Copyright (C) 2001, 2002 Free Software Foundation // // This file is part of GNU CC. // @@ -47,7 +47,7 @@ // MAY BE REMOVED in a future standard revision. You should use the // header instead. -#include +#include #include #include #include @@ -56,403 +56,362 @@ namespace std { - -// strstreambuf constructor, destructor. - -strstreambuf::strstreambuf(streamsize initial_capacity) - : _Base(), - _M_alloc_fun(0), _M_free_fun(0), - _M_dynamic(true), _M_frozen(false), _M_constant(false) -{ - streamsize n = max(initial_capacity, streamsize(16)); - - char* buf = _M_alloc(n); - if (buf) { - setp(buf, buf + n); - setg(buf, buf, buf); - } -} - -strstreambuf::strstreambuf(void* (*alloc_f)(size_t), void (*free_f)(void*)) - : _Base(), - _M_alloc_fun(alloc_f), _M_free_fun(free_f), - _M_dynamic(true), _M_frozen(false), _M_constant(false) -{ - streamsize n = 16; - - char* buf = _M_alloc(n); - if (buf) { - setp(buf, buf + n); - setg(buf, buf, buf); + strstreambuf::strstreambuf(streamsize initial_capacity) + : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true), + _M_frozen(false), _M_constant(false) + { + streamsize n = max(initial_capacity, streamsize(16)); + + char* buf = _M_alloc(n); + if (buf) + { + setp(buf, buf + n); + setg(buf, buf, buf); + } } -} - -strstreambuf::strstreambuf(char* get, streamsize n, char* put) - : _Base(), - _M_alloc_fun(0), _M_free_fun(0), - _M_dynamic(false), _M_frozen(false), _M_constant(false) -{ - _M_setup(get, put, n); -} - -strstreambuf::strstreambuf(signed char* get, streamsize n, signed char* put) - : _Base(), - _M_alloc_fun(0), _M_free_fun(0), - _M_dynamic(false), _M_frozen(false), _M_constant(false) -{ - _M_setup(reinterpret_cast(get), reinterpret_cast(put), n); -} - -strstreambuf::strstreambuf(unsigned char* get, streamsize n, - unsigned char* put) - : _Base(), - _M_alloc_fun(0), _M_free_fun(0), - _M_dynamic(false), _M_frozen(false), _M_constant(false) -{ - _M_setup(reinterpret_cast(get), reinterpret_cast(put), n); -} - -strstreambuf::strstreambuf(const char* get, streamsize n) - : _Base(), - _M_alloc_fun(0), _M_free_fun(0), - _M_dynamic(false), _M_frozen(false), _M_constant(true) -{ - _M_setup(const_cast(get), 0, n); -} - -strstreambuf::strstreambuf(const signed char* get, streamsize n) - : _Base(), - _M_alloc_fun(0), _M_free_fun(0), - _M_dynamic(false), _M_frozen(false), _M_constant(true) -{ - _M_setup(reinterpret_cast(const_cast(get)), 0, n); -} - -strstreambuf::strstreambuf(const unsigned char* get, streamsize n) - : _Base(), - _M_alloc_fun(0), _M_free_fun(0), - _M_dynamic(false), _M_frozen(false), _M_constant(true) -{ - _M_setup(reinterpret_cast(const_cast(get)), 0, n); -} - -strstreambuf::~strstreambuf() -{ - if (_M_dynamic && !_M_frozen) - _M_free(eback()); -} -void strstreambuf::freeze(bool frozenflag) -{ - if (_M_dynamic) - _M_frozen = frozenflag; -} - -char* strstreambuf::str() -{ - freeze(true); - return eback(); -} - -int strstreambuf::pcount() const -{ - return pptr() ? pptr() - pbase() : 0; -} - -strstreambuf::int_type strstreambuf::overflow(int_type c) { - if (c == traits_type::eof()) - return traits_type::not_eof(c); - - // Try to expand the buffer. - if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant) { - ptrdiff_t old_size = epptr() - pbase(); - ptrdiff_t new_size = max(2 * old_size, ptrdiff_t(1)); - - char* buf = _M_alloc(new_size); - if (buf) { - memcpy(buf, pbase(), old_size); - - char* old_buffer = pbase(); - bool reposition_get = false; - ptrdiff_t old_get_offset; - if (gptr() != 0) { - reposition_get = true; - old_get_offset = gptr() - eback(); + strstreambuf::strstreambuf(void* (*alloc_f)(size_t), void (*free_f)(void*)) + : _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true), + _M_frozen(false), _M_constant(false) + { + streamsize n = 16; + + char* buf = _M_alloc(n); + if (buf) + { + setp(buf, buf + n); + setg(buf, buf, buf); } - - setp(buf, buf + new_size); - pbump(old_size); - - if (reposition_get) - setg(buf, buf + old_get_offset, buf + max(old_get_offset, old_size)); - - _M_free(old_buffer); - } } - if (pptr() != epptr()) { - *pptr() = c; - pbump(1); - return c; + strstreambuf::strstreambuf(char* get, streamsize n, char* put) + : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), + _M_frozen(false), _M_constant(false) + { _M_setup(get, put, n); } + + strstreambuf::strstreambuf(signed char* get, streamsize n, signed char* put) + : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), + _M_frozen(false), _M_constant(false) + { _M_setup(reinterpret_cast(get), reinterpret_cast(put), n); } + + strstreambuf::strstreambuf(unsigned char* get, streamsize n, + unsigned char* put) + : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), + _M_frozen(false), _M_constant(false) + { _M_setup(reinterpret_cast(get), reinterpret_cast(put), n); } + + strstreambuf::strstreambuf(const char* get, streamsize n) + : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), + _M_frozen(false), _M_constant(true) + { _M_setup(const_cast(get), 0, n); } + + strstreambuf::strstreambuf(const signed char* get, streamsize n) + : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), + _M_frozen(false), _M_constant(true) + { _M_setup(reinterpret_cast(const_cast(get)), 0, n); } + + strstreambuf::strstreambuf(const unsigned char* get, streamsize n) + : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false), + _M_frozen(false), _M_constant(true) + { _M_setup(reinterpret_cast(const_cast(get)), 0, n); } + + strstreambuf::~strstreambuf() + { + if (_M_dynamic && !_M_frozen) + _M_free(eback()); } - else - return traits_type::eof(); -} -strstreambuf::int_type strstreambuf::pbackfail(int_type c) -{ - if (gptr() != eback()) { - if (c == _Traits::eof()) { - gbump(-1); - return _Traits::not_eof(c); - } - else if (c == static_cast(gptr()[-1])) { // KLUDGE - gbump(-1); - return c; - } - else if (!_M_constant) { - gbump(-1); - *gptr() = c; - return c; - } + void + strstreambuf::freeze(bool frozenflag) + { + if (_M_dynamic) + _M_frozen = frozenflag; } - return _Traits::eof(); -} - -strstreambuf::int_type strstreambuf::underflow() -{ - if (gptr() == egptr() && pptr() && pptr() > egptr()) - setg(eback(), gptr(), pptr()); - - if (gptr() != egptr()) - return (unsigned char) *gptr(); - else - return _Traits::eof(); -} - -basic_streambuf >* -strstreambuf::setbuf(char*, streamsize) -{ - return this; -} - -strstreambuf::pos_type -strstreambuf::seekoff(off_type off, - ios_base::seekdir dir, ios_base::openmode mode) -{ - bool do_get = false; - bool do_put = false; - - if ((mode & (ios_base::in | ios_base::out)) == - (ios_base::in | ios_base::out) && - (dir == ios_base::beg || dir == ios_base::end)) - do_get = do_put = true; - else if (mode & ios_base::in) - do_get = true; - else if (mode & ios_base::out) - do_put = true; - - // !gptr() is here because, according to D.7.1 paragraph 4, the seekable - // area is undefined if there is no get area. - if ((!do_get && !do_put) || (do_put && !pptr()) || !gptr()) - return pos_type(off_type(-1)); - - char* seeklow = eback(); - char* seekhigh = epptr() ? epptr() : egptr(); - - off_type newoff; - switch(dir) { - case ios_base::beg: - newoff = 0; - break; - case ios_base::end: - newoff = seekhigh - seeklow; - break; - case ios_base::cur: - newoff = do_put ? pptr() - seeklow : gptr() - seeklow; - break; - default: - return pos_type(off_type(-1)); + char* + strstreambuf::str() + { + freeze(true); + return eback(); } - off += newoff; - if (off < 0 || off > seekhigh - seeklow) - return pos_type(off_type(-1)); + int + strstreambuf::pcount() const + { return pptr() ? pptr() - pbase() : 0; } + + strstreambuf::int_type + strstreambuf::overflow(int_type c) + { + if (c == traits_type::eof()) + return traits_type::not_eof(c); + + // Try to expand the buffer. + if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant) + { + ptrdiff_t old_size = epptr() - pbase(); + ptrdiff_t new_size = max(2 * old_size, ptrdiff_t(1)); + + char* buf = _M_alloc(new_size); + if (buf) + { + memcpy(buf, pbase(), old_size); + char* old_buffer = pbase(); + bool reposition_get = false; + ptrdiff_t old_get_offset; + if (gptr() != 0) + { + reposition_get = true; + old_get_offset = gptr() - eback(); + } + + setp(buf, buf + new_size); + pbump(old_size); + + if (reposition_get) + setg(buf, buf + old_get_offset, buf + + max(old_get_offset, old_size)); + + _M_free(old_buffer); + } + } + + if (pptr() != epptr()) + { + *pptr() = c; + pbump(1); + return c; + } + else + return traits_type::eof(); + } - if (do_put) { - if (seeklow + off < pbase()) { - setp(seeklow, epptr()); - pbump(off); - } - else { - setp(pbase(), epptr()); - pbump(off - (pbase() - seeklow)); + strstreambuf::int_type + strstreambuf::pbackfail(int_type c) + { + if (gptr() != eback()) + { + if (c == _Traits::eof()) + { + gbump(-1); + return _Traits::not_eof(c); + } + else if (c == static_cast(gptr()[-1])) + { // KLUDGE + gbump(-1); + return c; + } + else if (!_M_constant) + { + gbump(-1); + *gptr() = c; + return c; + } } + return _Traits::eof(); } - if (do_get) { - if (off <= egptr() - seeklow) - setg(seeklow, seeklow + off, egptr()); - else if (off <= pptr() - seeklow) - setg(seeklow, seeklow + off, pptr()); + + strstreambuf::int_type + strstreambuf::underflow() + { + if (gptr() == egptr() && pptr() && pptr() > egptr()) + setg(eback(), gptr(), pptr()); + + if (gptr() != egptr()) + return (unsigned char) *gptr(); else - setg(seeklow, seeklow + off, epptr()); + return _Traits::eof(); } - return pos_type(newoff); -} - -strstreambuf::pos_type -strstreambuf::seekpos(pos_type pos, ios_base::openmode mode) -{ - return seekoff(pos - pos_type(off_type(0)), ios_base::beg, mode); -} + basic_streambuf >* + strstreambuf::setbuf(char*, streamsize) + { return this; } + + strstreambuf::pos_type + strstreambuf::seekoff(off_type off, ios_base::seekdir dir, + ios_base::openmode mode) + { + bool do_get = false; + bool do_put = false; + + if ((mode & (ios_base::in | ios_base::out)) + == (ios_base::in | ios_base::out) && + (dir == ios_base::beg || dir == ios_base::end)) + do_get = do_put = true; + else if (mode & ios_base::in) + do_get = true; + else if (mode & ios_base::out) + do_put = true; + + // !gptr() is here because, according to D.7.1 paragraph 4, the seekable + // area is undefined if there is no get area. + if ((!do_get && !do_put) || (do_put && !pptr()) || !gptr()) + return pos_type(off_type(-1)); + + char* seeklow = eback(); + char* seekhigh = epptr() ? epptr() : egptr(); + + off_type newoff; + switch (dir) + { + case ios_base::beg: + newoff = 0; + break; + case ios_base::end: + newoff = seekhigh - seeklow; + break; + case ios_base::cur: + newoff = do_put ? pptr() - seeklow : gptr() - seeklow; + break; + default: + return pos_type(off_type(-1)); + } + + off += newoff; + if (off < 0 || off > seekhigh - seeklow) + return pos_type(off_type(-1)); + + if (do_put) + { + if (seeklow + off < pbase()) + { + setp(seeklow, epptr()); + pbump(off); + } + else + { + setp(pbase(), epptr()); + pbump(off - (pbase() - seeklow)); + } + } + if (do_get) + { + if (off <= egptr() - seeklow) + setg(seeklow, seeklow + off, egptr()); + else if (off <= pptr() - seeklow) + setg(seeklow, seeklow + off, pptr()); + else + setg(seeklow, seeklow + off, epptr()); + } + return pos_type(newoff); + } -char* strstreambuf::_M_alloc(size_t n) -{ - if (_M_alloc_fun) - return static_cast(_M_alloc_fun(n)); - else - return new char[n]; -} + strstreambuf::pos_type + strstreambuf::seekpos(pos_type pos, ios_base::openmode mode) + { return seekoff(pos - pos_type(off_type(0)), ios_base::beg, mode); } -void strstreambuf::_M_free(char* p) -{ - if (p) - if (_M_free_fun) - _M_free_fun(p); + char* + strstreambuf::_M_alloc(size_t n) + { + if (_M_alloc_fun) + return static_cast(_M_alloc_fun(n)); else - delete[] p; -} - -void strstreambuf::_M_setup(char* get, char* put, streamsize n) -{ - if (get) { - size_t N = n > 0 ? size_t(n) : n == 0 ? strlen(get) : size_t(INT_MAX); + return new char[n]; + } - if (put) { - setg(get, get, put); - setp(put, put + N); - } - else { - setg(get, get, get + N); - } + void + strstreambuf::_M_free(char* p) + { + if (p) + if (_M_free_fun) + _M_free_fun(p); + else + delete[] p; } -} -//---------------------------------------------------------------------- -// Class istrstream + void + strstreambuf::_M_setup(char* get, char* put, streamsize n) + { + if (get) + { + size_t N = n > 0 ? size_t(n) : n == 0 ? strlen(get) : size_t(INT_MAX); + + if (put) + { + setg(get, get, put); + setp(put, put + N); + } + else + setg(get, get, get + N); + } + } -istrstream::istrstream(char* s) + istrstream::istrstream(char* s) : basic_ios(), basic_istream(0), _M_buf(s, 0) -{ - basic_ios::init(&_M_buf); -} + { basic_ios::init(&_M_buf); } -istrstream::istrstream(const char* s) + istrstream::istrstream(const char* s) : basic_ios(), basic_istream(0), _M_buf(s, 0) -{ - basic_ios::init(&_M_buf); -} + { basic_ios::init(&_M_buf); } -istrstream::istrstream(char* s, streamsize n) + istrstream::istrstream(char* s, streamsize n) : basic_ios(), basic_istream(0), _M_buf(s, n) -{ - basic_ios::init(&_M_buf); -} + { basic_ios::init(&_M_buf); } -istrstream::istrstream(const char* s, streamsize n) + istrstream::istrstream(const char* s, streamsize n) : basic_ios(), basic_istream(0), _M_buf(s, n) -{ - basic_ios::init(&_M_buf); -} - -istrstream::~istrstream() {} + { basic_ios::init(&_M_buf); } -strstreambuf* istrstream::rdbuf() const { - return const_cast(&_M_buf); -} + istrstream::~istrstream() { } -char* istrstream::str() { return _M_buf.str(); } + strstreambuf* + istrstream::rdbuf() const + { return const_cast(&_M_buf); } -//---------------------------------------------------------------------- -// Class ostrstream + char* + istrstream::str() + { return _M_buf.str(); } -ostrstream::ostrstream() + ostrstream::ostrstream() : basic_ios(), basic_ostream(0), _M_buf() -{ - basic_ios::init(&_M_buf); -} + { basic_ios::init(&_M_buf); } -ostrstream::ostrstream(char* s, int n, ios_base::openmode mode) - : basic_ios(), basic_ostream(0), + ostrstream::ostrstream(char* s, int n, ios_base::openmode mode) + : basic_ios(), basic_ostream(0), _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s) -{ - basic_ios::init(&_M_buf); -} + { basic_ios::init(&_M_buf); } -ostrstream::~ostrstream() {} + ostrstream::~ostrstream() {} -strstreambuf* ostrstream::rdbuf() const -{ - return const_cast(&_M_buf); -} + strstreambuf* + ostrstream::rdbuf() const + { return const_cast(&_M_buf); } -void ostrstream::freeze(bool freezeflag) -{ - _M_buf.freeze(freezeflag); -} + void + ostrstream::freeze(bool freezeflag) + { _M_buf.freeze(freezeflag); } -char* ostrstream::str() -{ - return _M_buf.str(); -} + char* + ostrstream::str() + { return _M_buf.str(); } -int ostrstream::pcount() const -{ - return _M_buf.pcount(); -} - -//---------------------------------------------------------------------- -// Class strstream + int + ostrstream::pcount() const + { return _M_buf.pcount(); } -strstream::strstream() + strstream::strstream() : basic_ios(), basic_iostream(0), _M_buf() -{ - basic_ios::init(&_M_buf); -} + { basic_ios::init(&_M_buf); } -strstream::strstream(char* s, int n, ios_base::openmode mode) - : basic_ios(), basic_iostream(0), + strstream::strstream(char* s, int n, ios_base::openmode mode) + : basic_ios(), basic_iostream(0), _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s) -{ - basic_ios::init(&_M_buf); -} - -strstream::~strstream() {} + { basic_ios::init(&_M_buf); } -strstreambuf* strstream::rdbuf() const -{ - return const_cast(&_M_buf); -} + strstream::~strstream() { } -void strstream::freeze(bool freezeflag) -{ - _M_buf.freeze(freezeflag); -} + strstreambuf* + strstream::rdbuf() const + { return const_cast(&_M_buf); } -int strstream::pcount() const -{ - return _M_buf.pcount(); -} + void + strstream::freeze(bool freezeflag) + { _M_buf.freeze(freezeflag); } -char* strstream::str() -{ - return _M_buf.str(); -} + int + strstream::pcount() const + { return _M_buf.pcount(); } + char* + strstream::str() + { return _M_buf.str(); } } // namespace std - -// Local Variables: -// mode:C++ -// End: -- cgit v1.1