diff options
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r-- | libstdc++-v3/src/Makefile.am | 14 | ||||
-rw-r--r-- | libstdc++-v3/src/Makefile.in | 50 | ||||
-rw-r--r-- | libstdc++-v3/src/bitset.cc | 28 | ||||
-rw-r--r-- | libstdc++-v3/src/concept-inst.cc | 59 | ||||
-rw-r--r-- | libstdc++-v3/src/ext-inst.cc | 30 | ||||
-rw-r--r-- | libstdc++-v3/src/fstream-inst.cc | 62 | ||||
-rw-r--r-- | libstdc++-v3/src/globals.cc | 131 | ||||
-rw-r--r-- | libstdc++-v3/src/io-inst.cc | 60 | ||||
-rw-r--r-- | libstdc++-v3/src/ios.cc | 154 | ||||
-rw-r--r-- | libstdc++-v3/src/istream-inst.cc | 70 | ||||
-rw-r--r-- | libstdc++-v3/src/limits.cc | 25 | ||||
-rw-r--r-- | libstdc++-v3/src/locale-inst.cc | 333 | ||||
-rw-r--r-- | libstdc++-v3/src/locale.cc | 68 | ||||
-rw-r--r-- | libstdc++-v3/src/localename.cc | 218 | ||||
-rw-r--r-- | libstdc++-v3/src/misc-inst.cc | 177 | ||||
-rw-r--r-- | libstdc++-v3/src/ostream-inst.cc | 76 | ||||
-rw-r--r-- | libstdc++-v3/src/sstream-inst.cc | 62 | ||||
-rw-r--r-- | libstdc++-v3/src/stl-inst.cc | 20 | ||||
-rw-r--r-- | libstdc++-v3/src/streambuf-inst.cc (renamed from libstdc++-v3/src/cmath.cc) | 41 | ||||
-rw-r--r-- | libstdc++-v3/src/string-inst.cc | 8 | ||||
-rw-r--r-- | libstdc++-v3/src/strstream.cc | 660 | ||||
-rw-r--r-- | libstdc++-v3/src/vterminate.cc | 78 |
22 files changed, 1401 insertions, 1023 deletions
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index 07955d3e1e6..e8fca80a517 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/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 moneypunct.cc numpunct.cc time.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-inst.cc io-inst.cc istream-inst.cc ostream-inst.cc \ + streambuf-inst.cc sstream-inst.cc VPATH = $(top_srcdir)/src:$(top_srcdir) @@ -84,7 +86,9 @@ else version_arg= endif -libstdc___la_LDFLAGS = -version-info @libtool_VERSION@ -lm ${version_arg} +libstdc___la_LDFLAGS = \ + -version-info @libtool_VERSION@ ${version_arg} \ + -lm @LIBUNWIND_FLAG@ libstdc___la_DEPENDENCIES = $(libstdc___la_LIBADD) linker.map diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in index 2a4664ab554..0d849679067 100644 --- a/libstdc++-v3/src/Makefile.in +++ b/libstdc++-v3/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,53 +74,37 @@ 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@ +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_COMPLEX_LONG_DOUBLE = @USE_COMPLEX_LONG_DOUBLE@ -USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ WARN_FLAGS = @WARN_FLAGS@ WERROR = @WERROR@ +check_msgfmt = @check_msgfmt@ enable_shared = @enable_shared@ enable_static = @enable_static@ glibcpp_CXX = @glibcpp_CXX@ @@ -141,7 +122,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 @@ -163,7 +143,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. @@ -188,12 +168,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 moneypunct.cc numpunct.cc time.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-inst.cc io-inst.cc istream-inst.cc ostream-inst.cc \ + streambuf-inst.cc sstream-inst.cc VPATH = $(top_srcdir)/src:$(top_srcdir) @@ -207,7 +189,10 @@ libstdc___la_LIBADD = \ @GLIBCPP_BUILD_VERSIONED_SHLIB_TRUE@version_arg = @GLIBCPP_BUILD_VERSIONED_SHLIB_TRUE@-Wl,--version-script=linker.map @GLIBCPP_BUILD_VERSIONED_SHLIB_FALSE@version_arg = -libstdc___la_LDFLAGS = -version-info @libtool_VERSION@ -lm ${version_arg} +libstdc___la_LDFLAGS = \ + -version-info @libtool_VERSION@ ${version_arg} \ + -lm @LIBUNWIND_FLAG@ + libstdc___la_DEPENDENCIES = $(libstdc___la_LIBADD) linker.map @@ -269,11 +254,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 moneypunct.lo numpunct.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-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/libstdc++-v3/src/bitset.cc b/libstdc++-v3/src/bitset.cc index c0bec5d5b34..244f308924f 100644 --- a/libstdc++-v3/src/bitset.cc +++ b/libstdc++-v3/src/bitset.cc @@ -1,6 +1,6 @@ // Bitset definitions -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation +// Copyright (C) 2001, 2002 Free Software Foundation // // This file is part of GNU CC. // @@ -59,7 +59,7 @@ std::_Base_bitset<1>::_M_do_find_first(std::size_t __not_found) const unsigned char __this_byte = static_cast<unsigned char>(__thisword & (~(unsigned char)0)); if ( __this_byte ) - return __j*CHAR_BIT + _First_one<true>::_S_first_one[__this_byte]; + return __j * CHAR_BIT + _S_first_one[__this_byte]; __thisword >>= CHAR_BIT; } @@ -93,7 +93,7 @@ std::_Base_bitset<1>::_M_do_find_next(std::size_t __prev, unsigned char __this_byte = static_cast<unsigned char>(__thisword & (~(unsigned char)0)); if ( __this_byte ) - return __j*CHAR_BIT + _First_one<true>::_S_first_one[__this_byte]; + return __j * CHAR_BIT + _S_first_one[__this_byte]; __thisword >>= CHAR_BIT; } @@ -103,11 +103,10 @@ std::_Base_bitset<1>::_M_do_find_next(std::size_t __prev, return __not_found; } // end _M_do_find_next -// ------------------------------------------------------------ -// Lookup tables for find and count operations. -template<bool __dummy> -unsigned char std::_Bit_count<__dummy>::_S_bit_count[] = { +// Lookup tables for find and count operations. +unsigned char std::_S_bit_count[256] = +{ 0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */ 2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */ 2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */ @@ -160,10 +159,10 @@ unsigned char std::_Bit_count<__dummy>::_S_bit_count[] = { 6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */ 6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */ 8 /* 255 */ -}; // end _Bit_count +}; // end _S_bit_count -template<bool __dummy> -unsigned char std::_First_one<__dummy>::_S_first_one[] = { +unsigned char std::_S_first_one[256] = +{ 0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */ 0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */ 1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */ @@ -216,12 +215,5 @@ unsigned char std::_First_one<__dummy>::_S_first_one[] = { 0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */ 1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */ 0, /* 255 */ -}; // end _First_one - -// Explicitly instantiate them. - -template unsigned char std::_Bit_count<false>::_S_bit_count[]; -template unsigned char std::_Bit_count<true>::_S_bit_count[]; +}; // end _S_first_one -template unsigned char std::_First_one<false>::_S_first_one[]; -template unsigned char std::_First_one<true>::_S_first_one[]; diff --git a/libstdc++-v3/src/concept-inst.cc b/libstdc++-v3/src/concept-inst.cc index 11e4a89a831..01cc030da8d 100644 --- a/libstdc++-v3/src/concept-inst.cc +++ b/libstdc++-v3/src/concept-inst.cc @@ -1,6 +1,6 @@ // Concept checking instantiations -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation +// Copyright (C) 2001, 2002 Free Software Foundation // // This file is part of GNU CC. // @@ -40,7 +40,6 @@ #ifdef _GLIBCPP_CONCEPT_CHECKS #include <memory> -#include <vector> #include <ostream> #define _Instantiate(...) template void __function_requires< __VA_ARGS__ > () @@ -49,36 +48,12 @@ namespace __gnu_cxx { template void __aux_require_boolean_expr<bool>(bool const&); - _Instantiate(_BidirectionalIteratorConcept< - std::__normal_iterator< std::locale::facet**, - std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > ); - - _Instantiate(_BidirectionalIteratorConcept< - std::__normal_iterator< unsigned*, - std::vector<unsigned, std::allocator<unsigned> > > > ); - - _Instantiate(_ConvertibleConcept<std::locale::facet*, std::locale::facet*> ); - _Instantiate(_ConvertibleConcept<unsigned, unsigned> ); _Instantiate(_InputIteratorConcept<char*> ); _Instantiate(_InputIteratorConcept<char const*> ); - _Instantiate(_InputIteratorConcept<std::locale::facet**> ); - - _Instantiate(_InputIteratorConcept< - std::__normal_iterator< std::locale::facet* const*, - std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > ); - - _Instantiate(_InputIteratorConcept< - std::__normal_iterator< std::locale::facet**, - std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > ); - - _Instantiate(_InputIteratorConcept< - std::__normal_iterator< unsigned*, - std::vector<unsigned, std::allocator<unsigned> > > > ); - #ifdef _GLIBCPP_USE_WCHAR_T _Instantiate(_InputIteratorConcept<wchar_t*> ); @@ -97,29 +72,6 @@ namespace __gnu_cxx _Instantiate(_LessThanComparableConcept<unsigned> ); - _Instantiate(_Mutable_BidirectionalIteratorConcept< - std::__normal_iterator< std::locale::facet**, - std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > ); - - _Instantiate(_Mutable_BidirectionalIteratorConcept< - std::__normal_iterator< unsigned*, - std::vector<unsigned, std::allocator<unsigned> > > > ); - - _Instantiate(_Mutable_ForwardIteratorConcept< - std::__normal_iterator< std::locale::facet**, - std::vector<std::locale::facet*,std::allocator<std::locale::facet*> > > > ); - - _Instantiate(_OutputIteratorConcept< - std::locale::facet**, std::locale::facet*> ); - - _Instantiate(_OutputIteratorConcept< - std::__normal_iterator< std::locale::facet**, - std::vector<std::locale::facet*, std::allocator<std::locale::facet* > > >, - std::locale::facet* > ); - - _Instantiate(_OutputIteratorConcept<std::__normal_iterator< - unsigned*, std::vector<unsigned, std::allocator<unsigned> > >, unsigned> ); - _Instantiate(_OutputIteratorConcept<std::ostreambuf_iterator< char, std::char_traits<char> >, char> ); @@ -133,19 +85,19 @@ namespace __gnu_cxx _Instantiate(_RandomAccessIteratorConcept<char const*> ); _Instantiate(_RandomAccessIteratorConcept< - std::__normal_iterator<char const*, std::string> > ); + __normal_iterator<char const*, std::string> > ); _Instantiate(_RandomAccessIteratorConcept< - std::__normal_iterator<char*, std::string> > ); + __normal_iterator<char*, std::string> > ); #ifdef _GLIBCPP_USE_WCHAR_T _Instantiate(_RandomAccessIteratorConcept< - std::__normal_iterator<wchar_t const*, + __normal_iterator<wchar_t const*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > ); _Instantiate(_RandomAccessIteratorConcept< - std::__normal_iterator<wchar_t*, + __normal_iterator<wchar_t*, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > > > ); @@ -153,7 +105,6 @@ namespace __gnu_cxx _Instantiate(_RandomAccessIteratorConcept<wchar_t const*> ); #endif - } // namespace __gnu_cxx #undef _Instantiate diff --git a/libstdc++-v3/src/ext-inst.cc b/libstdc++-v3/src/ext-inst.cc index 21b98c8ee6a..4896b110d42 100644 --- a/libstdc++-v3/src/ext-inst.cc +++ b/libstdc++-v3/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 <ext/rope> +#include <ext/stdio_filebuf.h> -namespace std +namespace __gnu_cxx { template - const unsigned long __gnu_cxx::rope<char, std::allocator<char> >::_S_min_len; -} // namespace std + const unsigned long + rope<char, std::allocator<char> >::_S_min_len; + + template + char + rope<char, std::allocator<char> >:: + _S_fetch(_Rope_RopeRep<char, std::allocator<char> >*, size_type); + + template class stdio_filebuf<char>; + +#ifdef _GLIBCPP_USE_WCHAR_T + template + const unsigned long + rope<wchar_t, std::allocator<wchar_t> >::_S_min_len; + + template + wchar_t + rope<wchar_t, std::allocator<wchar_t> >:: + _S_fetch(_Rope_RopeRep<wchar_t, std::allocator<wchar_t> >*, size_type); + + template class stdio_filebuf<wchar_t>; +#endif +} // namespace __gnu_cxx diff --git a/libstdc++-v3/src/fstream-inst.cc b/libstdc++-v3/src/fstream-inst.cc new file mode 100644 index 00000000000..34f3819876a --- /dev/null +++ b/libstdc++-v3/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 <fstream> + +namespace std +{ + // filebuf + template class basic_filebuf<char, char_traits<char> >; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_filebuf<wchar_t, char_traits<wchar_t> >; +#endif + + // ifstream + template class basic_ifstream<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ifstream<wchar_t>; +#endif + + // ofstream + template class basic_ofstream<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ofstream<wchar_t>; +#endif + + // fstream + template class basic_fstream<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_fstream<wchar_t>; +#endif +} //std diff --git a/libstdc++-v3/src/globals.cc b/libstdc++-v3/src/globals.cc index 2c80abd6937..36d193fb406 100644 --- a/libstdc++-v3/src/globals.cc +++ b/libstdc++-v3/src/globals.cc @@ -1,4 +1,4 @@ -// 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 @@ -30,6 +30,8 @@ #include <fstream> #include <istream> #include <ostream> +#include <locale> +#include <ext/stdio_filebuf.h> // On AIX, and perhaps other systems, library initialization order is // not guaranteed. For example, the static initializers for the main @@ -45,14 +47,125 @@ namespace std { // Standard "C" locale. + typedef char fake_locale[sizeof(locale)] + __attribute__ ((aligned(__alignof__(locale)))); + fake_locale c_locale; + typedef char fake_locale_Impl[sizeof(locale::_Impl)] __attribute__ ((aligned(__alignof__(locale::_Impl)))); - fake_locale_Impl locale_impl_c; + fake_locale_Impl c_locale_impl; + + typedef char fake_facet_vec[sizeof(locale::facet*)] + __attribute__ ((aligned(__alignof__(locale::facet*)))); + fake_facet_vec facet_vec[_GLIBCPP_NUM_FACETS]; - typedef char fake_locale[sizeof(locale)] - __attribute__ ((aligned(__alignof__(locale)))); - fake_locale locale_c; + typedef char fake_ctype_c[sizeof(std::ctype<char>)] + __attribute__ ((aligned(__alignof__(std::ctype<char>)))); + fake_ctype_c ctype_c; + + typedef char fake_collate_c[sizeof(std::collate<char>)] + __attribute__ ((aligned(__alignof__(std::collate<char>)))); + fake_collate_c collate_c; + + typedef char fake_numpunct_c[sizeof(numpunct<char>)] + __attribute__ ((aligned(__alignof__(numpunct<char>)))); + fake_numpunct_c numpunct_c; + + typedef char fake_num_get_c[sizeof(num_get<char>)] + __attribute__ ((aligned(__alignof__(num_get<char>)))); + fake_num_get_c num_get_c; + + typedef char fake_num_put_c[sizeof(num_put<char>)] + __attribute__ ((aligned(__alignof__(num_put<char>)))); + fake_num_put_c num_put_c; + + typedef char fake_codecvt_c[sizeof(codecvt<char, char, mbstate_t>)] + __attribute__ ((aligned(__alignof__(codecvt<char, char, mbstate_t>)))); + fake_codecvt_c codecvt_c; + + typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)] + __attribute__ ((aligned(__alignof__(moneypunct<char, true>)))); + fake_moneypunct_c moneypunct_tc; + fake_moneypunct_c moneypunct_fc; + + typedef char fake_money_get_c[sizeof(money_get<char>)] + __attribute__ ((aligned(__alignof__(money_get<char>)))); + fake_money_get_c money_get_c; + typedef char fake_money_put_c[sizeof(money_put<char>)] + __attribute__ ((aligned(__alignof__(money_put<char>)))); + fake_money_put_c money_put_c; + + typedef char fake_timepunct_c[sizeof(__timepunct<char>)] + __attribute__ ((aligned(__alignof__(__timepunct<char>)))); + fake_timepunct_c timepunct_c; + + typedef char fake_time_get_c[sizeof(time_get<char>)] + __attribute__ ((aligned(__alignof__(time_get<char>)))); + fake_time_get_c time_get_c; + + typedef char fake_time_put_c[sizeof(time_put<char>)] + __attribute__ ((aligned(__alignof__(time_put<char>)))); + fake_time_put_c time_put_c; + + typedef char fake_messages_c[sizeof(messages<char>)] + __attribute__ ((aligned(__alignof__(messages<char>)))); + fake_messages_c messages_c; + +#ifdef _GLIBCPP_USE_WCHAR_T + typedef char fake_wtype_w[sizeof(std::ctype<wchar_t>)] + __attribute__ ((aligned(__alignof__(std::ctype<wchar_t>)))); + fake_wtype_w ctype_w; + + typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)] + __attribute__ ((aligned(__alignof__(std::collate<wchar_t>)))); + fake_wollate_w collate_w; + + typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)] + __attribute__ ((aligned(__alignof__(numpunct<wchar_t>)))); + fake_numpunct_w numpunct_w; + + typedef char fake_num_get_w[sizeof(num_get<wchar_t>)] + __attribute__ ((aligned(__alignof__(num_get<wchar_t>)))); + fake_num_get_w num_get_w; + + typedef char fake_num_put_w[sizeof(num_put<wchar_t>)] + __attribute__ ((aligned(__alignof__(num_put<wchar_t>)))); + fake_num_put_w num_put_w; + + typedef char fake_wodecvt_w[sizeof(codecvt<wchar_t, char, mbstate_t>)] + __attribute__ ((aligned(__alignof__(codecvt<wchar_t, char, mbstate_t>)))); + fake_wodecvt_w codecvt_w; + + typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)] + __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>)))); + fake_moneypunct_w moneypunct_tw; + fake_moneypunct_w moneypunct_fw; + + typedef char fake_money_get_w[sizeof(money_get<wchar_t>)] + __attribute__ ((aligned(__alignof__(money_get<wchar_t>)))); + fake_money_get_w money_get_w; + + typedef char fake_money_put_w[sizeof(money_put<wchar_t>)] + __attribute__ ((aligned(__alignof__(money_put<wchar_t>)))); + fake_money_put_w money_put_w; + + typedef char fake_timepunct_w[sizeof(__timepunct<wchar_t>)] + __attribute__ ((aligned(__alignof__(__timepunct<wchar_t>)))); + fake_timepunct_w timepunct_w; + + typedef char fake_time_get_w[sizeof(time_get<wchar_t>)] + __attribute__ ((aligned(__alignof__(time_get<wchar_t>)))); + fake_time_get_w time_get_w; + + typedef char fake_time_put_w[sizeof(time_put<wchar_t>)] + __attribute__ ((aligned(__alignof__(time_put<wchar_t>)))); + fake_time_put_w time_put_w; + + typedef char fake_messages_w[sizeof(messages<wchar_t>)] + __attribute__ ((aligned(__alignof__(messages<wchar_t>)))); + fake_messages_w messages_w; +#endif // Standard stream objects. typedef char fake_istream[sizeof(istream)] @@ -64,8 +177,8 @@ namespace std fake_ostream cerr; fake_ostream clog; - typedef char fake_filebuf[sizeof(filebuf)] - __attribute__ ((aligned(__alignof__(filebuf)))); + typedef char fake_filebuf[sizeof(__gnu_cxx::stdio_filebuf<char>)] + __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf<char>)))); fake_filebuf buf_cout; fake_filebuf buf_cin; fake_filebuf buf_cerr; @@ -80,8 +193,8 @@ namespace std fake_wostream wcerr; fake_wostream wclog; - typedef char fake_wfilebuf[sizeof(wfilebuf)] - __attribute__ ((aligned(__alignof__(wfilebuf)))); + typedef char fake_wfilebuf[sizeof(__gnu_cxx::stdio_filebuf<wchar_t>)] + __attribute__ ((aligned(__alignof__(__gnu_cxx::stdio_filebuf<wchar_t>)))); fake_wfilebuf buf_wcout; fake_wfilebuf buf_wcin; fake_wfilebuf buf_wcerr; diff --git a/libstdc++-v3/src/io-inst.cc b/libstdc++-v3/src/io-inst.cc new file mode 100644 index 00000000000..f5773c93046 --- /dev/null +++ b/libstdc++-v3/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 <ios> +#include <iomanip> +#include <iostream> + +namespace std +{ + // basic_ios + template class basic_ios<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ios<wchar_t>; +#endif + + // iomanip + template class _Setfill<char>; + template _Setfill<char> setfill(char); +#ifdef _GLIBCPP_USE_WCHAR_T + template class _Setfill<wchar_t>; + template _Setfill<wchar_t> setfill(wchar_t); +#endif + + // iostream + template class basic_iostream<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_iostream<wchar_t>; +#endif +} //std diff --git a/libstdc++-v3/src/ios.cc b/libstdc++-v3/src/ios.cc index e8122bb2b77..c1167f8c15c 100644 --- a/libstdc++-v3/src/ios.cc +++ b/libstdc++-v3/src/ios.cc @@ -36,8 +36,8 @@ #include <ostream> #include <istream> #include <fstream> - #include <bits/atomicity.h> +#include <ext/stdio_filebuf.h> namespace std { @@ -46,18 +46,21 @@ namespace std extern ostream cout; extern ostream cerr; extern ostream clog; - extern filebuf buf_cout; - extern filebuf buf_cin; - extern filebuf buf_cerr; + + using __gnu_cxx::stdio_filebuf; + extern stdio_filebuf<char> buf_cout; + extern stdio_filebuf<char> buf_cin; + extern stdio_filebuf<char> buf_cerr; #ifdef _GLIBCPP_USE_WCHAR_T extern wistream wcin; extern wostream wcout; extern wostream wcerr; extern wostream wclog; - extern wfilebuf buf_wcout; - extern wfilebuf buf_wcin; - extern wfilebuf buf_wcerr; + + extern stdio_filebuf<wchar_t> buf_wcout; + extern stdio_filebuf<wchar_t> buf_wcin; + extern stdio_filebuf<wchar_t> buf_wcerr; #endif // Definitions for static const data members of __ios_flags. @@ -127,7 +130,7 @@ namespace std const ios_base::seekdir ios_base::cur; const ios_base::seekdir ios_base::end; - const int ios_base::_S_local_words; + const int ios_base::_S_local_word_size; int ios_base::Init::_S_ios_base_init = 0; bool ios_base::Init::_S_synced_with_stdio = true; @@ -147,23 +150,15 @@ namespace std void ios_base::Init::_S_ios_create(bool __sync) { - int __out_bufsize = __sync ? 0 : static_cast<int>(BUFSIZ); - int __in_bufsize = __sync ? 1 : static_cast<int>(BUFSIZ); - -#if _GLIBCPP_AVOID_FSEEK - // Platforms that prefer to avoid fseek() calls on streams only - // get their desire when the C++-layer input buffer size is 1. - // This hack hurts performance but keeps correctness across - // all types of streams that might be attached to (e.g.) cin. - __in_bufsize = 1; -#endif + int __out_size = __sync ? 0 : static_cast<int>(BUFSIZ); + int __in_size = __sync ? 1 : static_cast<int>(BUFSIZ); // NB: The file globals.cc creates the four standard files // with NULL buffers. At this point, we swap out the dummy NULL // [io]stream objects and buffers with the real deal. - new (&buf_cout) filebuf(stdout, ios_base::out, __out_bufsize); - new (&buf_cin) filebuf(stdin, ios_base::in, __in_bufsize); - new (&buf_cerr) filebuf(stderr, ios_base::out, __out_bufsize); + new (&buf_cout) stdio_filebuf<char>(stdout, ios_base::out, __out_size); + new (&buf_cin) stdio_filebuf<char>(stdin, ios_base::in, __in_size); + new (&buf_cerr) stdio_filebuf<char>(stderr, ios_base::out, __out_size); new (&cout) ostream(&buf_cout); new (&cin) istream(&buf_cin); new (&cerr) ostream(&buf_cerr); @@ -172,9 +167,9 @@ namespace std cerr.flags(ios_base::unitbuf); #ifdef _GLIBCPP_USE_WCHAR_T - new (&buf_wcout) wfilebuf(stdout, ios_base::out, __out_bufsize); - new (&buf_wcin) wfilebuf(stdin, ios_base::in, __in_bufsize); - new (&buf_wcerr) wfilebuf(stderr, ios_base::out, __out_bufsize); + new (&buf_wcout) stdio_filebuf<wchar_t>(stdout, ios_base::out, __out_size); + new (&buf_wcin) stdio_filebuf<wchar_t>(stdin, ios_base::in, __in_size); + new (&buf_wcerr) stdio_filebuf<wchar_t>(stderr, ios_base::out, __out_size); new (&wcout) wostream(&buf_wcout); new (&wcin) wistream(&buf_wcin); new (&wcerr) wostream(&buf_wcerr); @@ -190,19 +185,14 @@ namespace std // Explicitly call dtors to free any memory that is dynamically // allocated by filebuf ctor or member functions, but don't // deallocate all memory by calling operator delete. - cout.flush(); - cerr.flush(); - clog.flush(); - buf_cout.~filebuf(); - buf_cin.~filebuf(); - buf_cerr.~filebuf(); + buf_cout.~stdio_filebuf(); + buf_cin.~stdio_filebuf(); + buf_cerr.~stdio_filebuf(); + #ifdef _GLIBCPP_USE_WCHAR_T - wcout.flush(); - wcerr.flush(); - wclog.flush(); - buf_wcout.~wfilebuf(); - buf_wcin.~wfilebuf(); - buf_wcerr.~wfilebuf(); + buf_wcout.~stdio_filebuf(); + buf_wcin.~stdio_filebuf(); + buf_wcerr.~stdio_filebuf(); #endif } @@ -227,44 +217,52 @@ namespace std int ios_base::xalloc() throw() { - // XXX should be a symbol. (Reserve 0..3 for builtins.) - static _Atomic_word top = 0; - return __exchange_and_add(&top, 1) + 4; // Implementation note: Initialize top to zero to ensure that // initialization occurs before main() is started. + static _Atomic_word _S_top = 0; + return __exchange_and_add(&_S_top, 1) + 4; } // 27.4.2.5 iword/pword storage ios_base::_Words& ios_base::_M_grow_words(int ix) { - // Precondition: _M_word_limit <= ix - _Words zero = { 0, 0 }; - int newlimit = _S_local_words; - _Words* words = _M_word_array; - int i = 0; - if (_S_local_words <= ix) + // Precondition: _M_word_size <= ix + int newsize = _S_local_word_size; + _Words* words = _M_local_word; + if (ix > _S_local_word_size - 1) { - newlimit = ix+1; - try - { words = new _Words[ix+1]; } - catch (...) + if (ix < numeric_limits<int>::max()) + { + newsize = ix + 1; + try + { words = new _Words[newsize]; } + catch (...) + { + delete [] _M_word; + _M_word = 0; + _M_streambuf_state |= badbit; + if (_M_streambuf_state & _M_exception) + __throw_ios_failure("ios_base::_M_grow_words failure"); + return _M_word_zero; + } + for (int i = 0; i < _M_word_size; i++) + words[i] = _M_word[i]; + if (_M_word && _M_word != _M_local_word) + { + delete [] _M_word; + _M_word = 0; + } + } + else { - _M_dummy = zero; // XXX MT? Not on "normal" machines. - // XXX now in basic_ios - // _M_clear(_M_rdstate() | badbit); // may throw - return _M_dummy; + _M_streambuf_state |= badbit; + return _M_word_zero; } - for (; i < _M_word_limit; i++) - words[i] = _M_words[i]; - if (_M_words != _M_word_array) - delete [] _M_words; } - - do { words[i] = zero; } while (++i < newlimit); - _M_words = words; - _M_word_limit = newlimit; - return words[ix]; + _M_word = words; + _M_word_size = newsize; + return _M_word[ix]; } // Called only by basic_ios<>::init. @@ -276,10 +274,8 @@ namespace std _M_width = 0; _M_flags = skipws | dec; _M_callbacks = 0; - _M_words = 0; - _M_word_limit = 0; + _M_word_size = 0; _M_ios_locale = locale(); - // No init needed for _M_word_array or _M_dummy. } // 27.4.2.3 ios_base locale functions @@ -292,9 +288,11 @@ namespace std return __old; } - ios_base::ios_base() + ios_base::ios_base() : _M_callbacks(0), _M_word(0) { - // Do nothing; init() does it. Static init to 0 makes everything sane. + // Do nothing: basic_ios::init() does it. + // NB: _M_callbacks and _M_word must be zero for non-initialized + // ios_base to go through ~ios_base gracefully. } // 27.4.2.7 ios_base constructors/destructors @@ -302,9 +300,11 @@ namespace std { _M_call_callbacks(erase_event); _M_dispose_callbacks(); - if (_M_words != _M_word_array) - delete [] _M_words; - // XXX done? + if (_M_word && _M_word != _M_local_word) + { + delete [] _M_word; + _M_word = 0; + } } void @@ -314,13 +314,14 @@ namespace std void ios_base::_M_call_callbacks(event __e) throw() { - for (_Callback_list* __p = _M_callbacks; __p; __p = __p->_M_next) + _Callback_list* __p = _M_callbacks; + while (__p) { - try { - (*__p->_M_fn) (__e, *this, __p->_M_index); - } - catch (...) { - } + try + { (*__p->_M_fn) (__e, *this, __p->_M_index); } + catch (...) + { } + __p = __p->_M_next; } } @@ -356,4 +357,3 @@ namespace std return __ret; } } // namespace std - diff --git a/libstdc++-v3/src/istream-inst.cc b/libstdc++-v3/src/istream-inst.cc new file mode 100644 index 00000000000..61125097db1 --- /dev/null +++ b/libstdc++-v3/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 <istream> +#include <iomanip> + +namespace std +{ + // istream + template class basic_istream<char>; + 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<char>); + 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<wchar_t>; + template wistream& ws(wistream&); + template wistream& operator>>(wistream&, wchar_t&); + template wistream& operator>>(wistream&, wchar_t*); + + template wistream& operator>>(wistream&, _Setfill<wchar_t>); + 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/libstdc++-v3/src/limits.cc b/libstdc++-v3/src/limits.cc index 3fc3dcb8fb3..294673ea186 100644 --- a/libstdc++-v3/src/limits.cc +++ b/libstdc++-v3/src/limits.cc @@ -1,6 +1,6 @@ // Static data members of -*- C++ -*- numeric_limits classes -// Copyright (C) 1999, 2001 Free Software Foundation, Inc. +// Copyright (C) 1999, 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 @@ -38,6 +38,29 @@ namespace std { + const bool __numeric_limits_base::is_specialized; + const int __numeric_limits_base::digits; + const int __numeric_limits_base::digits10; + const bool __numeric_limits_base::is_signed; + const bool __numeric_limits_base::is_integer; + const bool __numeric_limits_base::is_exact; + const int __numeric_limits_base::radix; + const int __numeric_limits_base::min_exponent; + const int __numeric_limits_base::min_exponent10; + const int __numeric_limits_base::max_exponent; + const int __numeric_limits_base::max_exponent10; + const bool __numeric_limits_base::has_infinity; + const bool __numeric_limits_base::has_quiet_NaN; + const bool __numeric_limits_base::has_signaling_NaN; + const float_denorm_style __numeric_limits_base::has_denorm; + const bool __numeric_limits_base::has_denorm_loss; + const bool __numeric_limits_base::is_iec559; + const bool __numeric_limits_base::is_bounded; + const bool __numeric_limits_base::is_modulo; + const bool __numeric_limits_base::traps; + const bool __numeric_limits_base::tinyness_before; + const float_round_style __numeric_limits_base::round_style; + // bool const bool numeric_limits<bool>::is_specialized; const int numeric_limits<bool>::digits; diff --git a/libstdc++-v3/src/locale-inst.cc b/libstdc++-v3/src/locale-inst.cc index 324b07e9369..10f45eca0a0 100644 --- a/libstdc++-v3/src/locale-inst.cc +++ b/libstdc++-v3/src/locale-inst.cc @@ -43,126 +43,124 @@ namespace std { - typedef ostreambuf_iterator<char> obuf_iterator; - typedef istreambuf_iterator<char> ibuf_iterator; - typedef ostreambuf_iterator<wchar_t> wobuf_iterator; - typedef istreambuf_iterator<wchar_t> wibuf_iterator; - // moneypunct, money_get, and money_put template class moneypunct<char, false>; template class moneypunct<char, true>; template class moneypunct_byname<char, false>; template class moneypunct_byname<char, true>; - template class money_get<char, ibuf_iterator>; - template class money_put<char, obuf_iterator>; + template class money_get<char, istreambuf_iterator<char> >; + template class money_put<char, ostreambuf_iterator<char> >; #ifdef _GLIBCPP_USE_WCHAR_T template class moneypunct<wchar_t, false>; template class moneypunct<wchar_t, true>; template class moneypunct_byname<wchar_t, false>; template class moneypunct_byname<wchar_t, true>; - template class money_get<wchar_t, wibuf_iterator>; - template class money_put<wchar_t, wobuf_iterator>; + template class money_get<wchar_t, istreambuf_iterator<wchar_t> >; + template class money_put<wchar_t, ostreambuf_iterator<wchar_t> >; #endif // numpunct, numpunct_byname, num_get, and num_put template class numpunct<char>; template class numpunct_byname<char>; - template class num_get<char, ibuf_iterator>; - template class num_put<char, obuf_iterator>; + template class num_get<char, istreambuf_iterator<char> >; + template class num_put<char, ostreambuf_iterator<char> >; template - obuf_iterator - num_put<char, obuf_iterator>:: - _M_convert_int(obuf_iterator, ios_base&, char, char, char, long) const; + ostreambuf_iterator<char> + num_put<char, ostreambuf_iterator<char> >:: + _M_convert_int(ostreambuf_iterator<char>, ios_base&, char, char, char, + long) const; template - obuf_iterator - num_put<char, obuf_iterator>:: - _M_convert_int(obuf_iterator, ios_base&, char, char, char, + ostreambuf_iterator<char> + num_put<char, ostreambuf_iterator<char> >:: + _M_convert_int(ostreambuf_iterator<char>, ios_base&, char, char, char, unsigned long) const; #ifdef _GLIBCPP_USE_LONG_LONG template - obuf_iterator - num_put<char, obuf_iterator>:: - _M_convert_int(obuf_iterator, ios_base&, char, char, char, + ostreambuf_iterator<char> + num_put<char, ostreambuf_iterator<char> >:: + _M_convert_int(ostreambuf_iterator<char>, ios_base&, char, char, char, long long) const; template - obuf_iterator - num_put<char, obuf_iterator>:: - _M_convert_int(obuf_iterator, ios_base&, char, char, char, + ostreambuf_iterator<char> + num_put<char, ostreambuf_iterator<char> >:: + _M_convert_int(ostreambuf_iterator<char>, ios_base&, char, char, char, unsigned long long) const; #endif template - obuf_iterator - num_put<char, obuf_iterator>:: - _M_convert_float(obuf_iterator, ios_base&, char, char, double) const; + ostreambuf_iterator<char> + num_put<char, ostreambuf_iterator<char> >:: + _M_convert_float(ostreambuf_iterator<char>, ios_base&, char, char, + double) const; template - obuf_iterator - num_put<char, obuf_iterator>:: - _M_convert_float(obuf_iterator, ios_base&, char, char, + ostreambuf_iterator<char> + num_put<char, ostreambuf_iterator<char> >:: + _M_convert_float(ostreambuf_iterator<char>, ios_base&, char, char, long double) const; #ifdef _GLIBCPP_USE_WCHAR_T template class numpunct<wchar_t>; template class numpunct_byname<wchar_t>; - template class num_get<wchar_t, wibuf_iterator>; - template class num_put<wchar_t, wobuf_iterator>; + template class num_get<wchar_t, istreambuf_iterator<wchar_t> >; + template class num_put<wchar_t, ostreambuf_iterator<wchar_t> >; template - wobuf_iterator - num_put<wchar_t, wobuf_iterator>:: - _M_convert_int(wobuf_iterator, ios_base&, wchar_t, char, char, long) const; + ostreambuf_iterator<wchar_t> + num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: + _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, + char, long) const; template - wobuf_iterator - num_put<wchar_t, wobuf_iterator>:: - _M_convert_int(wobuf_iterator, ios_base&, wchar_t, char, char, - unsigned long) const; + ostreambuf_iterator<wchar_t> + num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: + _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, + char, unsigned long) const; #ifdef _GLIBCPP_USE_LONG_LONG template - wobuf_iterator - num_put<wchar_t, wobuf_iterator>:: - _M_convert_int(wobuf_iterator, ios_base&, wchar_t, char, char, - long long) const; + ostreambuf_iterator<wchar_t> + num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: + _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, + char, long long) const; template - wobuf_iterator - num_put<wchar_t, wobuf_iterator>:: - _M_convert_int(wobuf_iterator, ios_base&, wchar_t, char, char, - unsigned long long) const; + ostreambuf_iterator<wchar_t> + num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: + _M_convert_int(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, + char, unsigned long long) const; #endif template - wobuf_iterator - num_put<wchar_t, wobuf_iterator>:: - _M_convert_float(wobuf_iterator, ios_base&, wchar_t, char, + ostreambuf_iterator<wchar_t> + num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: + _M_convert_float(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, double) const; template - wobuf_iterator - num_put<wchar_t, wobuf_iterator>:: - _M_convert_float(wobuf_iterator, ios_base&, wchar_t, char, + ostreambuf_iterator<wchar_t> + num_put<wchar_t, ostreambuf_iterator<wchar_t> >:: + _M_convert_float(ostreambuf_iterator<wchar_t>, ios_base&, wchar_t, char, long double) const; #endif // time_get and time_put template class __timepunct<char>; - template class time_put<char, obuf_iterator>; - template class time_put_byname<char, obuf_iterator>; - template class time_get<char, ibuf_iterator>; - template class time_get_byname<char, ibuf_iterator>; + template class time_put<char, ostreambuf_iterator<char> >; + template class time_put_byname<char, ostreambuf_iterator<char> >; + template class time_get<char, istreambuf_iterator<char> >; + template class time_get_byname<char, istreambuf_iterator<char> >; #ifdef _GLIBCPP_USE_WCHAR_T template class __timepunct<wchar_t>; - template class time_put<wchar_t, wobuf_iterator>; - template class time_put_byname<wchar_t, wobuf_iterator>; - template class time_get<wchar_t, wibuf_iterator>; - template class time_get_byname<wchar_t, wibuf_iterator>; + template class time_put<wchar_t, ostreambuf_iterator<wchar_t> >; + template class time_put_byname<wchar_t, ostreambuf_iterator<wchar_t> >; + template class time_get<wchar_t, istreambuf_iterator<wchar_t> >; + template class time_get_byname<wchar_t, istreambuf_iterator<wchar_t> >; #endif // messages @@ -183,9 +181,9 @@ namespace std // codecvt inline template class __codecvt_abstract_base<char, char, mbstate_t>; - inline template class __codecvt_abstract_base<wchar_t, char, mbstate_t>; template class codecvt_byname<char, char, mbstate_t>; #ifdef _GLIBCPP_USE_WCHAR_T + inline template class __codecvt_abstract_base<wchar_t, char, mbstate_t>; template class codecvt_byname<wchar_t, char, mbstate_t>; #endif @@ -198,18 +196,7 @@ namespace std #endif // use_facet - template - const numpunct<char>& - use_facet<numpunct<char> >(const locale&); - - template - const num_put<char, obuf_iterator >& - use_facet<num_put<char, obuf_iterator> >(const locale&); - - template - const num_get<char, ibuf_iterator >& - use_facet<num_get<char, ibuf_iterator> >(const locale&); - + // NB: use_facet<ctype> is specialized template const codecvt<char, char, mbstate_t>& use_facet<codecvt<char, char, mbstate_t> >(const locale&); @@ -219,6 +206,18 @@ namespace std use_facet<collate<char> >(const locale&); template + const numpunct<char>& + use_facet<numpunct<char> >(const locale&); + + template + const num_put<char>& + use_facet<num_put<char> >(const locale&); + + template + const num_get<char>& + use_facet<num_get<char> >(const locale&); + + template const moneypunct<char, true>& use_facet<moneypunct<char, true> >(const locale&); @@ -226,23 +225,31 @@ namespace std const moneypunct<char, false>& use_facet<moneypunct<char, false> >(const locale&); + template + const money_put<char>& + use_facet<money_put<char> >(const locale&); + + template + const money_get<char>& + use_facet<money_get<char> >(const locale&); + template const __timepunct<char>& use_facet<__timepunct<char> >(const locale&); -#ifdef _GLIBCPP_USE_WCHAR_T - template - const numpunct<wchar_t>& - use_facet<numpunct<wchar_t> >(const locale&); + template + const time_put<char>& + use_facet<time_put<char> >(const locale&); template - const num_put<wchar_t, wobuf_iterator>& - use_facet<num_put<wchar_t, wobuf_iterator> >(const locale&); + const time_get<char>& + use_facet<time_get<char> >(const locale&); template - const num_get<wchar_t, wibuf_iterator>& - use_facet<num_get<wchar_t, wibuf_iterator> >(const locale&); + const messages<char>& + use_facet<messages<char> >(const locale&); +#ifdef _GLIBCPP_USE_WCHAR_T template const codecvt<wchar_t, char, mbstate_t>& use_facet<codecvt<wchar_t, char, mbstate_t> >(locale const&); @@ -252,78 +259,158 @@ namespace std use_facet<collate<wchar_t> >(const locale&); template + const numpunct<wchar_t>& + use_facet<numpunct<wchar_t> >(const locale&); + + template + const num_put<wchar_t>& + use_facet<num_put<wchar_t> >(const locale&); + + template + const num_get<wchar_t>& + use_facet<num_get<wchar_t> >(const locale&); + + template const moneypunct<wchar_t, true>& use_facet<moneypunct<wchar_t, true> >(const locale&); template const moneypunct<wchar_t, false>& use_facet<moneypunct<wchar_t, false> >(const locale&); + + template + const money_put<wchar_t>& + use_facet<money_put<wchar_t> >(const locale&); + + template + const money_get<wchar_t>& + use_facet<money_get<wchar_t> >(const locale&); template const __timepunct<wchar_t>& use_facet<__timepunct<wchar_t> >(const locale&); + + template + const time_put<wchar_t>& + use_facet<time_put<wchar_t> >(const locale&); + + template + const time_get<wchar_t>& + use_facet<time_get<wchar_t> >(const locale&); + + template + const messages<wchar_t>& + use_facet<messages<wchar_t> >(const locale&); #endif // has_facet template bool + has_facet<ctype<char> >(const locale&); + + template + bool + has_facet<codecvt<char, char, mbstate_t> >(const locale&); + + template + bool + has_facet<collate<char> >(const locale&); + + template + bool has_facet<numpunct<char> >(const locale&); + template bool has_facet<num_put<char> >(const locale&); + template bool has_facet<num_get<char> >(const locale&); + template bool - has_facet<ctype<char> >(const locale&); + has_facet<moneypunct<char> >(const locale&); + + template + bool + has_facet<money_put<char> >(const locale&); + + template + bool + has_facet<money_get<char> >(const locale&); + + template + bool + has_facet<__timepunct<char> >(const locale&); + + template + bool + has_facet<time_put<char> >(const locale&); + + template + bool + has_facet<time_get<char> >(const locale&); + + template + bool + has_facet<messages<char> >(const locale&); #ifdef _GLIBCPP_USE_WCHAR_T + template + bool + has_facet<ctype<wchar_t> >(const locale&); + + template + bool + has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&); + + template + bool + has_facet<collate<wchar_t> >(const locale&); + template bool has_facet<numpunct<wchar_t> >(const locale&); + template bool has_facet<num_put<wchar_t> >(const locale&); + template bool has_facet<num_get<wchar_t> >(const locale&); + template bool - has_facet<ctype<wchar_t> >(const locale&); -#endif + has_facet<moneypunct<wchar_t> >(const locale&); - // - // iterator - // - typedef vector<locale::facet*> vec_pfacet; template - void - vec_pfacet:: - insert(vec_pfacet::iterator, vec_pfacet::size_type, - const vec_pfacet::value_type&); + bool + has_facet<money_put<wchar_t> >(const locale&); + template - void - vec_pfacet:: - _M_fill_insert(vec_pfacet::iterator, vec_pfacet::size_type, - const vec_pfacet::value_type&); + bool + has_facet<money_get<wchar_t> >(const locale&); + template + bool + has_facet<__timepunct<wchar_t> >(const locale&); - // - // locale - // - typedef istreambuf_iterator<char, char_traits<char> > istreambuf_iter; - typedef ostreambuf_iterator<char, char_traits<char> > ostreambuf_iter; + template + bool + has_facet<time_put<wchar_t> >(const locale&); -#ifdef _GLIBCPP_USE_WCHAR_T - typedef istreambuf_iterator<wchar_t, char_traits<wchar_t> > wistreambuf_iter; - typedef ostreambuf_iterator<wchar_t, char_traits<wchar_t> > wostreambuf_iter; -#endif + template + bool + has_facet<time_get<wchar_t> >(const locale&); template bool - locale::operator()(const string&, const string&) const; + has_facet<messages<wchar_t> >(const locale&); +#endif + // locale template char* __add_grouping<char>(char*, char, char const*, char const*, @@ -344,12 +431,6 @@ namespace std streamsize, streamsize, const bool); #ifdef _GLIBCPP_USE_WCHAR_T - template - bool - locale::operator()(const wstring&, const wstring&) const; - - typedef ostreambuf_iterator<wchar_t> wostreambuf_iter; - template wchar_t* __add_grouping<wchar_t>(wchar_t*, wchar_t, char const*, char const*, @@ -373,43 +454,27 @@ namespace std template int - __convert_from_v(char*, 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 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 char*, long, const __c_locale&, int); + __convert_from_v(char*, const int, const char*, long, const __c_locale&, int); template int - __convert_from_v(char*, const char*, unsigned long, + __convert_from_v(char*, const int, const char*, unsigned long, const __c_locale&, int); template int - __convert_from_v(char*, const char*, long long, const __c_locale&, int); + __convert_from_v(char*, const int, const char*, long long, const __c_locale&, int); template int - __convert_from_v(char*, const char*, unsigned long long, + __convert_from_v(char*, const int, const char*, unsigned long long, const __c_locale&, int); - - template - locale::facet** - fill_n<locale::facet**, size_t, locale::facet*> - (locale::facet**, size_t, locale::facet* const&); - - template - __normal_iterator<locale::facet**, vector<locale::facet*> > - fill_n(__normal_iterator<locale::facet**, vector<locale::facet*> >, - size_t, locale::facet* const&); - - template - void - fill(__normal_iterator<locale::facet**, vector<locale::facet*> >, - __normal_iterator<locale::facet**, vector<locale::facet*> >, - locale::facet* const&); } // namespace std diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index 789cdf1f430..26c2834eb7d 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -30,24 +30,20 @@ #include <cstring> #include <cassert> #include <cctype> +#include <cwctype> // For towupper, etc. #include <limits> #include <exception> #include <locale> #include <istream> #include <ostream> -#include <vector> -#include <memory> // for auto_ptr -#ifdef _GLIBCPP_USE_WCHAR_T -# include <cwctype> // for towupper, etc. -#endif - #include <bits/atomicity.h> namespace std { // Defined in globals.cc. - extern locale::_Impl locale_impl_c; - extern locale locale_c; + extern locale c_locale; + extern locale::_Impl c_locale_impl; + extern locale::facet** facet_vec; // Definitions for static const data members of locale. const locale::category locale::none; @@ -62,9 +58,8 @@ namespace std locale::_Impl* locale::_S_classic; locale::_Impl* locale::_S_global; const size_t locale::_S_num_categories; - const size_t locale::_S_num_facets; - // Definitions for locale::id of standard facets. + // Definitions for locale::id of standard facets that are specialized. locale::id ctype<char>::id; locale::id codecvt<char, char, mbstate_t>::id; @@ -160,8 +155,8 @@ namespace std locale::_Impl::_S_id_ctype, locale::_Impl::_S_id_numeric, locale::_Impl::_S_id_collate, - locale::_Impl::_S_id_time, locale::_Impl::_S_id_monetary, + locale::_Impl::_S_id_time, locale::_Impl::_S_id_messages, 0 }; @@ -252,7 +247,8 @@ namespace std _Impl* __old = _S_global; __other._M_impl->_M_add_reference(); _S_global = __other._M_impl; - if (_S_global->_M_check_same_name() && _S_global->_M_names[0] != "*") + if (_S_global->_M_check_same_name() + && (strcmp(_S_global->_M_names[0], "*") != 0)) setlocale(LC_ALL, __other.name().c_str()); // Reference count sanity check: one reference removed for the @@ -266,23 +262,26 @@ namespace std string locale::name() const { - string __ret; // Need some kind of separator character. This one was pretty much // arbitrarily chosen as to not conflict with glibc locales: the // exact formatting is not set in stone. const char __separator = '|'; + string __ret; if (_M_impl->_M_check_same_name()) __ret = _M_impl->_M_names[0]; else { for (size_t i = 0; i < _S_num_categories; ++i) - __ret += __separator + _M_impl->_M_names[i]; + { + __ret += __separator; + __ret += _M_impl->_M_names[i]; + } } return __ret; } - locale const& + const locale& locale::classic() { static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER; @@ -294,9 +293,13 @@ namespace std { // 26 Standard facets, 2 references. // One reference for _M_classic, one for _M_global - _S_classic = new (&locale_impl_c) _Impl("C", 2); + facet** f = new(&facet_vec) facet*[_GLIBCPP_NUM_FACETS]; + for (size_t __i = 0; __i < _GLIBCPP_NUM_FACETS; ++__i) + f[__i] = 0; + + _S_classic = new (&c_locale_impl) _Impl(f, 2, true); _S_global = _S_classic; - new (&locale_c) locale(_S_classic); + new (&c_locale) locale(_S_classic); } catch(...) { @@ -308,7 +311,7 @@ namespace std __throw_exception_again; } } - return locale_c; + return c_locale; } locale::category @@ -383,7 +386,8 @@ namespace std } } - locale::id::id() { } + locale::id::id() + { } // Definitions for static const data members of ctype_base. const ctype_base::mask ctype_base::space; @@ -405,7 +409,7 @@ namespace std ctype<char>::~ctype() { - if (_M_c_locale_ctype) + if (_M_c_locale_ctype != _S_c_locale) _S_destroy_c_locale(_M_c_locale_ctype); if (_M_del) delete[] this->table(); @@ -454,20 +458,24 @@ namespace std #ifdef _GLIBCPP_USE_WCHAR_T ctype<wchar_t>::ctype(size_t __refs) : __ctype_abstract_base<wchar_t>(__refs) - { _M_c_locale_ctype = _S_clone_c_locale(_S_c_locale); } + { _M_c_locale_ctype = _S_c_locale; } ctype<wchar_t>::ctype(__c_locale __cloc, size_t __refs) : __ctype_abstract_base<wchar_t>(__refs) { _M_c_locale_ctype = _S_clone_c_locale(__cloc); } ctype<wchar_t>::~ctype() - { _S_destroy_c_locale(_M_c_locale_ctype); } + { + if (_M_c_locale_ctype != _S_c_locale) + _S_destroy_c_locale(_M_c_locale_ctype); + } template<> ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs) : ctype<wchar_t>(__refs) { - _S_destroy_c_locale(_M_c_locale_ctype); + if (_M_c_locale_ctype != _S_c_locale) + _S_destroy_c_locale(_M_c_locale_ctype); _S_create_c_locale(_M_c_locale_ctype, __s); } #endif @@ -499,9 +507,9 @@ namespace std const ctype<char>& use_facet<ctype<char> >(const locale& __loc) { - size_t __i = ctype<char>::id._M_index; + size_t __i = ctype<char>::id._M_id(); const locale::_Impl* __tmp = __loc._M_impl; - return static_cast<const ctype<char>&>(* (*(__tmp->_M_facets))[__i]); + return static_cast<const ctype<char>&>(*(__tmp->_M_facets[__i])); } #ifdef _GLIBCPP_USE_WCHAR_T @@ -509,19 +517,14 @@ namespace std const ctype<wchar_t>& use_facet<ctype<wchar_t> >(const locale& __loc) { - size_t __i = ctype<wchar_t>::id._M_index; + size_t __i = ctype<wchar_t>::id._M_id(); const locale::_Impl* __tmp = __loc._M_impl; - return static_cast<const ctype<wchar_t>&>(* (*(__tmp->_M_facets))[__i]); + return static_cast<const ctype<wchar_t>&>(*(__tmp->_M_facets[__i])); } #endif - const char __num_base::_S_atoms[] = "0123456789eEabcdfABCDF"; - const double __num_base::_S_scale_hex = log(10.0)/log(16.0); - - const double __num_base::_S_scale_oct = log(10.0)/log(8.0); - bool __num_base::_S_format_float(const ios_base& __io, char* __fptr, char __mod, streamsize __prec) @@ -582,3 +585,4 @@ namespace std *__fptr = '\0'; } } // namespace std + diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc index ad816486705..824d9790cef 100644 --- a/libstdc++-v3/src/localename.cc +++ b/libstdc++-v3/src/localename.cc @@ -29,111 +29,186 @@ #include <clocale> #include <cstring> #include <locale> -#include <vector> namespace std { + // Defined in globals.cc. + extern std::ctype<char> ctype_c; + extern std::collate<char> collate_c; + extern numpunct<char> numpunct_c; + extern num_get<char> num_get_c; + extern num_put<char> num_put_c; + extern codecvt<char, char, mbstate_t> codecvt_c; + extern moneypunct<char, false> moneypunct_fc; + extern moneypunct<char, true> moneypunct_tc; + extern money_get<char> money_get_c; + extern money_put<char> money_put_c; + extern __timepunct<char> timepunct_c; + extern time_get<char> time_get_c; + extern time_put<char> time_put_c; + extern std::messages<char> messages_c; +#ifdef _GLIBCPP_USE_WCHAR_T + extern std::ctype<wchar_t> ctype_w; + extern std::collate<wchar_t> collate_w; + extern numpunct<wchar_t> numpunct_w; + extern num_get<wchar_t> num_get_w; + extern num_put<wchar_t> num_put_w; + extern codecvt<wchar_t, char, mbstate_t> codecvt_w; + extern moneypunct<wchar_t, false> moneypunct_fw; + extern moneypunct<wchar_t, true> moneypunct_tw; + extern money_get<wchar_t> money_get_w; + extern money_put<wchar_t> money_put_w; + extern __timepunct<wchar_t> timepunct_w; + extern time_get<wchar_t> time_get_w; + extern time_put<wchar_t> time_put_w; + extern std::messages<wchar_t> messages_w; +#endif + locale::_Impl:: ~_Impl() throw() { - __vec_facet::iterator it = _M_facets->begin(); - for (; it != _M_facets->end(); ++it) - if (*it) - (*it)->_M_remove_reference(); - delete _M_facets; + for (size_t __i = 0; __i < _M_facets_size; ++__i) + if (_M_facets[__i]) + _M_facets[__i]->_M_remove_reference(); + delete [] _M_facets; } // Clone existing _Impl object. locale::_Impl:: _Impl(const _Impl& __imp, size_t __refs) - : _M_references(__refs), _M_facets(0) // XXX + : _M_references(__refs), _M_facets_size(__imp._M_facets_size) // XXX { try - { _M_facets = new __vec_facet(*(__imp._M_facets)); } + { + _M_facets = new facet*[_M_facets_size]; + for (size_t __i = 0; __i < _M_facets_size; ++__i) + _M_facets[__i] = 0; + } catch(...) { - delete _M_facets; + delete [] _M_facets; __throw_exception_again; } - - for (size_t i = 0; i < _S_num_categories; ++i) - _M_names[i] = __imp._M_names[i]; - - __vec_facet::iterator __it = _M_facets->begin(); - for (; __it != _M_facets->end(); ++__it) - if (*__it) - (*__it)->_M_add_reference(); + for (size_t __i = 0; __i < _M_facets_size; ++__i) + { + _M_facets[__i] = __imp._M_facets[__i]; + if (_M_facets[__i]) + _M_facets[__i]->_M_add_reference(); + } + for (size_t __i = 0; __i < _S_num_categories; ++__i) + _M_names[__i] = __imp._M_names[__i]; } - // Construct named _Impl, including the standard "C" locale. + // Construct named _Impl. locale::_Impl:: - _Impl(string __str, size_t __refs) - : _M_references(__refs), _M_facets(0) + _Impl(const char* __s, size_t __refs) + : _M_references(__refs), _M_facets_size(_GLIBCPP_NUM_FACETS) // XXX { - // Initialize the underlying locale model, which also checks to - // see if the given name is valid. + // Initialize the underlying locale model, which also checks + // to see if the given name is valid. __c_locale __cloc; - locale::facet::_S_create_c_locale(__cloc, __str.c_str()); + locale::facet::_S_create_c_locale(__cloc, __s); - // This is needed as presently "C" locales != required data in - // __timepunct, numpunct, and moneypunct. - __c_locale __cloc_c = NULL; - if (__str != "C" && __str != "POSIX") - __cloc_c = __cloc; - - // Allocate facet container. try - { _M_facets = new __vec_facet(_S_num_facets, NULL); } + { + _M_facets = new facet*[_M_facets_size]; + for (size_t __i = 0; __i < _M_facets_size; ++__i) + _M_facets[__i] = 0; + } catch(...) { - delete _M_facets; + delete [] _M_facets; __throw_exception_again; } // Name all the categories. for (size_t i = 0; i < _S_num_categories; ++i) - _M_names[i] = __str; + _M_names[i] = __s; // Construct all standard facets and add them to _M_facets. - _M_init_facet(new std::collate<char>(__cloc)); _M_init_facet(new std::ctype<char>(__cloc)); _M_init_facet(new codecvt<char, char, mbstate_t>); - _M_init_facet(new moneypunct<char, false>(__cloc_c)); - _M_init_facet(new moneypunct<char, true>(__cloc_c)); - _M_init_facet(new money_get<char>); - _M_init_facet(new money_put<char>); - _M_init_facet(new numpunct<char>(__cloc_c)); + _M_init_facet(new numpunct<char>(__cloc)); _M_init_facet(new num_get<char>); _M_init_facet(new num_put<char>); - _M_init_facet(new __timepunct<char>(__cloc_c, __str.c_str())); + _M_init_facet(new std::collate<char>(__cloc)); + _M_init_facet(new moneypunct<char, false>(__cloc)); + _M_init_facet(new moneypunct<char, true>(__cloc)); + _M_init_facet(new money_get<char>); + _M_init_facet(new money_put<char>); + _M_init_facet(new __timepunct<char>(__cloc, __s)); _M_init_facet(new time_get<char>); _M_init_facet(new time_put<char>); - _M_init_facet(new std::messages<char>(__cloc, __str.c_str())); - + _M_init_facet(new std::messages<char>(__cloc, __s)); + #ifdef _GLIBCPP_USE_WCHAR_T - _M_init_facet(new std::collate<wchar_t>(__cloc)); _M_init_facet(new std::ctype<wchar_t>(__cloc)); _M_init_facet(new codecvt<wchar_t, char, mbstate_t>); - _M_init_facet(new moneypunct<wchar_t, false>(__cloc_c)); - _M_init_facet(new moneypunct<wchar_t, true>(__cloc_c)); - _M_init_facet(new money_get<wchar_t>); - _M_init_facet(new money_put<wchar_t>); - _M_init_facet(new numpunct<wchar_t>(__cloc_c)); + _M_init_facet(new numpunct<wchar_t>(__cloc)); _M_init_facet(new num_get<wchar_t>); _M_init_facet(new num_put<wchar_t>); - _M_init_facet(new __timepunct<wchar_t>(__cloc_c, __str.c_str())); + _M_init_facet(new std::collate<wchar_t>(__cloc)); + _M_init_facet(new moneypunct<wchar_t, false>(__cloc)); + _M_init_facet(new moneypunct<wchar_t, true>(__cloc)); + _M_init_facet(new money_get<wchar_t>); + _M_init_facet(new money_put<wchar_t>); + _M_init_facet(new __timepunct<wchar_t>(__cloc, __s)); _M_init_facet(new time_get<wchar_t>); _M_init_facet(new time_put<wchar_t>); - _M_init_facet(new std::messages<wchar_t>(__cloc, __str.c_str())); + _M_init_facet(new std::messages<wchar_t>(__cloc, __s)); #endif locale::facet::_S_destroy_c_locale(__cloc); } + + // Construct "C" _Impl. + locale::_Impl:: + _Impl(facet** __f, size_t __refs, bool) + : _M_references(__refs), _M_facets(__f), _M_facets_size(_GLIBCPP_NUM_FACETS) + { + // Name all the categories. + for (size_t i = 0; i < _S_num_categories; ++i) + _M_names[i] = "C"; + + // This is needed as presently the C++ version of "C" locales + // != data in the underlying locale model for __timepunct, + // numpunct, and moneypunct. Also, the "C" locales must be + // constructed in a way such that they are pre-allocated. + _M_init_facet(new (&ctype_c) std::ctype<char>); + _M_init_facet(new (&codecvt_c) codecvt<char, char, mbstate_t>); + _M_init_facet(new (&numpunct_c) numpunct<char>); + _M_init_facet(new (&num_get_c) num_get<char>); + _M_init_facet(new (&num_put_c) num_put<char>); + _M_init_facet(new (&collate_c) std::collate<char>); + _M_init_facet(new (&moneypunct_fc) moneypunct<char, false>); + _M_init_facet(new (&moneypunct_tc) moneypunct<char, true>); + _M_init_facet(new (&money_get_c) money_get<char>); + _M_init_facet(new (&money_put_c) money_put<char>); + _M_init_facet(new (&timepunct_c) __timepunct<char>); + _M_init_facet(new (&time_get_c) time_get<char>); + _M_init_facet(new (&time_put_c) time_put<char>); + _M_init_facet(new (&messages_c) std::messages<char>); +#ifdef _GLIBCPP_USE_WCHAR_T + _M_init_facet(new (&ctype_w) std::ctype<wchar_t>); + _M_init_facet(new (&codecvt_w) codecvt<wchar_t, char, mbstate_t>); + _M_init_facet(new (&numpunct_w) numpunct<wchar_t>); + _M_init_facet(new (&num_get_w) num_get<wchar_t>); + _M_init_facet(new (&num_put_w) num_put<wchar_t>); + _M_init_facet(new (&collate_w) std::collate<wchar_t>); + _M_init_facet(new (&moneypunct_fw) moneypunct<wchar_t, false>); + _M_init_facet(new (&moneypunct_tw) moneypunct<wchar_t, true>); + _M_init_facet(new (&money_get_w) money_get<wchar_t>); + _M_init_facet(new (&money_put_w) money_put<wchar_t>); + _M_init_facet(new (&timepunct_w) __timepunct<wchar_t>); + _M_init_facet(new (&time_get_w) time_get<wchar_t>); + _M_init_facet(new (&time_put_w) time_put<wchar_t>); + _M_init_facet(new (&messages_w) std::messages<wchar_t>); +#endif + } void locale::_Impl:: _M_replace_categories(const _Impl* __imp, category __cat) { - const string __none("*"); category __mask; for (unsigned int __ix = 0; __ix < _S_num_categories; ++__ix) { @@ -143,7 +218,8 @@ namespace std // Need to replace entry in _M_facets with other locale's info. _M_replace_category(__imp, _S_facet_categories[__ix]); // If both have names, go ahead and mangle. - if (_M_names[__ix] != __none && __imp->_M_names[__ix] != __none) + if (strcmp(_M_names[__ix], "*") != 0 + && strcmp(__imp->_M_names[__ix], "*") != 0) _M_names[__ix] = __imp->_M_names[__ix]; } } @@ -161,13 +237,10 @@ namespace std locale::_Impl:: _M_replace_facet(const _Impl* __imp, const locale::id* __idp) { - size_t __index = __idp->_M_index; - if (__index == 0 - || __imp->_M_facets->size() <= __index - || (*(__imp->_M_facets))[__index] == 0) + size_t __index = __idp->_M_id(); + if ((__index > (__imp->_M_facets_size - 1)) || !__imp->_M_facets[__index]) __throw_runtime_error("no locale facet"); - - _M_install_facet(__idp, (*(__imp->_M_facets))[__index]); + _M_install_facet(__idp, __imp->_M_facets[__index]); } void @@ -176,18 +249,27 @@ namespace std { if (__fp) { - size_t& __index = __idp->_M_index; - if (!__index) - __index = 1 + __exchange_and_add(&locale::id::_S_highwater, 1); - - if (__index >= _M_facets->size()) - _M_facets->resize(__index + 1, 0); // might throw + size_t __index = __idp->_M_id(); + if (__index > _M_facets_size - 1) + { + facet** __old = _M_facets; + facet** __new; + const size_t __new_size = __index + 4; + __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) + __new[__i2] = 0; + + _M_facets_size = __new_size; + _M_facets = __new; + delete [] __old; + } - facet*& __fpr = (*_M_facets)[__index]; + facet*& __fpr = _M_facets[__index]; if (__fpr) { - // Replacing an existing facet. - // Order matters, here: + // Replacing an existing facet. Order matters. __fp->_M_add_reference(); __fpr->_M_remove_reference(); __fpr = __fp; @@ -197,7 +279,7 @@ namespace std // Installing a newly created facet into an empty // _M_facets container, say a newly-constructed, // swanky-fresh _Impl. - (*_M_facets)[__index] = __fp; + _M_facets[__index] = __fp; } } } diff --git a/libstdc++-v3/src/misc-inst.cc b/libstdc++-v3/src/misc-inst.cc index a276a732ed3..5576d2cb22a 100644 --- a/libstdc++-v3/src/misc-inst.cc +++ b/libstdc++-v3/src/misc-inst.cc @@ -33,172 +33,13 @@ // #include <string> -#include <algorithm> -#include <locale> -#include <vector> -#include <iterator> -#include <streambuf> -#include <sstream> -#include <fstream> -#include <ios> #include <istream> #include <ostream> -#include <iomanip> - -// NB: Unnecessary if the .h headers already include these. -#ifndef _GLIBCPP_FULLY_COMPLIANT_HEADERS -#include <bits/sstream.tcc> -#include <bits/fstream.tcc> -#include <bits/streambuf.tcc> -#include <bits/istream.tcc> -#include <bits/ostream.tcc> -#endif +#include <algorithm> +#include <vector> namespace std { - // streambuf - template class basic_streambuf<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_streambuf<wchar_t>; -#endif - - // stringbuf - template class basic_stringbuf<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_stringbuf<wchar_t>; -#endif - - // filebuf - template class basic_filebuf<char, char_traits<char> >; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_filebuf<wchar_t, char_traits<wchar_t> >; -#endif - - // basic_ios - template class basic_ios<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ios<wchar_t>; -#endif - - // iomanip - template class _Setfill<char>; - template _Setfill<char> setfill(char); -#ifdef _GLIBCPP_USE_WCHAR_T - template class _Setfill<wchar_t>; - template _Setfill<wchar_t> setfill(wchar_t); -#endif - - // istream - template class basic_istream<char>; - 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<char>); - 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<wchar_t>; - template wistream& ws(wistream&); - template wistream& operator>>(wistream&, wchar_t&); - template wistream& operator>>(wistream&, wchar_t*); - - template wistream& operator>>(wistream&, _Setfill<wchar_t>); - 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<char>; - 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<char>); - 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<wchar_t>; - 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<wchar_t>); - 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<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_iostream<wchar_t>; -#endif - - // ifstream - template class basic_ifstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ifstream<wchar_t>; -#endif - - // ofstream - template class basic_ofstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ofstream<wchar_t>; -#endif - - // fstream - template class basic_fstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_fstream<wchar_t>; -#endif - - // istringstream - template class basic_istringstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_istringstream<wchar_t>; -#endif - - // ostringstream - template class basic_ostringstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_ostringstream<wchar_t>; -#endif - - // stringstream - template class basic_stringstream<char>; -#ifdef _GLIBCPP_USE_WCHAR_T - template class basic_stringstream<wchar_t>; -#endif - // string related to iostreams template basic_istream<char>& @@ -227,6 +68,10 @@ namespace std getline(basic_istream<wchar_t>&, wstring&); #endif +#if 1 + // XXX + // 2002-05-24 These are no longer needed and should be deleted. + // algorithm typedef _Char_traits_match<char, char_traits<char> > char_match; @@ -253,15 +98,5 @@ namespace std __uninitialized_copy_aux<vector<string>::const_iterator, string *> (vector<string>::const_iterator, vector<string>::const_iterator, string*, __false_type); - - template - streamsize - __copy_streambufs(basic_ios<char>&, basic_streambuf<char>*, - basic_streambuf<char>*); -#ifdef _GLIBCPP_USE_WCHAR_T - template - streamsize - __copy_streambufs(basic_ios<wchar_t>&, basic_streambuf<wchar_t>*, - basic_streambuf<wchar_t>*); #endif } //std diff --git a/libstdc++-v3/src/ostream-inst.cc b/libstdc++-v3/src/ostream-inst.cc new file mode 100644 index 00000000000..e43b0c7b746 --- /dev/null +++ b/libstdc++-v3/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 <ostream> +#include <iomanip> + +namespace std +{ + // ostream + template class basic_ostream<char>; + 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<char>); + 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<wchar_t>; + 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<wchar_t>); + 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/libstdc++-v3/src/sstream-inst.cc b/libstdc++-v3/src/sstream-inst.cc new file mode 100644 index 00000000000..e341f5fd94b --- /dev/null +++ b/libstdc++-v3/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 <sstream> + +namespace std +{ + // stringbuf + template class basic_stringbuf<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_stringbuf<wchar_t>; +#endif + + // istringstream + template class basic_istringstream<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_istringstream<wchar_t>; +#endif + + // ostringstream + template class basic_ostringstream<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_ostringstream<wchar_t>; +#endif + + // stringstream + template class basic_stringstream<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_stringstream<wchar_t>; +#endif +} //std diff --git a/libstdc++-v3/src/stl-inst.cc b/libstdc++-v3/src/stl-inst.cc index 43cef9e6d2c..d8879a7bccd 100644 --- a/libstdc++-v3/src/stl-inst.cc +++ b/libstdc++-v3/src/stl-inst.cc @@ -33,27 +33,15 @@ #include <bits/c++config.h> #include <memory> -#include <vector> -#include <ostream> -#include <map> namespace std { - const int __stl_threshold = 16; - const int __stl_chunk_size = 7; - const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int)); - const _Rb_tree_Color_type _S_rb_tree_red = false; - const _Rb_tree_Color_type _S_rb_tree_black = true; + template class allocator<char>; + template class allocator<wchar_t>; +#ifdef __USE_MALLOC template class __malloc_alloc_template<0>; - -#ifndef __USE_MALLOC +#else template class __default_alloc_template<true, 0>; #endif - - template - void - vector<unsigned int>:: - _M_insert_aux(vector<unsigned int>::iterator, unsigned int const &); - } // namespace std diff --git a/libstdc++-v3/src/cmath.cc b/libstdc++-v3/src/streambuf-inst.cc index 7a7433a1cf3..438752e7e5b 100644 --- a/libstdc++-v3/src/cmath.cc +++ b/libstdc++-v3/src/streambuf-inst.cc @@ -1,6 +1,7 @@ -// Explicit instantiation file for -*- C++ -*- math library. +// Explicit instantiation file. -// Copyright (C) 2001 Free Software Foundation, Inc. +// 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 @@ -27,21 +28,29 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +// +// ISO C++ 14882: +// -// These are explicit instantiations of the behind-the-scenes internal -// helper functions used in the math routines of libstdc++. - - -#include <cmath> +#include <ios> +#include <streambuf> namespace std { - // This function is only declared/used in the cheaders=c_std case. - template float - __cmath_power<float>(float, unsigned int); - template double - __cmath_power<double>(double, unsigned int); - template long double - __cmath_power<long double>(long double, unsigned int); - -} // namespace std + // streambuf + template class basic_streambuf<char>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class basic_streambuf<wchar_t>; +#endif + + template + streamsize + __copy_streambufs(basic_ios<char>&, basic_streambuf<char>*, + basic_streambuf<char>*); +#ifdef _GLIBCPP_USE_WCHAR_T + template + streamsize + __copy_streambufs(basic_ios<wchar_t>&, basic_streambuf<wchar_t>*, + basic_streambuf<wchar_t>*); +#endif +} //std diff --git a/libstdc++-v3/src/string-inst.cc b/libstdc++-v3/src/string-inst.cc index 7ebc0c5abd3..e812aa0cfc2 100644 --- a/libstdc++-v3/src/string-inst.cc +++ b/libstdc++-v3/src/string-inst.cc @@ -48,9 +48,17 @@ namespace std template class basic_string<C>; template S operator+(const C*, const S&); template S operator+(C, const S&); +} // namespace std + +namespace __gnu_cxx +{ + using std::S; template bool operator==(const S::iterator&, const S::iterator&); template bool operator==(const S::const_iterator&, const S::const_iterator&); +} +namespace std +{ // Only one template keyword allowed here. // See core issue #46 (NAD) // http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#46 diff --git a/libstdc++-v3/src/strstream.cc b/libstdc++-v3/src/strstream.cc index 2160c440be2..961ff039447 100644 --- a/libstdc++-v3/src/strstream.cc +++ b/libstdc++-v3/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. // @@ -56,403 +56,369 @@ 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(streamsize initial_capacity) + : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true), + _M_frozen(false), _M_constant(false) + { + _M_buf_size = _M_buf_size_opt = max(initial_capacity, streamsize(16)); + _M_buf = _M_alloc(_M_buf_size); + if (_M_buf) + { + setp(_M_buf, _M_buf + _M_buf_size); + setg(_M_buf, _M_buf, _M_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(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) + { + _M_buf_size = _M_buf_size_opt = 16; + _M_buf = _M_alloc(_M_buf_size); + if (_M_buf) + { + setp(_M_buf, _M_buf + _M_buf_size); + setg(_M_buf, _M_buf, _M_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<char*>(get), reinterpret_cast<char*>(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<char*>(get), reinterpret_cast<char*>(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<char*>(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<char*>(const_cast<signed char*>(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<char*>(const_cast<unsigned char*>(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(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<char*>(get), reinterpret_cast<char*>(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<char*>(get), reinterpret_cast<char*>(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<char*>(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<char*>(const_cast<signed char*>(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<char*>(const_cast<unsigned char*>(get)), 0, n); } + + strstreambuf::~strstreambuf() + { + if (_M_dynamic && !_M_frozen) + { + char* p = this->eback(); + _M_free(p); + if (p == _M_buf) + _M_buf = 0; } - - 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 (_M_buf) + _M_free(_M_buf); } - if (pptr() != epptr()) { - *pptr() = c; - pbump(1); - return c; + void + strstreambuf::freeze(bool frozenflag) + { + if (_M_dynamic) + _M_frozen = frozenflag; } - 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<int_type>(gptr()[-1])) { // KLUDGE - gbump(-1); - return c; - } - else if (!_M_constant) { - gbump(-1); - *gptr() = c; - return c; - } + char* + strstreambuf::str() + { + freeze(true); + return eback(); } - 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<char, char_traits<char> >* -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)); + 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(); + } + + _M_buf = buf; + _M_buf_size = _M_buf_size_opt = new_size; + 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(); } - 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)); + 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<int_type>(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<char, char_traits<char> >* + 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<char*>(_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<char*>(_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<char>(), basic_istream<char>(0), _M_buf(s, 0) -{ - basic_ios<char>::init(&_M_buf); -} + { basic_ios<char>::init(&_M_buf); } -istrstream::istrstream(const char* s) + istrstream::istrstream(const char* s) : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0) -{ - basic_ios<char>::init(&_M_buf); -} + { basic_ios<char>::init(&_M_buf); } -istrstream::istrstream(char* s, streamsize n) + istrstream::istrstream(char* s, streamsize n) : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n) -{ - basic_ios<char>::init(&_M_buf); -} + { basic_ios<char>::init(&_M_buf); } -istrstream::istrstream(const char* s, streamsize n) + istrstream::istrstream(const char* s, streamsize n) : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n) -{ - basic_ios<char>::init(&_M_buf); -} - -istrstream::~istrstream() {} + { basic_ios<char>::init(&_M_buf); } -strstreambuf* istrstream::rdbuf() const { - return const_cast<strstreambuf*>(&_M_buf); -} + istrstream::~istrstream() { } -char* istrstream::str() { return _M_buf.str(); } + strstreambuf* + istrstream::rdbuf() const + { return const_cast<strstreambuf*>(&_M_buf); } -//---------------------------------------------------------------------- -// Class ostrstream + char* + istrstream::str() + { return _M_buf.str(); } -ostrstream::ostrstream() + ostrstream::ostrstream() : basic_ios<char>(), basic_ostream<char>(0), _M_buf() -{ - basic_ios<char>::init(&_M_buf); -} + { basic_ios<char>::init(&_M_buf); } -ostrstream::ostrstream(char* s, int n, ios_base::openmode mode) - : basic_ios<char>(), basic_ostream<char>(0), + ostrstream::ostrstream(char* s, int n, ios_base::openmode mode) + : basic_ios<char>(), basic_ostream<char>(0), _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s) -{ - basic_ios<char>::init(&_M_buf); -} + { basic_ios<char>::init(&_M_buf); } -ostrstream::~ostrstream() {} + ostrstream::~ostrstream() {} -strstreambuf* ostrstream::rdbuf() const -{ - return const_cast<strstreambuf*>(&_M_buf); -} + strstreambuf* + ostrstream::rdbuf() const + { return const_cast<strstreambuf*>(&_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<char>(), basic_iostream<char>(0), _M_buf() -{ - basic_ios<char>::init(&_M_buf); -} + { basic_ios<char>::init(&_M_buf); } -strstream::strstream(char* s, int n, ios_base::openmode mode) - : basic_ios<char>(), basic_iostream<char>(0), + strstream::strstream(char* s, int n, ios_base::openmode mode) + : basic_ios<char>(), basic_iostream<char>(0), _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s) -{ - basic_ios<char>::init(&_M_buf); -} - -strstream::~strstream() {} + { basic_ios<char>::init(&_M_buf); } -strstreambuf* strstream::rdbuf() const -{ - return const_cast<strstreambuf*>(&_M_buf); -} + strstream::~strstream() { } -void strstream::freeze(bool freezeflag) -{ - _M_buf.freeze(freezeflag); -} + strstreambuf* + strstream::rdbuf() const + { return const_cast<strstreambuf*>(&_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: diff --git a/libstdc++-v3/src/vterminate.cc b/libstdc++-v3/src/vterminate.cc index 942d6b55eab..a3543c903c6 100644 --- a/libstdc++-v3/src/vterminate.cc +++ b/libstdc++-v3/src/vterminate.cc @@ -1,6 +1,6 @@ // Verbose terminate_handler -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation +// Copyright (C) 2001, 2002 Free Software Foundation // // This file is part of GNU CC. // @@ -28,9 +28,10 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <exception> #include <cstdlib> #include <cstdio> +#include <exception> +#include <exception_defines.h> #include <cxxabi.h> using namespace std; @@ -38,46 +39,45 @@ using namespace abi; namespace __gnu_cxx { - -/* A replacement for the standard terminate_handler which prints - more information about the terminating exception (if any) on stderr. */ -void __verbose_terminate_handler () -{ - // Make sure there was an exception; terminate is also called for an - // attempt to rethrow when there is no suitable exception. - type_info *t = __cxa_current_exception_type (); - if (t) - { - char const *name = t->name (); - // Note that "name" is the mangled name. - + /* A replacement for the standard terminate_handler which prints + more information about the terminating exception (if any) on + stderr. */ + void __verbose_terminate_handler() + { + // Make sure there was an exception; terminate is also called for an + // attempt to rethrow when there is no suitable exception. + type_info *t = __cxa_current_exception_type(); + if (t) { - int status = -1; - char *dem = 0; + char const *name = t->name(); + // Note that "name" is the mangled name. + + { + int status = -1; + char *dem = 0; + + // Disabled until __cxa_demangle gets the runtime GPL exception. + dem = __cxa_demangle(name, 0, 0, &status); -#if 0 - // Disabled until __cxa_demangle gets the runtime GPL exception. - dem = __cxa_demangle (name, 0, 0, &status); -#endif + printf("terminate called after throwing a `%s'\n", + status == 0 ? dem : name); - printf ("terminate called after throwing a `%s'\n", - status == 0 ? dem : name); + if (status == 0) + free(dem); + } - if (status == 0) - free (dem); + // If the exception is derived from std::exception, we can give more + // information. + try { __throw_exception_again; } +#ifdef __EXCEPTIONS + catch (exception &exc) + { fprintf(stderr, " what(): %s\n", exc.what()); } +#endif + catch (...) { } } - - // If the exception is derived from std::exception, we can give more - // information. - try { throw; } - catch (exception &exc) - { fprintf (stderr, " what(): %s\n", exc.what()); } - catch (...) { } - } - else - fprintf (stderr, "terminate called without an active exception\n"); - - abort (); -} - + else + fprintf(stderr, "terminate called without an active exception\n"); + + abort(); + } } // namespace __gnu_cxx |