aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorno-author <no-author@gcc.gnu.org>2003-10-16 19:45:43 +0000
committerno-author <no-author@gcc.gnu.org>2003-10-16 19:45:43 +0000
commit62e7d315d715d19b921dbc592ae96b78d28c8836 (patch)
treee9ef225b6387d8920aa47c7c13760574b97f2a08 /libstdc++-v3/include
parent5cfd4c5b1b941f7fb3d7ee9cd0f2921efd2eedd6 (diff)
This commit was manufactured by cvs2svn to create taggcc_3_3_2_release
'gcc_3_3_2_release'. git-svn-id: https://gcc.gnu.org/svn/gcc/tags/gcc_3_3_2_release@72569 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/Makefile.am200
-rw-r--r--libstdc++-v3/include/Makefile.in222
-rw-r--r--libstdc++-v3/include/bits/basic_ios.h22
-rw-r--r--libstdc++-v3/include/bits/basic_ios.tcc43
-rw-r--r--libstdc++-v3/include/bits/basic_string.h96
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc130
-rw-r--r--libstdc++-v3/include/bits/c++config25
-rw-r--r--libstdc++-v3/include/bits/codecvt.h29
-rw-r--r--libstdc++-v3/include/bits/concept_check.h3
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc211
-rw-r--r--libstdc++-v3/include/bits/ios_base.h25
-rw-r--r--libstdc++-v3/include/bits/istream.tcc148
-rw-r--r--libstdc++-v3/include/bits/locale_classes.h404
-rw-r--r--libstdc++-v3/include/bits/locale_facets.h321
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc955
-rw-r--r--libstdc++-v3/include/bits/localefwd.h330
-rw-r--r--libstdc++-v3/include/bits/ostream.tcc98
-rw-r--r--libstdc++-v3/include/bits/stl_algo.h6
-rw-r--r--libstdc++-v3/include/bits/stl_alloc.h40
-rw-r--r--libstdc++-v3/include/bits/stl_iterator.h7
-rw-r--r--libstdc++-v3/include/bits/streambuf.tcc86
-rw-r--r--libstdc++-v3/include/bits/streambuf_iterator.h36
-rw-r--r--libstdc++-v3/include/bits/valarray_meta.h4
-rw-r--r--libstdc++-v3/include/c_std/std_cmath.h127
-rw-r--r--libstdc++-v3/include/c_std/std_cstdio.h15
-rw-r--r--libstdc++-v3/include/c_std/std_cstdlib.h26
-rw-r--r--libstdc++-v3/include/c_std/std_cwchar.h16
-rw-r--r--libstdc++-v3/include/ext/stdio_filebuf.h13
-rw-r--r--libstdc++-v3/include/std/std_bitset.h51
-rw-r--r--libstdc++-v3/include/std/std_complex.h16
-rw-r--r--libstdc++-v3/include/std/std_fstream.h39
-rw-r--r--libstdc++-v3/include/std/std_iomanip.h5
-rw-r--r--libstdc++-v3/include/std/std_iosfwd.h7
-rw-r--r--libstdc++-v3/include/std/std_istream.h21
-rw-r--r--libstdc++-v3/include/std/std_limits.h16
-rw-r--r--libstdc++-v3/include/std/std_locale.h7
-rw-r--r--libstdc++-v3/include/std/std_ostream.h20
-rw-r--r--libstdc++-v3/include/std/std_sstream.h4
-rw-r--r--libstdc++-v3/include/std/std_streambuf.h15
39 files changed, 2446 insertions, 1393 deletions
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index da7646aed05..cf1510200ab 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1,6 +1,6 @@
## Makefile for the include subdirectory of the GNU C++ Standard library.
##
-## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
## Process this file with automake to produce Makefile.in.
@@ -31,6 +31,75 @@ CXX = @glibcpp_CXX@
glibcpp_srcdir=@glibcpp_srcdir@
glibcpp_builddir=@glibcpp_builddir@
+GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
+LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
+INCLUDES = -nostdinc++ $(GLIBCPP_INCLUDES) $(LIBSUPCXX_INCLUDES)
+
+# Standard C++ includes.
+std_srcdir = ${glibcpp_srcdir}/include/std
+std_builddir = .
+std_headers = \
+ ${std_srcdir}/std_algorithm.h \
+ ${std_srcdir}/std_bitset.h \
+ ${std_srcdir}/std_complex.h \
+ ${std_srcdir}/std_deque.h \
+ ${std_srcdir}/std_fstream.h \
+ ${std_srcdir}/std_functional.h \
+ ${std_srcdir}/std_iomanip.h \
+ ${std_srcdir}/std_ios.h \
+ ${std_srcdir}/std_iosfwd.h \
+ ${std_srcdir}/std_iostream.h \
+ ${std_srcdir}/std_istream.h \
+ ${std_srcdir}/std_iterator.h \
+ ${std_srcdir}/std_limits.h \
+ ${std_srcdir}/std_list.h \
+ ${std_srcdir}/std_locale.h \
+ ${std_srcdir}/std_map.h \
+ ${std_srcdir}/std_memory.h \
+ ${std_srcdir}/std_numeric.h \
+ ${std_srcdir}/std_ostream.h \
+ ${std_srcdir}/std_queue.h \
+ ${std_srcdir}/std_set.h \
+ ${std_srcdir}/std_sstream.h \
+ ${std_srcdir}/std_stack.h \
+ ${std_srcdir}/std_stdexcept.h \
+ ${std_srcdir}/std_streambuf.h \
+ ${std_srcdir}/std_string.h \
+ ${std_srcdir}/std_utility.h \
+ ${std_srcdir}/std_valarray.h \
+ ${std_srcdir}/std_vector.h
+# Renamed at build time.
+std_headers_rename = \
+ algorithm \
+ bitset \
+ complex \
+ deque \
+ fstream \
+ functional \
+ iomanip \
+ ios \
+ iosfwd \
+ iostream \
+ istream \
+ iterator \
+ limits \
+ list \
+ locale \
+ map \
+ memory \
+ numeric \
+ ostream \
+ queue \
+ set \
+ sstream \
+ stack \
+ stdexcept \
+ streambuf \
+ string \
+ utility \
+ valarray \
+ vector
+
bits_srcdir = ${glibcpp_srcdir}/include/bits
bits_builddir = ./bits
bits_headers = \
@@ -53,6 +122,7 @@ bits_headers = \
${bits_srcdir}/ios_base.h \
${bits_srcdir}/istream.tcc \
${bits_srcdir}/list.tcc \
+ ${bits_srcdir}/locale_classes.h \
${bits_srcdir}/locale_facets.h \
${bits_srcdir}/locale_facets.tcc \
${bits_srcdir}/localefwd.h \
@@ -239,71 +309,6 @@ else
c_compatibility_headers_extra =
endif
-
-std_srcdir = ${glibcpp_srcdir}/include/std
-std_builddir = .
-std_headers = \
- ${std_srcdir}/std_algorithm.h \
- ${std_srcdir}/std_bitset.h \
- ${std_srcdir}/std_complex.h \
- ${std_srcdir}/std_deque.h \
- ${std_srcdir}/std_fstream.h \
- ${std_srcdir}/std_functional.h \
- ${std_srcdir}/std_iomanip.h \
- ${std_srcdir}/std_ios.h \
- ${std_srcdir}/std_iosfwd.h \
- ${std_srcdir}/std_iostream.h \
- ${std_srcdir}/std_istream.h \
- ${std_srcdir}/std_iterator.h \
- ${std_srcdir}/std_limits.h \
- ${std_srcdir}/std_list.h \
- ${std_srcdir}/std_locale.h \
- ${std_srcdir}/std_map.h \
- ${std_srcdir}/std_memory.h \
- ${std_srcdir}/std_numeric.h \
- ${std_srcdir}/std_ostream.h \
- ${std_srcdir}/std_queue.h \
- ${std_srcdir}/std_set.h \
- ${std_srcdir}/std_sstream.h \
- ${std_srcdir}/std_stack.h \
- ${std_srcdir}/std_stdexcept.h \
- ${std_srcdir}/std_streambuf.h \
- ${std_srcdir}/std_string.h \
- ${std_srcdir}/std_utility.h \
- ${std_srcdir}/std_valarray.h \
- ${std_srcdir}/std_vector.h
-# Renamed at build time.
-std_headers_rename = \
- algorithm \
- bitset \
- complex \
- deque \
- fstream \
- functional \
- iomanip \
- ios \
- iosfwd \
- iostream \
- istream \
- iterator \
- limits \
- list \
- locale \
- map \
- memory \
- numeric \
- ostream \
- queue \
- set \
- sstream \
- stack \
- stdexcept \
- streambuf \
- string \
- utility \
- valarray \
- vector
-
target_srcdir = ${glibcpp_srcdir}/@OS_INC_SRCDIR@
target_builddir = ./${target_alias}/bits
target_headers = \
@@ -312,6 +317,11 @@ target_headers = \
${target_srcdir}/ctype_noninline.h \
${target_srcdir}/os_defines.h \
${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h
+
+# Non-installed target_header files.
+target_headers_noinst = \
+ ${glibcpp_srcdir}/@CLOCALE_INTERNAL_H@
+
# These target_headers_extra files are all built with ad hoc naming rules.
target_headers_extra = \
${target_builddir}/basic_file.h \
@@ -319,6 +329,7 @@ target_headers_extra = \
${target_builddir}/c++io.h \
${target_builddir}/c++locale.h \
${target_builddir}/messages_members.h \
+ ${target_builddir}/time_members.h \
${target_builddir}/codecvt_specializations.h
thread_target_headers = \
@@ -331,9 +342,7 @@ thread_target_headers = \
# CLEANFILES and all-local are kept up-to-date.
allstamps = \
stamp-std stamp-bits stamp-c_base stamp-c_compatibility \
- stamp-backward stamp-ext \
- ${target_builddir}/stamp-target
-
+ stamp-backward stamp-ext stamp-target
# Here are the rules for building the headers
all-local: ${target_builddir}/c++config.h ${thread_target_headers} ${allstamps}
@@ -350,6 +359,12 @@ stamp-std: ${std_headers}
done) ;\
echo `date` > stamp-std
+stamp-std-precompile: stamp-std
+ for h in ${std_headers_rename}; do \
+ $(CXX) -Winvalid-pch -x c++-header $(INCLUDES) $${h}; \
+ done; \
+ echo `date` > stamp-std-precompile
+
stamp-bits: ${bits_headers}
@if [ ! -d "${bits_builddir}" ]; then \
mkdir -p ${bits_builddir} ;\
@@ -357,7 +372,7 @@ stamp-bits: ${bits_headers}
(cd ${bits_builddir} && @LN_S@ $? . || true) ;\
echo `date` > stamp-bits
-stamp-c_base: ${c_base_headers} ${c_base_headers_extra}
+stamp-c_base: stamp-bits ${c_base_headers} ${c_base_headers_extra}
@if [ ! -d "${c_base_builddir}" ]; then \
mkdir -p ${c_base_builddir} ;\
fi ;\
@@ -400,16 +415,19 @@ stamp-${target_alias}:
fi
# Target includes static.
-${target_builddir}/stamp-target: ${target_headers} stamp-${target_alias}
- @cd ${target_builddir} ;\
- if [ ! -f stamp-target ]; then \
+# XXX Missing dependency info for {target_headers_extra}
+stamp-target: ${target_headers} ${target_headers_noinst} stamp-${target_alias}
+ @if [ ! -f stamp-target ]; then \
+ (cd ${target_builddir} ;\
@LN_S@ ${target_headers} . || true ;\
@LN_S@ ${glibcpp_srcdir}/@BASIC_FILE_H@ basic_file.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CSTDIO_H@ c++io.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CLOCALE_H@ c++locale.h || true ;\
+ @LN_S@ ${glibcpp_srcdir}/@CLOCALE_INTERNAL_H@ . || true ;\
@LN_S@ ${glibcpp_srcdir}/@CMESSAGES_H@ messages_members.h || true ;\
- @LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true ;\
- echo `date` > stamp-target; \
+ @LN_S@ ${glibcpp_srcdir}/@CTIME_H@ time_members.h || true ;\
+ @LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true);\
+ echo `date` > stamp-target ; \
fi
# Target includes dynamic.
@@ -464,35 +482,35 @@ ${target_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcpp_thread_h} \
# the rest are taken from the original source tree.
gxx_include_dir = @gxx_include_dir@
install-data-local:
- $(mkinstalldirs) ${gxx_include_dir}
- $(mkinstalldirs) ${gxx_include_dir}/${bits_builddir}
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${bits_builddir}
for file in ${bits_headers}; do \
- $(INSTALL_DATA) $${file} ${gxx_include_dir}/${bits_builddir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${backward_builddir}
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${bits_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${backward_builddir}
for file in ${backward_headers}; do \
- $(INSTALL_DATA) $${file} ${gxx_include_dir}/${backward_builddir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${ext_builddir}
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${backward_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${ext_builddir}
for file in ${ext_headers}; do \
- $(INSTALL_DATA) $${file} ${gxx_include_dir}/${ext_builddir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${c_base_builddir}
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${ext_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir}
for file in ${c_base_headers_rename}; do \
- $(INSTALL_DATA) ${c_base_builddir}/$${file} ${gxx_include_dir}; done
+ $(INSTALL_DATA) ${c_base_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done
c_base_headers_extra_install='$(c_base_headers_extra)';\
for file in $$c_base_headers_extra_install; do \
- $(INSTALL_DATA) $$file ${gxx_include_dir}/${bits_builddir}; done
+ $(INSTALL_DATA) $$file $(DESTDIR)${gxx_include_dir}/${bits_builddir}; done
c_compatibility_headers_install='$(c_compatibility_headers_extra)';\
for file in $$c_compatibility_headers_install; do \
- $(INSTALL_DATA) $$file ${gxx_include_dir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${std_builddir}
+ $(INSTALL_DATA) $$file $(DESTDIR)${gxx_include_dir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir}
for file in ${std_headers_rename}; do \
- $(INSTALL_DATA) ${std_builddir}/$${file} ${gxx_include_dir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${target_builddir}
+ $(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${target_builddir}
for file in ${target_headers} ${target_headers_extra} \
${thread_target_headers}; do \
- $(INSTALL_DATA) $${file} ${gxx_include_dir}/${target_builddir}; done
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${target_builddir}; done
# By adding these files here, automake will remove them for 'make clean'
-#CLEANFILES = ${allstamps}
+CLEANFILES = *.pch stamp-std-precompile
# Stop implicit '.o' make rules from ever stomping on extensionless
# headers, in the improbable case where some foolish, crack-addled
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 5441e974d4f..b6cc4515109 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
@@ -67,14 +67,25 @@ AR = @AR@
AS = @AS@
ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@
AWK = @AWK@
+BASIC_FILE_CC = @BASIC_FILE_CC@
BASIC_FILE_H = @BASIC_FILE_H@
CC = @CC@
CCODECVT_C = @CCODECVT_C@
+CCODECVT_CC = @CCODECVT_CC@
CCODECVT_H = @CCODECVT_H@
+CCOLLATE_CC = @CCOLLATE_CC@
+CCTYPE_CC = @CCTYPE_CC@
+CLOCALE_CC = @CLOCALE_CC@
CLOCALE_H = @CLOCALE_H@
+CLOCALE_INTERNAL_H = @CLOCALE_INTERNAL_H@
+CMESSAGES_CC = @CMESSAGES_CC@
CMESSAGES_H = @CMESSAGES_H@
+CMONEY_CC = @CMONEY_CC@
+CNUMERIC_CC = @CNUMERIC_CC@
CPP = @CPP@
CSTDIO_H = @CSTDIO_H@
+CTIME_CC = @CTIME_CC@
+CTIME_H = @CTIME_H@
CXXCPP = @CXXCPP@
C_INCLUDE_DIR = @C_INCLUDE_DIR@
DEBUG_FLAGS = @DEBUG_FLAGS@
@@ -83,12 +94,10 @@ EXEEXT = @EXEEXT@
EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
-GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
GLIBCPP_IS_CROSS_COMPILING = @GLIBCPP_IS_CROSS_COMPILING@
LIBIO_INCLUDES = @LIBIO_INCLUDES@
LIBMATHOBJS = @LIBMATHOBJS@
LIBMATH_INCLUDES = @LIBMATH_INCLUDES@
-LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
LIBSUPCXX_PICFLAGS = @LIBSUPCXX_PICFLAGS@
LIBTOOL = @LIBTOOL@
LIBUNWIND_FLAG = @LIBUNWIND_FLAG@
@@ -105,6 +114,7 @@ RANLIB = @RANLIB@
SECTION_FLAGS = @SECTION_FLAGS@
SECTION_LDFLAGS = @SECTION_LDFLAGS@
STRIP = @STRIP@
+SYMVER_MAP = @SYMVER_MAP@
TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
@@ -137,6 +147,77 @@ CXX = @glibcpp_CXX@
glibcpp_srcdir = @glibcpp_srcdir@
glibcpp_builddir = @glibcpp_builddir@
+GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@
+LIBSUPCXX_INCLUDES = @LIBSUPCXX_INCLUDES@
+INCLUDES = -nostdinc++ $(GLIBCPP_INCLUDES) $(LIBSUPCXX_INCLUDES)
+
+# Standard C++ includes.
+std_srcdir = ${glibcpp_srcdir}/include/std
+std_builddir = .
+std_headers = \
+ ${std_srcdir}/std_algorithm.h \
+ ${std_srcdir}/std_bitset.h \
+ ${std_srcdir}/std_complex.h \
+ ${std_srcdir}/std_deque.h \
+ ${std_srcdir}/std_fstream.h \
+ ${std_srcdir}/std_functional.h \
+ ${std_srcdir}/std_iomanip.h \
+ ${std_srcdir}/std_ios.h \
+ ${std_srcdir}/std_iosfwd.h \
+ ${std_srcdir}/std_iostream.h \
+ ${std_srcdir}/std_istream.h \
+ ${std_srcdir}/std_iterator.h \
+ ${std_srcdir}/std_limits.h \
+ ${std_srcdir}/std_list.h \
+ ${std_srcdir}/std_locale.h \
+ ${std_srcdir}/std_map.h \
+ ${std_srcdir}/std_memory.h \
+ ${std_srcdir}/std_numeric.h \
+ ${std_srcdir}/std_ostream.h \
+ ${std_srcdir}/std_queue.h \
+ ${std_srcdir}/std_set.h \
+ ${std_srcdir}/std_sstream.h \
+ ${std_srcdir}/std_stack.h \
+ ${std_srcdir}/std_stdexcept.h \
+ ${std_srcdir}/std_streambuf.h \
+ ${std_srcdir}/std_string.h \
+ ${std_srcdir}/std_utility.h \
+ ${std_srcdir}/std_valarray.h \
+ ${std_srcdir}/std_vector.h
+
+# Renamed at build time.
+std_headers_rename = \
+ algorithm \
+ bitset \
+ complex \
+ deque \
+ fstream \
+ functional \
+ iomanip \
+ ios \
+ iosfwd \
+ iostream \
+ istream \
+ iterator \
+ limits \
+ list \
+ locale \
+ map \
+ memory \
+ numeric \
+ ostream \
+ queue \
+ set \
+ sstream \
+ stack \
+ stdexcept \
+ streambuf \
+ string \
+ utility \
+ valarray \
+ vector
+
+
bits_srcdir = ${glibcpp_srcdir}/include/bits
bits_builddir = ./bits
bits_headers = \
@@ -159,6 +240,7 @@ bits_headers = \
${bits_srcdir}/ios_base.h \
${bits_srcdir}/istream.tcc \
${bits_srcdir}/list.tcc \
+ ${bits_srcdir}/locale_classes.h \
${bits_srcdir}/locale_facets.h \
${bits_srcdir}/locale_facets.tcc \
${bits_srcdir}/localefwd.h \
@@ -340,72 +422,6 @@ c_compatibility_headers = \
@GLIBCPP_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = @GLIBCPP_C_HEADERS_COMPATIBILITY_TRUE@${c_compatibility_headers}
@GLIBCPP_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra =
-std_srcdir = ${glibcpp_srcdir}/include/std
-std_builddir = .
-std_headers = \
- ${std_srcdir}/std_algorithm.h \
- ${std_srcdir}/std_bitset.h \
- ${std_srcdir}/std_complex.h \
- ${std_srcdir}/std_deque.h \
- ${std_srcdir}/std_fstream.h \
- ${std_srcdir}/std_functional.h \
- ${std_srcdir}/std_iomanip.h \
- ${std_srcdir}/std_ios.h \
- ${std_srcdir}/std_iosfwd.h \
- ${std_srcdir}/std_iostream.h \
- ${std_srcdir}/std_istream.h \
- ${std_srcdir}/std_iterator.h \
- ${std_srcdir}/std_limits.h \
- ${std_srcdir}/std_list.h \
- ${std_srcdir}/std_locale.h \
- ${std_srcdir}/std_map.h \
- ${std_srcdir}/std_memory.h \
- ${std_srcdir}/std_numeric.h \
- ${std_srcdir}/std_ostream.h \
- ${std_srcdir}/std_queue.h \
- ${std_srcdir}/std_set.h \
- ${std_srcdir}/std_sstream.h \
- ${std_srcdir}/std_stack.h \
- ${std_srcdir}/std_stdexcept.h \
- ${std_srcdir}/std_streambuf.h \
- ${std_srcdir}/std_string.h \
- ${std_srcdir}/std_utility.h \
- ${std_srcdir}/std_valarray.h \
- ${std_srcdir}/std_vector.h
-
-# Renamed at build time.
-std_headers_rename = \
- algorithm \
- bitset \
- complex \
- deque \
- fstream \
- functional \
- iomanip \
- ios \
- iosfwd \
- iostream \
- istream \
- iterator \
- limits \
- list \
- locale \
- map \
- memory \
- numeric \
- ostream \
- queue \
- set \
- sstream \
- stack \
- stdexcept \
- streambuf \
- string \
- utility \
- valarray \
- vector
-
-
target_srcdir = ${glibcpp_srcdir}/@OS_INC_SRCDIR@
target_builddir = ./${target_alias}/bits
target_headers = \
@@ -415,6 +431,12 @@ target_headers = \
${target_srcdir}/os_defines.h \
${glibcpp_srcdir}/@ATOMICITY_INC_SRCDIR@/atomicity.h
+
+# Non-installed target_header files.
+target_headers_noinst = \
+ ${glibcpp_srcdir}/@CLOCALE_INTERNAL_H@
+
+
# These target_headers_extra files are all built with ad hoc naming rules.
target_headers_extra = \
${target_builddir}/basic_file.h \
@@ -422,6 +444,7 @@ target_headers_extra = \
${target_builddir}/c++io.h \
${target_builddir}/c++locale.h \
${target_builddir}/messages_members.h \
+ ${target_builddir}/time_members.h \
${target_builddir}/codecvt_specializations.h
@@ -436,8 +459,7 @@ thread_target_headers = \
# CLEANFILES and all-local are kept up-to-date.
allstamps = \
stamp-std stamp-bits stamp-c_base stamp-c_compatibility \
- stamp-backward stamp-ext \
- ${target_builddir}/stamp-target
+ stamp-backward stamp-ext stamp-target
# Target includes for threads
@@ -453,6 +475,9 @@ uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_]
# target_headers_extra are taken out of the build tree staging area;
# the rest are taken from the original source tree.
gxx_include_dir = @gxx_include_dir@
+
+# By adding these files here, automake will remove them for 'make clean'
+CLEANFILES = *.pch stamp-std-precompile
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = Makefile.am Makefile.in
@@ -521,6 +546,7 @@ installdirs:
mostlyclean-generic:
clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
@@ -570,6 +596,12 @@ stamp-std: ${std_headers}
done) ;\
echo `date` > stamp-std
+stamp-std-precompile: stamp-std
+ for h in ${std_headers_rename}; do \
+ $(CXX) -Winvalid-pch -x c++-header $(INCLUDES) $${h}; \
+ done; \
+ echo `date` > stamp-std-precompile
+
stamp-bits: ${bits_headers}
@if [ ! -d "${bits_builddir}" ]; then \
mkdir -p ${bits_builddir} ;\
@@ -577,7 +609,7 @@ stamp-bits: ${bits_headers}
(cd ${bits_builddir} && @LN_S@ $? . || true) ;\
echo `date` > stamp-bits
-stamp-c_base: ${c_base_headers} ${c_base_headers_extra}
+stamp-c_base: stamp-bits ${c_base_headers} ${c_base_headers_extra}
@if [ ! -d "${c_base_builddir}" ]; then \
mkdir -p ${c_base_builddir} ;\
fi ;\
@@ -620,16 +652,19 @@ stamp-${target_alias}:
fi
# Target includes static.
-${target_builddir}/stamp-target: ${target_headers} stamp-${target_alias}
- @cd ${target_builddir} ;\
- if [ ! -f stamp-target ]; then \
+# XXX Missing dependency info for {target_headers_extra}
+stamp-target: ${target_headers} ${target_headers_noinst} stamp-${target_alias}
+ @if [ ! -f stamp-target ]; then \
+ (cd ${target_builddir} ;\
@LN_S@ ${target_headers} . || true ;\
@LN_S@ ${glibcpp_srcdir}/@BASIC_FILE_H@ basic_file.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CSTDIO_H@ c++io.h || true ;\
@LN_S@ ${glibcpp_srcdir}/@CLOCALE_H@ c++locale.h || true ;\
+ @LN_S@ ${glibcpp_srcdir}/@CLOCALE_INTERNAL_H@ . || true ;\
@LN_S@ ${glibcpp_srcdir}/@CMESSAGES_H@ messages_members.h || true ;\
- @LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true ;\
- echo `date` > stamp-target; \
+ @LN_S@ ${glibcpp_srcdir}/@CTIME_H@ time_members.h || true ;\
+ @LN_S@ ${glibcpp_srcdir}/@CCODECVT_H@ codecvt_specializations.h || true);\
+ echo `date` > stamp-target ; \
fi
# Target includes dynamic.
@@ -670,35 +705,32 @@ ${target_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcpp_thread_h} \
-e 's,^#include "\(.*\)",#include <bits/\1>,g' \
< ${toplevel_srcdir}/gcc/${glibcpp_thread_h} > $@
install-data-local:
- $(mkinstalldirs) ${gxx_include_dir}
- $(mkinstalldirs) ${gxx_include_dir}/${bits_builddir}
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${bits_builddir}
for file in ${bits_headers}; do \
- $(INSTALL_DATA) $${file} ${gxx_include_dir}/${bits_builddir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${backward_builddir}
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${bits_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${backward_builddir}
for file in ${backward_headers}; do \
- $(INSTALL_DATA) $${file} ${gxx_include_dir}/${backward_builddir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${ext_builddir}
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${backward_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${ext_builddir}
for file in ${ext_headers}; do \
- $(INSTALL_DATA) $${file} ${gxx_include_dir}/${ext_builddir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${c_base_builddir}
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${ext_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir}
for file in ${c_base_headers_rename}; do \
- $(INSTALL_DATA) ${c_base_builddir}/$${file} ${gxx_include_dir}; done
+ $(INSTALL_DATA) ${c_base_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done
c_base_headers_extra_install='$(c_base_headers_extra)';\
for file in $$c_base_headers_extra_install; do \
- $(INSTALL_DATA) $$file ${gxx_include_dir}/${bits_builddir}; done
+ $(INSTALL_DATA) $$file $(DESTDIR)${gxx_include_dir}/${bits_builddir}; done
c_compatibility_headers_install='$(c_compatibility_headers_extra)';\
for file in $$c_compatibility_headers_install; do \
- $(INSTALL_DATA) $$file ${gxx_include_dir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${std_builddir}
+ $(INSTALL_DATA) $$file $(DESTDIR)${gxx_include_dir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir}
for file in ${std_headers_rename}; do \
- $(INSTALL_DATA) ${std_builddir}/$${file} ${gxx_include_dir}; done
- $(mkinstalldirs) ${gxx_include_dir}/${target_builddir}
+ $(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done
+ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${target_builddir}
for file in ${target_headers} ${target_headers_extra} \
${thread_target_headers}; do \
- $(INSTALL_DATA) $${file} ${gxx_include_dir}/${target_builddir}; done
-
-# By adding these files here, automake will remove them for 'make clean'
-#CLEANFILES = ${allstamps}
+ $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${target_builddir}; done
# Stop implicit '.o' make rules from ever stomping on extensionless
# headers, in the improbable case where some foolish, crack-addled
diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/include/bits/basic_ios.h
index b6ef89ba8b0..fe5e36a4fd7 100644
--- a/libstdc++-v3/include/bits/basic_ios.h
+++ b/libstdc++-v3/include/bits/basic_ios.h
@@ -1,6 +1,7 @@
// Iostreams base classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003
+// 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 +39,8 @@
#pragma GCC system_header
#include <bits/streambuf_iterator.h>
+#include <bits/localefwd.h>
+#include <bits/locale_classes.h>
#include <bits/locale_facets.h>
namespace std
@@ -78,6 +81,8 @@ namespace std
typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
typedef num_get<_CharT, __istreambuf_iter> __numget_type;
//@}
+
+ friend void ios_base::Init::_S_ios_create(bool);
// Data members:
protected:
@@ -415,7 +420,9 @@ namespace std
* @brief All setup is performed here.
*
* This is called from the public constructor. It is not virtual and
- * cannot be redefined.
+ * cannot be redefined. The second argument, __cache, is used
+ * to initialize the standard streams without allocating
+ * memory.
*/
void
init(basic_streambuf<_CharT, _Traits>* __sb);
@@ -429,7 +436,18 @@ namespace std
}
void
+ _M_cache_locale(const locale& __loc);
+
+#if 1
+ // XXX GLIBCXX_ABI Deprecated, compatibility only.
+ void
_M_cache_facets(const locale& __loc);
+#endif
+
+ // Internal state setter that won't throw, only set the state bits.
+ // Used to guarantee we don't throw when setting badbit.
+ void
+ _M_setstate(iostate __state) { _M_streambuf_state |= __state; }
};
} // namespace std
diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc
index 7ee8015e29f..1c9cd3b7256 100644
--- a/libstdc++-v3/include/bits/basic_ios.tcc
+++ b/libstdc++-v3/include/bits/basic_ios.tcc
@@ -1,6 +1,6 @@
// basic_ios locale and locale-related member functions -*- C++ -*-
-// Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2001, 2002, 2003 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
@@ -95,10 +95,17 @@ namespace std
this->precision(__rhs.precision());
this->tie(__rhs.tie());
this->fill(__rhs.fill());
+ _M_ios_locale = __rhs.getloc();
+
+ // This removes the link to __rhs locale cache
+ _M_call_callbacks(copyfmt_event);
+
+ _M_cache_locale(_M_ios_locale);
+
+
// The next is required to be the last assignment.
this->exceptions(__rhs.exceptions());
- _M_call_callbacks(copyfmt_event);
return *this;
}
@@ -129,7 +136,7 @@ namespace std
{
locale __old(this->getloc());
ios_base::imbue(__loc);
- _M_cache_facets(__loc);
+ _M_cache_locale(__loc);
if (this->rdbuf() != 0)
this->rdbuf()->pubimbue(__loc);
return __old;
@@ -141,7 +148,7 @@ namespace std
{
// NB: This may be called more than once on the same object.
ios_base::_M_init();
- _M_cache_facets(_M_ios_locale);
+ _M_cache_locale(_M_ios_locale);
_M_tie = 0;
// NB: The 27.4.4.1 Postconditions Table specifies requirements
@@ -166,31 +173,47 @@ namespace std
template<typename _CharT, typename _Traits>
void
- basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc)
+ basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc)
{
- if (has_facet<__ctype_type>(__loc))
+ if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
_M_fctype = &use_facet<__ctype_type>(__loc);
else
_M_fctype = 0;
- // Should be filled in by ostream and istream, respectively.
- if (has_facet<__numput_type>(__loc))
+ if (__builtin_expect(has_facet<__numput_type>(__loc), true))
_M_fnumput = &use_facet<__numput_type>(__loc);
else
_M_fnumput = 0;
- if (has_facet<__numget_type>(__loc))
- _M_fnumget = &use_facet<__numget_type>(__loc);
+ if (__builtin_expect(has_facet<__numget_type>(__loc), true))
+ _M_fnumget = &use_facet<__numget_type>(__loc);
else
_M_fnumget = 0;
}
+#if 1
+ // XXX GLIBCXX_ABI Deprecated, compatibility only.
+ template<typename _CharT, typename _Traits>
+ void
+ basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc)
+ {
+ if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
+ _M_fctype = &use_facet<__ctype_type>(__loc);
+ if (__builtin_expect(has_facet<__numput_type>(__loc), true))
+ _M_fnumput = &use_facet<__numput_type>(__loc);
+ if (__builtin_expect(has_facet<__numget_type>(__loc), true))
+ _M_fnumget = &use_facet<__numget_type>(__loc);
+ }
+#endif
+
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_ios<char>;
#ifdef _GLIBCPP_USE_WCHAR_T
extern template class basic_ios<wchar_t>;
#endif
+#endif
} // namespace std
#endif
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index fd56bb81ea0..e92009dc9d7 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -499,37 +499,10 @@ namespace std
assign(const basic_string& __str);
basic_string&
- assign(const basic_string& __str, size_type __pos, size_type __n)
- {
- const size_type __strsize = __str.size();
- if (__pos > __strsize)
- __throw_out_of_range("basic_string::assign");
- const bool __testn = __n < __strsize - __pos;
- const size_type __newsize = __testn ? __n : __strsize - __pos;
- return this->assign(__str._M_data() + __pos, __newsize);
- }
+ assign(const basic_string& __str, size_type __pos, size_type __n);
basic_string&
- assign(const _CharT* __s, size_type __n)
- {
- if (__n > this->max_size())
- __throw_length_error("basic_string::assign");
- if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
- || less<const _CharT*>()(_M_data() + this->size(), __s))
- return _M_replace_safe(_M_ibegin(), _M_iend(), __s, __s + __n);
- else
- {
- // Work in-place
- const size_type __pos = __s - _M_data();
- if (__pos >= __n)
- traits_type::copy(_M_data(), __s, __n);
- else if (__pos)
- traits_type::move(_M_data(), __s, __n);
- _M_rep()->_M_length = __n;
- _M_data()[__n] = _Rep::_S_terminal;
- return *this;
- }
- }
+ assign(const _CharT* __s, size_type __n);
basic_string&
assign(const _CharT* __s)
@@ -558,49 +531,10 @@ namespace std
basic_string&
insert(size_type __pos1, const basic_string& __str,
- size_type __pos2, size_type __n)
- {
- const size_type __strsize = __str.size();
- if (__pos2 > __strsize)
- __throw_out_of_range("basic_string::insert");
- const bool __testn = __n < __strsize - __pos2;
- const size_type __newsize = __testn ? __n : __strsize - __pos2;
- return this->insert(__pos1, __str._M_data() + __pos2, __newsize);
- }
+ size_type __pos2, size_type __n);
basic_string&
- insert(size_type __pos, const _CharT* __s, size_type __n)
- {
- const size_type __size = this->size();
- if (__pos > __size)
- __throw_out_of_range("basic_string::insert");
- if (__size > this->max_size() - __n)
- __throw_length_error("basic_string::insert");
- if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
- || less<const _CharT*>()(_M_data() + __size, __s))
- return _M_replace_safe(_M_ibegin() + __pos, _M_ibegin() + __pos,
- __s, __s + __n);
- else
- {
- // Work in-place. If _M_mutate reallocates the string, __s
- // does not point anymore to valid data, therefore we save its
- // offset, then we restore it.
- const size_type __off = __s - _M_data();
- _M_mutate(__pos, 0, __n);
- __s = _M_data() + __off;
- _CharT* __p = _M_data() + __pos;
- if (__s + __n <= __p)
- traits_type::copy(__p, __s, __n);
- else if (__s >= __p)
- traits_type::copy(__p, __s + __n, __n);
- else
- {
- traits_type::copy(__p, __s, __p - __s);
- traits_type::copy(__p + (__p - __s), __p + __n, __n - (__p - __s));
- }
- return *this;
- }
- }
+ insert(size_type __pos, const _CharT* __s, size_type __n);
basic_string&
insert(size_type __pos, const _CharT* __s)
@@ -657,25 +591,7 @@ namespace std
basic_string&
replace(size_type __pos, size_type __n1, const _CharT* __s,
- size_type __n2)
- {
- const size_type __size = this->size();
- if (__pos > __size)
- __throw_out_of_range("basic_string::replace");
- const bool __testn1 = __n1 < __size - __pos;
- const size_type __foldn1 = __testn1 ? __n1 : __size - __pos;
- if (__size - __foldn1 > this->max_size() - __n2)
- __throw_length_error("basic_string::replace");
- if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
- || less<const _CharT*>()(_M_data() + __size, __s))
- return _M_replace_safe(_M_ibegin() + __pos,
- _M_ibegin() + __pos + __foldn1, __s, __s + __n2);
- // Todo: optimized in-place replace.
- else return
- _M_replace(_M_ibegin() + __pos, _M_ibegin() + __pos + __foldn1,
- __s, __s + __n2,
- typename iterator_traits<const _CharT*>::iterator_category());
- }
+ size_type __n2);
basic_string&
replace(size_type __pos, size_type __n1, const _CharT* __s)
@@ -930,7 +846,7 @@ namespace std
compare(const _CharT* __s) const;
// _GLIBCPP_RESOLVE_LIB_DEFECTS
- // 5. String::compare specification questionable
+ // 5 String::compare specification questionable
int
compare(size_type __pos, size_type __n1, const _CharT* __s) const;
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index 70dd991ea3e..d3f1e8e3605 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -1,6 +1,6 @@
// Components for manipulating sequences of characters -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -254,6 +254,117 @@ namespace std
}
return *this;
}
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ assign(const basic_string& __str, size_type __pos, size_type __n)
+ {
+ const size_type __strsize = __str.size();
+ if (__pos > __strsize)
+ __throw_out_of_range("basic_string::assign");
+ const bool __testn = __n < __strsize - __pos;
+ const size_type __newsize = __testn ? __n : __strsize - __pos;
+ return this->assign(__str._M_data() + __pos, __newsize);
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ assign(const _CharT* __s, size_type __n)
+ {
+ if (__n > this->max_size())
+ __throw_length_error("basic_string::assign");
+ if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
+ || less<const _CharT*>()(_M_data() + this->size(), __s))
+ return _M_replace_safe(_M_ibegin(), _M_iend(), __s, __s + __n);
+ else
+ {
+ // Work in-place
+ const size_type __pos = __s - _M_data();
+ if (__pos >= __n)
+ traits_type::copy(_M_data(), __s, __n);
+ else if (__pos)
+ traits_type::move(_M_data(), __s, __n);
+ _M_rep()->_M_length = __n;
+ _M_data()[__n] = _Rep::_S_terminal; // grr.
+ return *this;
+ }
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ insert(size_type __pos1, const basic_string& __str,
+ size_type __pos2, size_type __n)
+ {
+ const size_type __strsize = __str.size();
+ if (__pos2 > __strsize)
+ __throw_out_of_range("basic_string::insert");
+ const bool __testn = __n < __strsize - __pos2;
+ const size_type __newsize = __testn ? __n : __strsize - __pos2;
+ return this->insert(__pos1, __str._M_data() + __pos2, __newsize);
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ insert(size_type __pos, const _CharT* __s, size_type __n)
+ {
+ const size_type __size = this->size();
+ if (__pos > __size)
+ __throw_out_of_range("basic_string::insert");
+ if (__size > this->max_size() - __n)
+ __throw_length_error("basic_string::insert");
+ if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
+ || less<const _CharT*>()(_M_data() + __size, __s))
+ return _M_replace_safe(_M_ibegin() + __pos, _M_ibegin() + __pos,
+ __s, __s + __n);
+ else
+ {
+ // Work in-place. If _M_mutate reallocates the string, __s
+ // does not point anymore to valid data, therefore we save its
+ // offset, then we restore it.
+ const size_type __off = __s - _M_data();
+ _M_mutate(__pos, 0, __n);
+ __s = _M_data() + __off;
+ _CharT* __p = _M_data() + __pos;
+ if (__s + __n <= __p)
+ traits_type::copy(__p, __s, __n);
+ else if (__s >= __p)
+ traits_type::copy(__p, __s + __n, __n);
+ else
+ {
+ traits_type::copy(__p, __s, __p - __s);
+ traits_type::copy(__p + (__p-__s), __p + __n, __n - (__p-__s));
+ }
+ return *this;
+ }
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ basic_string<_CharT, _Traits, _Alloc>&
+ basic_string<_CharT, _Traits, _Alloc>::
+ replace(size_type __pos, size_type __n1, const _CharT* __s,
+ size_type __n2)
+ {
+ const size_type __size = this->size();
+ if (__pos > __size)
+ __throw_out_of_range("basic_string::replace");
+ const bool __testn1 = __n1 < __size - __pos;
+ const size_type __foldn1 = __testn1 ? __n1 : __size - __pos;
+ if (__size - __foldn1 > this->max_size() - __n2)
+ __throw_length_error("basic_string::replace");
+ if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
+ || less<const _CharT*>()(_M_data() + __size, __s))
+ return _M_replace_safe(_M_ibegin() + __pos,
+ _M_ibegin() + __pos + __foldn1, __s, __s + __n2);
+ // Todo: optimized in-place replace.
+ else
+ return _M_replace(_M_ibegin() + __pos, _M_ibegin() + __pos + __foldn1,
+ __s, __s + __n2,
+ typename iterator_traits<const _CharT*>::iterator_category());
+ }
template<typename _CharT, typename _Traits, typename _Alloc>
void
@@ -578,7 +689,8 @@ namespace std
// Iff appending itself, string needs to pre-reserve the
// correct size so that _M_mutate does not clobber the
// iterators formed here.
- size_type __len = std::min(__str.size() - __pos, __n) + this->size();
+ size_type __len = std::min(size_type(__str.size() - __pos),
+ __n) + this->size();
if (__len > this->capacity())
this->reserve(__len);
return _M_replace_safe(_M_iend(), _M_iend(), __str._M_check(__pos),
@@ -709,7 +821,7 @@ namespace std
size_type __size = this->size();
if (__n <= __size)
{
- __pos = std::min(__size - __n, __pos);
+ __pos = std::min(size_type(__size - __n), __pos);
const _CharT* __data = _M_data();
do
{
@@ -848,7 +960,7 @@ namespace std
if (__pos > __size)
__throw_out_of_range("basic_string::compare");
- size_type __rsize= std::min(__size - __pos, __n);
+ size_type __rsize= std::min(size_type(__size - __pos), __n);
size_type __len = std::min(__rsize, __osize);
int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
if (!__r)
@@ -867,8 +979,8 @@ namespace std
if (__pos1 > __size || __pos2 > __osize)
__throw_out_of_range("basic_string::compare");
- size_type __rsize = std::min(__size - __pos1, __n1);
- size_type __rosize = std::min(__osize - __pos2, __n2);
+ size_type __rsize = std::min(size_type(__size - __pos1), __n1);
+ size_type __rosize = std::min(size_type(__osize - __pos2), __n2);
size_type __len = std::min(__rsize, __rosize);
int __r = traits_type::compare(_M_data() + __pos1,
__str.data() + __pos2, __len);
@@ -903,7 +1015,7 @@ namespace std
__throw_out_of_range("basic_string::compare");
size_type __osize = traits_type::length(__s);
- size_type __rsize = std::min(__size - __pos, __n1);
+ size_type __rsize = std::min(size_type(__size - __pos), __n1);
size_type __len = std::min(__rsize, __osize);
int __r = traits_type::compare(_M_data() + __pos, __s, __len);
if (!__r)
@@ -922,7 +1034,7 @@ namespace std
__throw_out_of_range("basic_string::compare");
size_type __osize = std::min(traits_type::length(__s), __n2);
- size_type __rsize = std::min(__size - __pos, __n1);
+ size_type __rsize = std::min(size_type(__size - __pos), __n1);
size_type __len = std::min(__rsize, __osize);
int __r = traits_type::compare(_M_data() + __pos, __s, __len);
if (!__r)
@@ -945,6 +1057,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_string<char>;
extern template
basic_istream<char>&
@@ -974,6 +1087,7 @@ namespace std
basic_istream<wchar_t>&
getline(basic_istream<wchar_t>&, wstring&);
#endif
+#endif
} // namespace std
#endif
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 8dbbd9fb823..2d81793aa90 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -1,6 +1,7 @@
// Predefined symbols and macros -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// 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
@@ -34,10 +35,9 @@
#include <bits/os_defines.h>
// The current version of the C++ library in compressed ISO date format.
-#define __GLIBCPP__ 20021213
+#define __GLIBCPP__ 20031016
-// This is necessary until GCC supports separate template
-// compilation.
+// This is necessary until GCC supports separate template compilation.
#define _GLIBCPP_NO_TEMPLATE_EXPORT 1
// This is a hack around not having either pre-compiled headers or
@@ -49,6 +49,16 @@
// by the compiler, but instead instantiated into the library binary.
#define _GLIBCPP_FULLY_COMPLIANT_HEADERS 1
+// Allow use of the GNU syntax extension, "extern template." This
+// extension is fully documented in the g++ manual, but in a nutshell,
+// it inhibits all implicit instantiations and is used throughout the
+// library to avoid multiple weak definitions for required types that
+// are already explicitly instantiated in the library binary. This
+// substantially reduces the binary size of resulting executables.
+#ifndef _GLIBCPP_EXTERN_TEMPLATE
+#define _GLIBCPP_EXTERN_TEMPLATE 1
+#endif
+
// To enable older, ARM-style iostreams and other anachronisms use this.
//#define _GLIBCPP_DEPRECATED 1
@@ -77,6 +87,13 @@
#error __USE_MALLOC should never be defined. Read the release notes.
#endif
+// Create a boolean flag to be used to determine if --fast-math is set.
+#ifdef __FAST_MATH__
+#define _GLIBCPP_FAST_MATH 1
+#else
+#define _GLIBCPP_FAST_MATH 0
+#endif
+
// The remainder of the prewritten config is mostly automatic; all the
// user hooks are listed above.
diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h
index 92b0f0e8a7d..9ab9f94e71d 100644
--- a/libstdc++-v3/include/bits/codecvt.h
+++ b/libstdc++-v3/include/bits/codecvt.h
@@ -1,6 +1,6 @@
// Locale support (codecvt) -*- C++ -*-
-// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 2002, 2003 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
@@ -164,9 +164,6 @@
typedef _ExternT extern_type;
typedef _StateT state_type;
- protected:
- __c_locale _M_c_locale_codecvt;
-
public:
static locale::id id;
@@ -174,9 +171,6 @@
codecvt(size_t __refs = 0)
: __codecvt_abstract_base<_InternT, _ExternT, _StateT> (__refs) { }
- explicit
- codecvt(__c_locale __cloc, size_t __refs = 0);
-
protected:
virtual
~codecvt() { }
@@ -225,18 +219,12 @@
typedef char extern_type;
typedef mbstate_t state_type;
- protected:
- __c_locale _M_c_locale_codecvt;
-
public:
static locale::id id;
explicit
codecvt(size_t __refs = 0);
- explicit
- codecvt(__c_locale __cloc, size_t __refs = 0);
-
protected:
virtual
~codecvt();
@@ -283,18 +271,12 @@
typedef char extern_type;
typedef mbstate_t state_type;
- protected:
- __c_locale _M_c_locale_codecvt;
-
public:
static locale::id id;
explicit
codecvt(size_t __refs = 0);
- explicit
- codecvt(__c_locale __cloc, size_t __refs = 0);
-
protected:
virtual
~codecvt();
@@ -338,13 +320,8 @@
{
public:
explicit
- codecvt_byname(const char* __s, size_t __refs = 0)
- : codecvt<_InternT, _ExternT, _StateT>(__refs)
- {
- if (_M_c_locale_codecvt != _S_c_locale)
- _S_destroy_c_locale(_M_c_locale_codecvt);
- _S_create_c_locale(_M_c_locale_codecvt, __s);
- }
+ codecvt_byname(const char*, size_t __refs = 0)
+ : codecvt<_InternT, _ExternT, _StateT>(__refs) { }
protected:
virtual
diff --git a/libstdc++-v3/include/bits/concept_check.h b/libstdc++-v3/include/bits/concept_check.h
index 92ceefbd685..88877ebf57e 100644
--- a/libstdc++-v3/include/bits/concept_check.h
+++ b/libstdc++-v3/include/bits/concept_check.h
@@ -61,8 +61,7 @@
// Note that the obvious and elegant approach of
//
-//#define glibcpp_function_requires(C) \
-// boost::function_requires< boost::C >()
+//#define glibcpp_function_requires(C) boost::function_requires< boost::C >()
//
// won't work due to concept templates with more than one parameter, e.g.,
// BinaryPredicateConcept. The preprocessor tries to split things up on
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 387f099ae98..c69ac9c7226 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -1,6 +1,6 @@
// File based streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -58,7 +58,7 @@ namespace std
template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
- _M_destroy_internal_buffer()
+ _M_destroy_internal_buffer() throw()
{
if (_M_buf_allocated)
{
@@ -94,16 +94,13 @@ namespace std
// Setup initial position of buffer.
_M_set_indeterminate();
- // Set input buffer to something real.
- // NB: Must open in non-blocking way to do this, or must
- // set the initial position in a different manner than
- // using underflow.
- if (__mode & ios_base::in && _M_buf_allocated)
- this->underflow();
-
if ((__mode & ios_base::ate)
&& this->seekoff(0, ios_base::end, __mode) < 0)
- this->close();
+ {
+ // 27.8.1.3,4
+ this->close();
+ return __ret;
+ }
__ret = this;
}
@@ -114,35 +111,46 @@ namespace std
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
basic_filebuf<_CharT, _Traits>::
- close()
+ close() throw()
{
- __filebuf_type *__ret = NULL;
+ __filebuf_type* __ret = NULL;
if (this->is_open())
{
- const int_type __eof = traits_type::eof();
- bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
- if (__testput
- && traits_type::eq_int_type(_M_really_overflow(__eof), __eof))
- return __ret;
+ bool __testfail = false;
+ try
+ {
+ const int_type __eof = traits_type::eof();
+ bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
+ if (__testput
+ && traits_type::eq_int_type(_M_really_overflow(__eof),
+ __eof))
+ __testfail = true;
+
+#if 0
+ // XXX not done
+ if (_M_last_overflowed)
+ {
+ _M_output_unshift();
+ _M_really_overflow(__eof);
+ }
+#endif
+ }
+ catch(...)
+ {
+ __testfail = true;
+ }
// NB: Do this here so that re-opened filebufs will be cool...
- _M_mode = ios_base::openmode(0);
+ this->_M_mode = ios_base::openmode(0);
_M_destroy_internal_buffer();
_M_pback_destroy();
-
-#if 0
- // XXX not done
- if (_M_last_overflowed)
- {
- _M_output_unshift();
- _M_really_overflow(__eof);
- }
-#endif
- if (_M_file.close())
+ if (!_M_file.close())
+ __testfail = true;
+
+ if (!__testfail)
__ret = this;
}
-
_M_last_overflowed = false;
return __ret;
}
@@ -154,9 +162,16 @@ namespace std
{
streamsize __ret = -1;
bool __testin = _M_mode & ios_base::in;
+ const locale __loc = this->getloc();
+ const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc);
if (__testin && this->is_open())
- __ret = _M_in_end - _M_in_cur;
+ {
+ __ret = _M_in_end - _M_in_cur;
+ if (__cvt.always_noconv())
+ __ret += _M_file.showmanyc_helper();
+ }
+
_M_last_overflowed = false;
return __ret;
}
@@ -208,21 +223,26 @@ namespace std
}
else
{
- // At the beginning of the buffer, need to make a
- // putback position available.
- this->seekoff(-1, ios_base::cur);
- this->underflow();
- if (!__testeof)
+ // At the beginning of the buffer, need to make a
+ // putback position available.
+ // But the seek may fail (f.i., at the beginning of
+ // a file, see libstdc++/9439) and in that case
+ // we return traits_type::eof()
+ if (this->seekoff(-1, ios_base::cur) >= 0)
{
- if (!traits_type::eq(__c, *_M_in_cur))
- {
- _M_pback_create();
- *_M_in_cur = __c;
- }
- __ret = __i;
+ this->underflow();
+ if (!__testeof)
+ {
+ if (!traits_type::eq(__c, *_M_in_cur))
+ {
+ _M_pback_create();
+ *_M_in_cur = __c;
+ }
+ __ret = __i;
+ }
+ else
+ __ret = traits_type::not_eof(__i);
}
- else
- __ret = traits_type::not_eof(__i);
}
}
_M_last_overflowed = false;
@@ -240,7 +260,9 @@ namespace std
if (__testout)
{
- if (__testput)
+ if (traits_type::eq_int_type(__c, traits_type::eof()))
+ __ret = traits_type::not_eof(__c);
+ else if (__testput)
{
*_M_out_cur = traits_type::to_char_type(__c);
_M_out_cur_move(1);
@@ -278,14 +300,23 @@ namespace std
char* __buf = static_cast<char*>(__builtin_alloca(__blen));
char* __bend;
const char_type* __iend;
- __res_type __r = __cvt.out(_M_state_cur, __ibuf, __ibuf + __ilen,
- __iend, __buf, __buf + __blen, __bend);
- // Result == ok, partial, noconv
- if (__r != codecvt_base::error)
+ codecvt_base::result __r;
+ __r = __cvt.out(_M_state_cur, __ibuf, __ibuf + __ilen,
+ __iend, __buf, __buf + __blen, __bend);
+
+ if (__r == codecvt_base::ok || __r == codecvt_base::partial)
__blen = __bend - __buf;
- // Result == error
- else
- __blen = 0;
+ else if (__r == codecvt_base::noconv)
+ {
+ // Same as the always_noconv case above.
+ __buf = reinterpret_cast<char*>(__ibuf);
+ __blen = __ilen;
+ }
+ else
+ {
+ // Result == error
+ __blen = 0;
+ }
if (__blen)
{
@@ -301,11 +332,8 @@ namespace std
__r = __cvt.out(_M_state_cur, __iresume, __iresume + __rlen,
__iend, __buf, __buf + __blen, __bend);
if (__r != codecvt_base::error)
- __rlen = __bend - __buf;
- else
- __rlen = 0;
- if (__rlen)
{
+ __rlen = __bend - __buf;
__elen += _M_file.xsputn(__buf, __rlen);
__plen += __rlen;
}
@@ -320,7 +348,7 @@ namespace std
{
int_type __ret = traits_type::eof();
bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
- bool __testunbuffered = _M_file.is_open() && !_M_buf_size_opt;
+ bool __testunbuffered = _M_file.is_open() && !_M_buf_size;
if (__testput || __testunbuffered)
{
@@ -343,26 +371,32 @@ namespace std
_M_convert_to_external(_M_out_beg, _M_out_end - _M_out_beg,
__elen, __plen);
- // Convert pending sequence to external representation, output.
- // If eof, then just attempt sync.
- if (!traits_type::eq_int_type(__c, traits_type::eof()))
- {
- char_type __pending = traits_type::to_char_type(__c);
- _M_convert_to_external(&__pending, 1, __elen, __plen);
-
- // User code must flush when switching modes (thus don't sync).
- if (__elen == __plen)
+ // Checks for codecvt.out failures and _M_file.xsputn failures,
+ // respectively, inside _M_convert_to_external.
+ if (__testunbuffered || (__elen && __elen == __plen))
+ {
+ // Convert pending sequence to external representation, output.
+ // If eof, then just attempt sync.
+ if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
- _M_set_indeterminate();
- __ret = traits_type::not_eof(__c);
+ char_type __pending = traits_type::to_char_type(__c);
+ _M_convert_to_external(&__pending, 1, __elen, __plen);
+
+ // User code must flush when switching modes (thus
+ // don't sync).
+ if (__elen == __plen && __elen)
+ {
+ _M_set_indeterminate();
+ __ret = traits_type::not_eof(__c);
+ }
}
- }
- else if (!_M_file.sync())
- {
- _M_set_indeterminate();
- __ret = traits_type::not_eof(__c);
- }
- }
+ else if (!_M_file.sync())
+ {
+ _M_set_indeterminate();
+ __ret = traits_type::not_eof(__c);
+ }
+ }
+ }
_M_last_overflowed = true;
return __ret;
}
@@ -401,12 +435,13 @@ namespace std
bool __testin = (ios_base::in & _M_mode & __mode) != 0;
bool __testout = (ios_base::out & _M_mode & __mode) != 0;
- // Should probably do has_facet checks here.
- int __width = use_facet<__codecvt_type>(_M_buf_locale).encoding();
+ int __width = 0;
+ if (has_facet<__codecvt_type>(this->_M_buf_locale))
+ __width = use_facet<__codecvt_type>(this->_M_buf_locale).encoding();
if (__width < 0)
__width = 0;
- bool __testfail = __off != 0 && __width <= 0;
-
+
+ bool __testfail = __off != 0 && __width <= 0;
if (this->is_open() && !__testfail && (__testin || __testout))
{
// Ditch any pback buffers to avoid confusion.
@@ -430,7 +465,8 @@ namespace std
//in
else if (__testget && __way == ios_base::cur)
__computed_off += _M_in_cur - _M_filepos;
-
+
+ // Return pos_type(off_type(-1)) in case of failure.
__ret = _M_file.seekoff(__computed_off, __way, __mode);
_M_set_indeterminate();
}
@@ -438,8 +474,14 @@ namespace std
// state, ie _M_file._offset == -1
else
{
- __ret = _M_file.seekoff(__off, ios_base::cur, __mode);
- __ret += max(_M_out_cur, _M_in_cur) - _M_filepos;
+ pos_type __tmp =
+ _M_file.seekoff(__off, ios_base::cur, __mode);
+ if (__tmp >= 0)
+ {
+ // Seek successful.
+ __ret = __tmp;
+ __ret += max(_M_out_cur, _M_in_cur) - _M_filepos;
+ }
}
}
_M_last_overflowed = false;
@@ -471,10 +513,7 @@ namespace std
bool __testbeg = gptr() == eback() && pptr() == pbase();
if (__testbeg && _M_buf_locale != __loc)
- {
- _M_buf_locale = __loc;
- _M_buf_locale_init = true;
- }
+ _M_buf_locale = __loc;
// NB this may require the reconversion of previously
// converted chars. This in turn may cause the reconstruction
@@ -486,6 +525,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_filebuf<char>;
extern template class basic_ifstream<char>;
extern template class basic_ofstream<char>;
@@ -497,6 +537,7 @@ namespace std
extern template class basic_ofstream<wchar_t>;
extern template class basic_fstream<wchar_t>;
#endif
+#endif
} // namespace std
#endif
diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h
index 1f085d9e4e7..3437f847c4a 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -1,6 +1,6 @@
// Iostreams base classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -43,6 +43,8 @@
#pragma GCC system_header
#include <bits/atomicity.h>
+#include <bits/localefwd.h>
+#include <bits/locale_classes.h>
namespace std
{
@@ -414,6 +416,7 @@ namespace std
_Words _M_word_zero;
// Guaranteed storage.
+ // The first 5 iword and pword slots are reserved for internal use.
static const int _S_local_word_size = 8;
_Words _M_local_word[_S_local_word_size];
@@ -449,6 +452,12 @@ namespace std
static void
_S_ios_destroy();
+ // NB: Allows debugger applications use of the standard streams
+ // from operator new. _S_ios_base_init must be incremented in
+ // _S_ios_create _after_ initialization is completed.
+ static bool
+ _S_initialized() { return _S_ios_base_init; }
+
private:
static int _S_ios_base_init;
static bool _S_synced_with_stdio;
@@ -595,7 +604,7 @@ namespace std
/**
* @brief Locale access
- * @return The locale currently in effect.
+ * @return A copy of the current locale.
*
* If @c imbue(loc) has previously been called, then this function
* returns @c loc. Otherwise, it returns a copy of @c std::locale(),
@@ -604,6 +613,16 @@ namespace std
inline locale
getloc() const { return _M_ios_locale; }
+ /**
+ * @brief Locale access
+ * @return A reference to the current locale.
+ *
+ * Like getloc above, but returns a reference instead of
+ * generating a copy.
+ */
+ inline const locale&
+ _M_getloc() const { return _M_ios_locale; }
+
// [27.4.2.5] ios_base storage functions
/**
* @doctodo
@@ -638,7 +657,7 @@ namespace std
* Destroys local storage and
* [XXX does something with callbacks].
*/
- virtual ~ios_base();
+ ~ios_base();
protected:
ios_base();
diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc
index a6e49a923bd..ae0c5077e51 100644
--- a/libstdc++-v3/include/bits/istream.tcc
+++ b/libstdc++-v3/include/bits/istream.tcc
@@ -1,6 +1,6 @@
// istream classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -118,11 +118,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -155,11 +155,11 @@ namespace std
#endif
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -182,11 +182,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -219,11 +219,11 @@ namespace std
#endif
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -246,11 +246,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -273,11 +273,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -300,11 +300,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -328,11 +328,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -355,11 +355,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -383,11 +383,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -410,11 +410,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -437,11 +437,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -464,11 +464,11 @@ namespace std
_M_fnumget->get(*this, 0, *this, __err, __n);
this->setstate(__err);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -495,11 +495,11 @@ namespace std
if (!__sbout || !__xtrct)
this->setstate(ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -527,11 +527,11 @@ namespace std
else
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -561,11 +561,11 @@ namespace std
else
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -600,11 +600,11 @@ namespace std
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -643,11 +643,11 @@ namespace std
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -694,11 +694,11 @@ namespace std
this->setstate(ios_base::failbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -735,11 +735,11 @@ namespace std
if (traits_type::eq_int_type(__c, __eof))
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -757,13 +757,17 @@ namespace std
sentry __cerb(*this, true);
if (__cerb)
{
- try
- { __c = this->rdbuf()->sgetc(); }
- catch(exception& __fail)
+ try
+ {
+ __c = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__c, traits_type::eof()))
+ this->setstate(ios_base::eofbit);
+ }
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -786,11 +790,11 @@ namespace std
if (_M_gcount != __n)
this->setstate(ios_base::eofbit | ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -822,11 +826,11 @@ namespace std
else
this->setstate(ios_base::eofbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -841,6 +845,10 @@ namespace std
basic_istream<_CharT, _Traits>::
putback(char_type __c)
{
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+// 60. What is a formatted input function?
+ _M_gcount = 0;
+#endif
sentry __cerb(*this, true);
if (__cerb)
{
@@ -852,11 +860,11 @@ namespace std
|| traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -871,7 +879,10 @@ namespace std
basic_istream<_CharT, _Traits>::
unget(void)
{
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+// 60. What is a formatted input function?
_M_gcount = 0;
+#endif
sentry __cerb(*this, true);
if (__cerb)
{
@@ -883,11 +894,11 @@ namespace std
|| traits_type::eq_int_type(__sb->sungetc(), __eof))
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -902,8 +913,8 @@ namespace std
basic_istream<_CharT, _Traits>::
sync(void)
{
+ // DR60. Do not change _M_gcount.
int __ret = -1;
- _M_gcount = 0;
sentry __cerb(*this, true);
if (__cerb)
{
@@ -918,11 +929,11 @@ namespace std
__ret = 0;
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.3 paragraph 1
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -935,6 +946,7 @@ namespace std
basic_istream<_CharT, _Traits>::
tellg(void)
{
+ // DR60. Do not change _M_gcount.
pos_type __ret = pos_type(-1);
if (!this->fail())
__ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
@@ -947,7 +959,7 @@ namespace std
basic_istream<_CharT, _Traits>::
seekg(pos_type __pos)
{
- _M_gcount = 0;
+ // DR60. Do not change _M_gcount.
if (!this->fail())
{
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
@@ -967,7 +979,7 @@ namespace std
basic_istream<_CharT, _Traits>::
seekg(off_type __off, ios_base::seekdir __dir)
{
- _M_gcount = 0;
+ // DR60. Do not change _M_gcount.
if (!this->fail())
{
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
@@ -994,11 +1006,11 @@ namespace std
{
try
{ __in.get(__c); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __in.setstate(ios_base::badbit);
+ __in._M_setstate(ios_base::badbit);
if ((__in.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -1026,7 +1038,7 @@ namespace std
{
// Figure out how many characters to extract.
streamsize __num = __in.width();
- if (__num == 0)
+ if (__num <= 0)
__num = numeric_limits<streamsize>::max();
const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
@@ -1036,9 +1048,9 @@ namespace std
while (__extracted < __num - 1
&& !_Traits::eq_int_type(__c, __eof)
- && !__ctype.is(ctype_base::space, __c))
+ && !__ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
{
- *__s++ = __c;
+ *__s++ = _Traits::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
@@ -1051,11 +1063,11 @@ namespace std
#endif
__in.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __in.setstate(ios_base::badbit);
+ __in._M_setstate(ios_base::badbit);
if ((__in.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -1081,7 +1093,7 @@ namespace std
__int_type __c = __sb->sgetc();
while (!_Traits::eq_int_type(__c, __eof)
- && __ctype.is(ctype_base::space, __c))
+ && __ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
__c = __sb->snextc();
if (_Traits::eq_int_type(__c, __eof))
@@ -1119,7 +1131,7 @@ namespace std
while (__extracted < __n
&& !_Traits::eq_int_type(__c, __eof)
- && !__ctype.is(ctype_base::space, __c))
+ && !__ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
{
__str += _Traits::to_char_type(__c);
++__extracted;
@@ -1189,6 +1201,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_istream<char>;
extern template istream& ws(istream&);
extern template istream& operator>>(istream&, char&);
@@ -1204,4 +1217,5 @@ namespace std
extern template wistream& operator>>(wistream&, wchar_t&);
extern template wistream& operator>>(wistream&, wchar_t*);
#endif
+#endif
} // namespace std
diff --git a/libstdc++-v3/include/bits/locale_classes.h b/libstdc++-v3/include/bits/locale_classes.h
new file mode 100644
index 00000000000..ddd23fb9726
--- /dev/null
+++ b/libstdc++-v3/include/bits/locale_classes.h
@@ -0,0 +1,404 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// 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: 22.1 Locales
+//
+
+/** @file localefwd.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
+#ifndef _CPP_BITS_LOCALE_CLASSES_H
+#define _CPP_BITS_LOCALE_CLASSES_H 1
+
+#pragma GCC system_header
+
+#include <bits/localefwd.h>
+#include <cstring> // For strcmp.
+#include <string>
+#include <bits/atomicity.h>
+
+namespace std
+{
+ class __locale_cache_base;
+ template<typename _Facet> class __locale_cache;
+
+ // 22.1.1 Class locale
+ class locale
+ {
+ public:
+ // Types:
+ typedef unsigned int category;
+
+ // Forward decls and friends:
+ class facet;
+ class id;
+ class _Impl;
+
+ friend class facet;
+ friend class _Impl;
+
+ template<typename _Facet>
+ friend const _Facet&
+ use_facet(const locale&);
+
+ template<typename _Facet>
+ friend bool
+ has_facet(const locale&) throw();
+
+ template<typename _Facet>
+ friend const __locale_cache<_Facet>&
+ __use_cache(const locale&);
+
+ // Category values:
+ // NB: Order must match _S_facet_categories definition in locale.cc
+ static const category none = 0;
+ static const category ctype = 1L << 0;
+ static const category numeric = 1L << 1;
+ static const category collate = 1L << 2;
+ static const category time = 1L << 3;
+ static const category monetary = 1L << 4;
+ static const category messages = 1L << 5;
+ static const category all = (ctype | numeric | collate |
+ time | monetary | messages);
+
+ // Construct/copy/destroy:
+ locale() throw();
+
+ locale(const locale& __other) throw();
+
+ explicit
+ locale(const char* __s);
+
+ locale(const locale& __base, const char* __s, category __cat);
+
+ locale(const locale& __base, const locale& __add, category __cat);
+
+ template<typename _Facet>
+ locale(const locale& __other, _Facet* __f);
+
+ ~locale() throw();
+
+ const locale&
+ operator=(const locale& __other) throw();
+
+ template<typename _Facet>
+ locale
+ combine(const locale& __other) const;
+
+ // Locale operations:
+ string
+ name() const;
+
+ bool
+ operator==(const locale& __other) const throw ();
+
+ inline bool
+ operator!=(const locale& __other) const throw ()
+ { return !(this->operator==(__other)); }
+
+ template<typename _Char, typename _Traits, typename _Alloc>
+ bool
+ operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
+ const basic_string<_Char, _Traits, _Alloc>& __s2) const;
+
+ // Global locale objects:
+ static locale
+ global(const locale&);
+
+ static const locale&
+ classic();
+
+ private:
+ // The (shared) implementation
+ _Impl* _M_impl;
+
+ // The "C" reference locale
+ static _Impl* _S_classic;
+
+ // Current global locale
+ static _Impl* _S_global;
+
+ // Number of standard categories. For C++, these categories are
+ // collate, ctype, monetary, numeric, time, and messages. These
+ // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
+ // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
+ // 1003.1-2001) specifies LC_MESSAGES.
+ static const size_t _S_categories_size = 6;
+
+ // In addition to the standard categories, the underlying
+ // operating system is allowed to define extra LC_*
+ // macros. For GNU systems, the following are also valid:
+ // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
+ // and LC_IDENTIFICATION.
+ static const size_t _S_extra_categories_size = _GLIBCPP_NUM_CATEGORIES;
+
+ // Names of underlying locale categories.
+ // NB: locale::global() has to know how to modify all the
+ // underlying categories, not just the ones required by the C++
+ // standard.
+ static const char* _S_categories[_S_categories_size
+ + _S_extra_categories_size];
+
+ explicit
+ locale(_Impl*) throw();
+
+ static inline void
+ _S_initialize()
+ {
+ if (!_S_classic)
+ classic();
+ }
+
+ static category
+ _S_normalize_category(category);
+
+ void
+ _M_coalesce(const locale& __base, const locale& __add, category __cat);
+ };
+
+
+ // Implementation object for locale
+ class locale::_Impl
+ {
+ public:
+ // Friends.
+ friend class locale;
+ friend class locale::facet;
+
+ template<typename _Facet>
+ friend const _Facet&
+ use_facet(const locale&);
+
+ template<typename _Facet>
+ friend bool
+ has_facet(const locale&) throw();
+
+ template<typename _Facet>
+ friend const __locale_cache<_Facet>&
+ __use_cache(const locale&);
+
+ private:
+ // Data Members.
+ _Atomic_word _M_references;
+ facet** _M_facets;
+ size_t _M_facets_size;
+
+ char* _M_names[_S_categories_size
+ + _S_extra_categories_size];
+ static const locale::id* const _S_id_ctype[];
+ static const locale::id* const _S_id_numeric[];
+ static const locale::id* const _S_id_collate[];
+ static const locale::id* const _S_id_time[];
+ static const locale::id* const _S_id_monetary[];
+ static const locale::id* const _S_id_messages[];
+ static const locale::id* const* const _S_facet_categories[];
+
+ inline void
+ _M_add_reference() throw()
+ { __atomic_add(&_M_references, 1); }
+
+ inline void
+ _M_remove_reference() throw()
+ {
+ if (__exchange_and_add(&_M_references, -1) == 1)
+ {
+ try
+ { delete this; }
+ catch(...)
+ { }
+ }
+ }
+
+ _Impl(const _Impl&, size_t);
+ _Impl(const char*, size_t);
+ _Impl(facet**, size_t, bool);
+
+ ~_Impl() throw();
+
+ _Impl(const _Impl&); // Not defined.
+
+ void
+ operator=(const _Impl&); // Not defined.
+
+ inline bool
+ _M_check_same_name()
+ {
+ bool __ret = true;
+ for (size_t __i = 0;
+ __ret && __i < _S_categories_size + _S_extra_categories_size - 1;
+ ++__i)
+ __ret &= (strcmp(_M_names[__i], _M_names[__i + 1]) == 0);
+ return __ret;
+ }
+
+ void
+ _M_replace_categories(const _Impl*, category);
+
+ void
+ _M_replace_category(const _Impl*, const locale::id* const*);
+
+ void
+ _M_replace_facet(const _Impl*, const locale::id*);
+
+ void
+ _M_install_facet(const locale::id*, facet*);
+
+ template<typename _Facet>
+ inline void
+ _M_init_facet(_Facet* __facet)
+ { _M_install_facet(&_Facet::id, __facet); }
+
+ // Retrieve the cache at __index. 0 is returned if the cache is
+ // missing. Cache is actually located at __index +
+ // _M_facets_size. __index must be < _M_facets_size.
+ inline __locale_cache_base*
+ _M_get_cache(size_t __index)
+ {
+ return (__locale_cache_base*)_M_facets[__index + _M_facets_size];
+ }
+
+ // Save the supplied cache at __id. Assumes _M_get_cache has been
+ // called.
+ void
+ _M_install_cache(__locale_cache_base* __cache, int __id)
+ {
+ _M_facets[__id + _M_facets_size] =
+ reinterpret_cast<locale::facet*>(__cache);
+ }
+
+ };
+
+ template<typename _Facet>
+ locale::locale(const locale& __other, _Facet* __f)
+ {
+ _M_impl = new _Impl(*__other._M_impl, 1);
+ _M_impl->_M_install_facet(&_Facet::id, __f);
+ for (size_t __i = 0;
+ __i < _S_categories_size + _S_extra_categories_size; ++__i)
+ {
+ delete [] _M_impl->_M_names[__i];
+ char* __new = new char[2];
+ strcpy(__new, "*");
+ _M_impl->_M_names[__i] = __new;
+ }
+ }
+
+
+ // 22.1.1.1.2 Class locale::facet
+ class locale::facet
+ {
+ private:
+ friend class locale;
+ friend class locale::_Impl;
+
+ _Atomic_word _M_references;
+
+ protected:
+ // Contains data from the underlying "C" library for the classic locale.
+ static __c_locale _S_c_locale;
+
+ // String literal for the name of the classic locale.
+ static char _S_c_name[2];
+
+ explicit
+ facet(size_t __refs = 0) throw();
+
+ virtual
+ ~facet();
+
+ static void
+ _S_create_c_locale(__c_locale& __cloc, const char* __s,
+ __c_locale __old = 0);
+
+ static __c_locale
+ _S_clone_c_locale(__c_locale& __cloc);
+
+ static void
+ _S_destroy_c_locale(__c_locale& __cloc);
+
+ private:
+ void
+ _M_add_reference() throw();
+
+ void
+ _M_remove_reference() throw();
+
+ facet(const facet&); // Not defined.
+
+ void
+ operator=(const facet&); // Not defined.
+ };
+
+
+ // 22.1.1.1.3 Class locale::id
+ class locale::id
+ {
+ private:
+ friend class locale;
+ friend class locale::_Impl;
+ template<typename _Facet>
+ friend const _Facet&
+ use_facet(const locale&);
+ template<typename _Facet>
+ friend bool
+ has_facet(const locale&) throw ();
+
+ // NB: There is no accessor for _M_index because it may be used
+ // before the constructor is run; the effect of calling a member
+ // function (even an inline) would be undefined.
+ mutable size_t _M_index;
+
+ // Last id number assigned.
+ static _Atomic_word _S_highwater;
+
+ void
+ operator=(const id&); // Not defined.
+
+ id(const id&); // Not defined.
+
+ public:
+ // NB: This class is always a static data member, and thus can be
+ // counted on to be zero-initialized.
+ id();
+
+ inline size_t
+ _M_id() const
+ {
+ if (!_M_index)
+ _M_index = 1 + __exchange_and_add(&_S_highwater, 1);
+ return _M_index - 1;
+ }
+ };
+} // namespace std
+
+#endif
diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h
index 660bad3c11a..37f6875bc25 100644
--- a/libstdc++-v3/include/bits/locale_facets.h
+++ b/libstdc++-v3/include/bits/locale_facets.h
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -44,7 +44,9 @@
#include <ctime> // For struct tm
#include <cwctype> // For wctype_t
-#include <ios> // For ios_base
+#include <iosfwd>
+#include <bits/ios_base.h> // For ios_base, ios_base::iostate
+#include <streambuf>
namespace std
{
@@ -55,8 +57,109 @@ namespace std
# define _GLIBCPP_NUM_FACETS 14
#endif
+ // Convert string to numeric value of type _Tv and store results.
+ // NB: This is specialized for all required types, there is no
+ // generic definition.
+ template<typename _Tv>
+ void
+ __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
+ const __c_locale& __cloc, int __base = 10);
+
+ // Explicit specializations for required types.
+ template<>
+ void
+ __convert_to_v(const char*, long&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ template<>
+ void
+ __convert_to_v(const char*, unsigned long&, ios_base::iostate&,
+ const __c_locale&, int);
+
+#ifdef _GLIBCPP_USE_LONG_LONG
+ template<>
+ void
+ __convert_to_v(const char*, long long&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ template<>
+ void
+ __convert_to_v(const char*, unsigned long long&, ios_base::iostate&,
+ const __c_locale&, int);
+#endif
+
+ template<>
+ void
+ __convert_to_v(const char*, float&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ template<>
+ void
+ __convert_to_v(const char*, double&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ template<>
+ void
+ __convert_to_v(const char*, long double&, ios_base::iostate&,
+ const __c_locale&, int);
+
+ // NB: __pad is a struct, rather than a function, so it can be
+ // partially-specialized.
template<typename _CharT, typename _Traits>
- struct __pad;
+ struct __pad
+ {
+ static void
+ _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
+ const _CharT* __olds, const streamsize __newlen,
+ const streamsize __oldlen, const bool __num);
+ };
+
+ // Used by both numeric and monetary facets.
+ // Check to make sure that the __grouping_tmp string constructed in
+ // money_get or num_get matches the canonical grouping for a given
+ // locale.
+ // __grouping_tmp is parsed L to R
+ // 1,222,444 == __grouping_tmp of "\1\3\3"
+ // __grouping is parsed R to L
+ // 1,222,444 == __grouping of "\3" == "\3\3\3"
+ template<typename _CharT>
+ bool
+ __verify_grouping(const basic_string<_CharT>& __grouping,
+ basic_string<_CharT>& __grouping_tmp);
+
+ // Used by both numeric and monetary facets.
+ // Inserts "group separator" characters into an array of characters.
+ // It's recursive, one iteration per group. It moves the characters
+ // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
+ // only with __gbeg != __gend.
+ template<typename _CharT>
+ _CharT*
+ __add_grouping(_CharT* __s, _CharT __sep,
+ const char* __gbeg, const char* __gend,
+ const _CharT* __first, const _CharT* __last);
+
+ // This template permits specializing facet output code for
+ // ostreambuf_iterator. For ostreambuf_iterator, sputn is
+ // significantly more efficient than incrementing iterators.
+ template<typename _CharT>
+ inline
+ ostreambuf_iterator<_CharT>
+ __write(ostreambuf_iterator<_CharT> __s, const _CharT* __ws, int __len)
+ {
+ __s._M_put(__ws, __len);
+ return __s;
+ }
+
+ // This is the unspecialized form of the template.
+ template<typename _CharT, typename _OutIter>
+ inline
+ _OutIter
+ __write(_OutIter __s, const _CharT* __ws, int __len)
+ {
+ for (int __j = 0; __j < __len; __j++, ++__s)
+ *__s = __ws[__j];
+ return __s;
+ }
// 22.2.1.1 Template class ctype
// Include host and configuration specific ctype enums for ctype_base.
@@ -424,14 +527,38 @@ namespace std
// 22.2.1.5 Template class codecvt
#include <bits/codecvt.h>
-
// 22.2.2 The numeric category.
class __num_base
{
+ public:
+ // NB: Code depends on the order of _S_atoms_out elements.
+ // Below are the indices into _S_atoms_out.
+ enum
+ {
+ _S_minus,
+ _S_plus,
+ _S_x,
+ _S_X,
+ _S_digits,
+ _S_digits_end = _S_digits + 16,
+ _S_udigits = _S_digits_end,
+ _S_udigits_end = _S_udigits + 16,
+ _S_e = _S_digits + 14, // For scientific notation, 'e'
+ _S_E = _S_udigits + 14, // For scientific notation, 'E'
+ _S_end = _S_udigits_end
+ };
+
+ // A list of valid numeric literals for output. This array
+ // contains chars that will be passed through the current locale's
+ // ctype<_CharT>.widen() and then used to render numbers.
+ // For the standard "C" locale, this is
+ // "-+xX0123456789abcdef0123456789ABCDEF".
+ static const char* _S_atoms_out;
+
protected:
// String literal of acceptable (narrow) input, for num_get.
// "0123456789eEabcdfABCDF"
- static const char _S_atoms[];
+ static const char* _S_atoms_in;
enum
{
@@ -443,7 +570,7 @@ namespace std
// num_put
// Construct and return valid scanf format for floating point types.
- static bool
+ static void
_S_format_float(const ios_base& __io, char* __fptr, char __mod,
streamsize __prec);
@@ -454,6 +581,9 @@ namespace std
template<typename _CharT>
+ class __locale_cache;
+
+ template<typename _CharT>
class numpunct : public locale::facet
{
public:
@@ -461,6 +591,8 @@ namespace std
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
+ friend class __locale_cache<numpunct<_CharT> >;
+
static locale::id id;
private:
@@ -725,7 +857,6 @@ namespace std
// Types:
typedef _CharT char_type;
typedef _OutIter iter_type;
-
static locale::id id;
explicit
@@ -775,6 +906,27 @@ namespace std
_M_convert_float(iter_type, ios_base& __io, char_type __fill,
char __mod, _ValueT __v) const;
+ void
+ _M_group_float(const string& __grouping, char_type __sep,
+ const char_type* __p, char_type* __new, char_type* __cs,
+ int& __len) const;
+
+ template<typename _ValueT>
+ iter_type
+ _M_convert_int(iter_type, ios_base& __io, char_type __fill,
+ _ValueT __v) const;
+
+ void
+ _M_group_int(const string& __grouping, char_type __sep,
+ ios_base& __io, char_type* __new, char_type* __cs,
+ int& __len) const;
+
+ void
+ _M_pad(char_type __fill, streamsize __w, ios_base& __io,
+ char_type* __new, const char_type* __cs, int& __len) const;
+
+#if 1
+ // XXX GLIBCXX_ABI Deprecated, compatibility only.
template<typename _ValueT>
iter_type
_M_convert_int(iter_type, ios_base& __io, char_type __fill,
@@ -791,8 +943,9 @@ namespace std
iter_type
_M_insert(iter_type, ios_base& __io, char_type __fill,
const char_type* __ws, int __len) const;
+#endif
- virtual
+ virtual
~num_put() { };
virtual iter_type
@@ -1011,22 +1164,10 @@ namespace std
public:
explicit
- __timepunct(size_t __refs = 0)
- : locale::facet(__refs)
- {
- _M_name_timepunct = new char[2];
- strcpy(_M_name_timepunct, "C");
- _M_initialize_timepunct();
- }
+ __timepunct(size_t __refs = 0);
explicit
- __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0)
- : locale::facet(__refs)
- {
- _M_name_timepunct = new char[strlen(__s) + 1];
- strcpy(_M_name_timepunct, __s);
- _M_initialize_timepunct(__cloc);
- }
+ __timepunct(__c_locale __cloc, const char* __s, size_t __refs = 0);
void
_M_put(_CharT* __s, size_t __maxlen, const _CharT* __format,
@@ -1123,11 +1264,7 @@ namespace std
protected:
virtual
- ~__timepunct()
- {
- delete [] _M_name_timepunct;
- _S_destroy_c_locale(_M_c_locale_timepunct);
- }
+ ~__timepunct();
// For use at construction time only.
void
@@ -1169,6 +1306,8 @@ namespace std
template<typename _CharT>
const _CharT* __timepunct<_CharT>::_S_timezones[14];
+ // Include host and configuration specific timepunct functions.
+ #include <bits/time_members.h>
template<typename _CharT, typename _InIter>
class time_get : public locale::facet, public time_base
@@ -1628,32 +1767,17 @@ namespace std
// Underlying "C" library locale information saved from
// initialization, needed by messages_byname as well.
__c_locale _M_c_locale_messages;
-#if 1
- // Only needed if glibc < 2.3
char* _M_name_messages;
-#endif
public:
static locale::id id;
explicit
- messages(size_t __refs = 0)
- : locale::facet(__refs)
- {
- _M_name_messages = new char[2];
- strcpy(_M_name_messages, "C");
- _M_c_locale_messages = _S_c_locale;
- }
+ messages(size_t __refs = 0);
// Non-standard.
explicit
- messages(__c_locale __cloc, const char* __s, size_t __refs = 0)
- : locale::facet(__refs)
- {
- _M_name_messages = new char[strlen(__s) + 1];
- strcpy(_M_name_messages, __s);
- _M_c_locale_messages = _S_clone_c_locale(__cloc);
- }
+ messages(__c_locale __cloc, const char* __s, size_t __refs = 0);
catalog
open(const basic_string<char>& __s, const locale& __loc) const
@@ -1673,11 +1797,7 @@ namespace std
protected:
virtual
- ~messages()
- {
- delete [] _M_name_messages;
- _S_destroy_c_locale(_M_c_locale_messages);
- }
+ ~messages();
virtual catalog
do_open(const basic_string<char>&, const locale&) const;
@@ -1751,9 +1871,6 @@ namespace std
messages<wchar_t>::do_get(catalog, int, int, const wstring&) const;
#endif
- // Include host and configuration specific messages virtual functions.
- #include <bits/messages_members.h>
-
template<typename _CharT>
class messages_byname : public messages<_CharT>
{
@@ -1762,15 +1879,7 @@ namespace std
typedef basic_string<_CharT> string_type;
explicit
- messages_byname(const char* __s, size_t __refs = 0)
- : messages<_CharT>(__refs)
- {
- delete [] _M_name_messages;
- _M_name_messages = new char[strlen(__s) + 1];
- strcpy(_M_name_messages, __s);
- _S_destroy_c_locale(_M_c_locale_messages);
- _S_create_c_locale(_M_c_locale_messages, __s);
- }
+ messages_byname(const char* __s, size_t __refs = 0);
protected:
virtual
@@ -1778,6 +1887,9 @@ namespace std
{ }
};
+ // Include host and configuration specific messages functions.
+ #include <bits/messages_members.h>
+
// Subclause convenience interfaces, inlines.
// NB: These are inline because, when used in a loop, some compilers
@@ -1846,6 +1958,93 @@ namespace std
inline _CharT
tolower(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
+
+ /**
+ * @if maint
+ * __locale_cache objects hold information extracted from facets in
+ * a form optimized for parsing and formatting. They are stored in
+ * a locale's facet array and accessed via __use_cache<_Facet>.
+ *
+ * The intent twofold: to avoid the costs of creating a locale
+ * object and to avoid calling the virtual functions in a locale's
+ * facet to look up data.
+ * @endif
+ */
+ class __locale_cache_base
+ {
+ friend class std::locale::_Impl;
+ friend class locale;
+
+ public:
+ virtual
+ ~__locale_cache_base() { }
+
+ };
+
+ // This template doesn't really get used for anything except a
+ // placeholder for specializations
+ template<typename _Facet>
+ class __locale_cache : public __locale_cache_base
+ {
+ // ctor
+ __locale_cache(const locale&) {}
+ };
+
+ template<typename _CharT>
+ class __locale_cache<numpunct<_CharT> > : public __locale_cache_base
+ {
+ // Types:
+ typedef _CharT char_type;
+ typedef char_traits<_CharT> traits_type;
+ typedef basic_string<_CharT> string_type;
+
+ public:
+ // Data Members:
+
+ // The sign used to separate decimal values: for standard US
+ // locales, this would usually be: "." Abstracted from
+ // numpunct::decimal_point().
+ _CharT _M_decimal_point;
+
+ // The sign used to separate groups of digits into smaller
+ // strings that the eye can parse with less difficulty: for
+ // standard US locales, this would usually be: "," Abstracted
+ // from numpunct::thousands_sep().
+ _CharT _M_thousands_sep;
+
+ // However the US's "false" and "true" are translated. From
+ // numpunct::truename() and numpunct::falsename(), respectively.
+ const _CharT* _M_truename;
+ const _CharT* _M_falsename;
+
+ // If we are checking groupings. This should be equivalent to
+ // numpunct::groupings().size() != 0
+ bool _M_use_grouping;
+
+ // If we are using numpunct's groupings, this is the current
+ // grouping string in effect (from numpunct::grouping()).
+ const char* _M_grouping;
+
+ // A list of valid numeric literals: for the standard "C"
+ // locale, this is "-+xX0123456789abcdef0123456789ABCDEF". This
+ // array contains the chars after having been passed through the
+ // current locale's ctype<_CharT>.widen().
+
+ // Copied here from __locale_cache<ctype> to save multiple cache
+ // access in num_put functions.
+ _CharT _M_atoms_out[__num_base::_S_end];
+
+ // ctor
+ __locale_cache(const locale& __loc);
+ __locale_cache(const locale& __loc, bool);
+
+ ~__locale_cache()
+ {
+ delete [] _M_truename;
+ delete [] _M_falsename;
+ delete [] _M_grouping;
+ }
+ };
} // namespace std
#endif
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index ce6f3d7d5ff..9ad4dfea389 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -36,13 +36,13 @@
#pragma GCC system_header
#include <cerrno>
-#include <clocale> // For localeconv
-#include <cstdlib> // For strof, strtold
-#include <cmath> // For ceil
-#include <cctype> // For isspace
-#include <limits> // For numeric_limits
+#include <clocale> // For localeconv
+#include <cstdlib> // For strof, strtold
+#include <cmath> // For ceil
+#include <cctype> // For isspace
+#include <limits> // For numeric_limits
+#include <typeinfo> // For bad_cast.
#include <bits/streambuf_iterator.h>
-#include <typeinfo> // For bad_cast.
namespace std
{
@@ -86,6 +86,23 @@ namespace std
return (__i < __loc._M_impl->_M_facets_size && __facets[__i]);
}
+ // Routine to access a cache for the locale. If the cache didn't
+ // exist before, it gets constructed on the fly.
+ template<typename _Facet>
+ inline const __locale_cache<_Facet>&
+ __use_cache(const locale& __loc)
+ {
+ size_t __i = _Facet::id._M_id();
+ if (__builtin_expect(__i >= __loc._M_impl->_M_facets_size,false))
+ __throw_bad_cast();
+ __locale_cache_base* __cache = __loc._M_impl->_M_get_cache(__i);
+ if (__builtin_expect(!__cache, false))
+ {
+ __cache = new __locale_cache<_Facet>(__loc);
+ __loc._M_impl->_M_install_cache(__cache, __i);
+ }
+ return static_cast<const __locale_cache<_Facet>&>(*__cache);
+ }
// Stage 1: Determine a conversion specifier.
template<typename _CharT, typename _InIter>
@@ -113,7 +130,7 @@ namespace std
}
// Next, strip leading zeros.
- const char_type __zero = __ctype.widen(_S_atoms[_M_zero]);
+ const char_type __zero = __ctype.widen(_S_atoms_in[_M_zero]);
bool __found_zero = false;
while (__traits_type::eq(__c, __zero) && __beg != __end)
{
@@ -122,14 +139,14 @@ namespace std
}
if (__found_zero)
{
- __xtrc += _S_atoms[_M_zero];
+ __xtrc += _S_atoms_in[_M_zero];
++__pos;
}
// Only need acceptable digits for floating point numbers.
const size_t __len = _M_E - _M_zero + 1;
char_type __watoms[__len];
- __ctype.widen(_S_atoms, _S_atoms + __len, __watoms);
+ __ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
bool __found_dec = false;
bool __found_sci = false;
const char_type __dec = __np.decimal_point();
@@ -150,7 +167,7 @@ namespace std
{
// Try first for acceptable digit; record it if found.
++__pos;
- __xtrc += _S_atoms[__p - __watoms];
+ __xtrc += _S_atoms_in[__p - __watoms];
++__sep_pos;
__c = *(++__beg);
}
@@ -261,7 +278,7 @@ namespace std
}
// Next, strip leading zeros and check required digits for base formats.
- const char_type __zero = __ctype.widen(_S_atoms[_M_zero]);
+ const char_type __zero = __ctype.widen(_S_atoms_in[_M_zero]);
const char_type __x = __ctype.widen('x');
const char_type __X = __ctype.widen('X');
if (__base == 10)
@@ -274,7 +291,7 @@ namespace std
}
if (__found_zero)
{
- __xtrc += _S_atoms[_M_zero];
+ __xtrc += _S_atoms_in[_M_zero];
++__pos;
if (__basefield == 0)
{
@@ -296,7 +313,7 @@ namespace std
{
if (__traits_type::eq(__c, __zero) && __beg != __end)
{
- __xtrc += _S_atoms[_M_zero];
+ __xtrc += _S_atoms_in[_M_zero];
++__pos;
__c = *(++__beg);
if ((__traits_type::eq(__c, __x) || __traits_type::eq(__c, __X))
@@ -319,7 +336,7 @@ namespace std
// Extract.
char_type __watoms[_M_size];
- __ctype.widen(_S_atoms, _S_atoms + __len, __watoms);
+ __ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
string __found_grouping;
const string __grouping = __np.grouping();
bool __check_grouping = __grouping.size();
@@ -333,7 +350,7 @@ namespace std
if (__p && !__traits_type::eq(__c, char_type()))
{
// Try first for acceptable digit; record it if found.
- __xtrc += _S_atoms[__p - __watoms];
+ __xtrc += _S_atoms_in[__p - __watoms];
++__pos;
++__sep_pos;
__c = *(++__beg);
@@ -606,14 +623,251 @@ namespace std
return __beg;
}
- // The following code uses snprintf (or sprintf(), when _GLIBCPP_USE_C99
- // is not defined) to convert floating point values for insertion into a
- // stream. An optimization would be to replace them with code that works
- // directly on a wide buffer and then use __pad to do the padding.
- // It would be good to replace them anyway to gain back the efficiency
- // that C++ provides by knowing up front the type of the values to insert.
- // Also, sprintf is dangerous since may lead to accidental buffer overruns.
- // This implementation follows the C++ standard fairly directly as
+ // For use by integer and floating-point types after they have been
+ // converted into a char_type string.
+ template<typename _CharT, typename _OutIter>
+ void
+ num_put<_CharT, _OutIter>::
+ _M_pad(_CharT __fill, streamsize __w, ios_base& __io,
+ _CharT* __new, const _CharT* __cs, int& __len) const
+ {
+ // [22.2.2.2.2] Stage 3.
+ // If necessary, pad.
+ __pad<_CharT, char_traits<_CharT> >::_S_pad(__io, __fill, __new, __cs,
+ __w, __len, true);
+ __len = static_cast<int>(__w);
+ }
+
+ // Forwarding functions to peel signed from unsigned integer types.
+ template<typename _CharT>
+ inline int
+ __int_to_char(_CharT* __out, const int __size, long __v,
+ const _CharT* __lit, ios_base::fmtflags __flags)
+ {
+ unsigned long __ul = static_cast<unsigned long>(__v);
+ bool __neg = false;
+ if (__v < 0)
+ {
+ __ul = -__ul;
+ __neg = true;
+ }
+ return __int_to_char(__out, __size, __ul, __lit, __flags, __neg);
+ }
+
+ template<typename _CharT>
+ inline int
+ __int_to_char(_CharT* __out, const int __size, unsigned long __v,
+ const _CharT* __lit, ios_base::fmtflags __flags)
+ { return __int_to_char(__out, __size, __v, __lit, __flags, false); }
+
+#ifdef _GLIBCPP_USE_LONG_LONG
+ template<typename _CharT>
+ inline int
+ __int_to_char(_CharT* __out, const int __size, long long __v,
+ const _CharT* __lit, ios_base::fmtflags __flags)
+ {
+ unsigned long long __ull = static_cast<unsigned long long>(__v);
+ bool __neg = false;
+ if (__v < 0)
+ {
+ __ull = -__ull;
+ __neg = true;
+ }
+ return __int_to_char(__out, __size, __ull, __lit, __flags, __neg);
+ }
+
+ template<typename _CharT>
+ inline int
+ __int_to_char(_CharT* __out, const int __size, unsigned long long __v,
+ const _CharT* __lit, ios_base::fmtflags __flags)
+ { return __int_to_char(__out, __size, __v, __lit, __flags, false); }
+#endif
+
+ template<typename _CharT, typename _ValueT>
+ int
+ __int_to_char(_CharT* __out, const int __size, _ValueT __v,
+ const _CharT* __lit, ios_base::fmtflags __flags, bool __neg)
+ {
+ // Don't write base if already 0.
+ const bool __showbase = (__flags & ios_base::showbase) && __v;
+ const ios_base::fmtflags __basefield = __flags & ios_base::basefield;
+ _CharT* __buf = __out + __size - 1;
+ _CharT* __bufend = __out + __size;
+
+ if (__builtin_expect(__basefield != ios_base::oct &&
+ __basefield != ios_base::hex, true))
+ {
+ // Decimal.
+ do
+ {
+ *__buf-- = __lit[(__v % 10) + __num_base::_S_digits];
+ __v /= 10;
+ }
+ while (__v != 0);
+ if (__neg)
+ *__buf-- = __lit[__num_base::_S_minus];
+ else if (__flags & ios_base::showpos)
+ *__buf-- = __lit[__num_base::_S_plus];
+ }
+ else if (__basefield == ios_base::oct)
+ {
+ // Octal.
+ do
+ {
+ *__buf-- = __lit[(__v & 0x7) + __num_base::_S_digits];
+ __v >>= 3;
+ }
+ while (__v != 0);
+ if (__showbase)
+ *__buf-- = __lit[__num_base::_S_digits];
+ }
+ else
+ {
+ // Hex.
+ const bool __uppercase = __flags & ios_base::uppercase;
+ int __case_offset = __uppercase
+ ? __num_base::_S_udigits : __num_base::_S_digits;
+ do
+ {
+ *__buf-- = __lit[(__v & 0xf) + __case_offset];
+ __v >>= 4;
+ }
+ while (__v != 0);
+ if (__showbase)
+ {
+ // 'x' or 'X'
+ *__buf-- = __lit[__num_base::_S_x + __uppercase];
+ // '0'
+ *__buf-- = __lit[__num_base::_S_digits];
+ }
+ }
+ int __ret = __bufend - __buf - 1;
+ return __ret;
+ }
+
+ template<typename _CharT, typename _OutIter>
+ void
+ num_put<_CharT, _OutIter>::
+ _M_group_int(const string& __grouping, _CharT __sep, ios_base& __io,
+ _CharT* __new, _CharT* __cs, int& __len) const
+ {
+ // By itself __add_grouping cannot deal correctly with __ws when
+ // ios::showbase is set and ios_base::oct || ios_base::hex.
+ // Therefore we take care "by hand" of the initial 0, 0x or 0X.
+ // However, remember that the latter do not occur if the number
+ // printed is '0' (__len == 1).
+ streamsize __off = 0;
+ const ios_base::fmtflags __basefield = __io.flags()
+ & ios_base::basefield;
+ if ((__io.flags() & ios_base::showbase) && __len > 1)
+ if (__basefield == ios_base::oct)
+ {
+ __off = 1;
+ *__new = *__cs;
+ }
+ else if (__basefield == ios_base::hex)
+ {
+ __off = 2;
+ *__new = *__cs;
+ *(__new + 1) = *(__cs + 1);
+ }
+ _CharT* __p;
+ __p = __add_grouping(__new + __off, __sep,
+ __grouping.c_str(),
+ __grouping.c_str() + __grouping.size(),
+ __cs + __off, __cs + __len);
+ __len = __p - __new;
+ }
+
+ template<typename _CharT, typename _OutIter>
+ template<typename _ValueT>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill,
+ _ValueT __v) const
+ {
+ typedef numpunct<_CharT> __facet_type;
+ typedef __locale_cache<numpunct<_CharT> > __cache_type;
+ const locale& __loc = __io._M_getloc();
+ const __cache_type& __lc = __use_cache<__facet_type>(__loc);
+ const _CharT* __lit = __lc._M_atoms_out;
+
+ // Long enough to hold hex, dec, and octal representations.
+ int __ilen = 4 * sizeof(_ValueT);
+ _CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __ilen));
+ // [22.2.2.2.2] Stage 1, numeric conversion to character.
+ // Result is returned right-justified in the buffer.
+ int __len;
+ __len = __int_to_char(&__cs[0], __ilen, __v, __lit, __io.flags());
+ __cs = __cs + __ilen - __len;
+
+ // Add grouping, if necessary.
+ _CharT* __cs2;
+ if (__lc._M_use_grouping)
+ {
+ // Grouping can add (almost) as many separators as the
+ // number of digits, but no more.
+ __cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len * 2));
+ _M_group_int(__lc._M_grouping, __lc._M_thousands_sep, __io,
+ __cs2, __cs, __len);
+ __cs = __cs2;
+ }
+
+ // Pad.
+ _CharT* __cs3;
+ streamsize __w = __io.width();
+ if (__w > static_cast<streamsize>(__len))
+ {
+ __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __w));
+ _M_pad(__fill, __w, __io, __cs3, __cs, __len);
+ __cs = __cs3;
+ }
+ __io.width(0);
+
+ // [22.2.2.2.2] Stage 4.
+ // Write resulting, fully-formatted string to output iterator.
+ return __write(__s, __cs, __len);
+ }
+
+ template<typename _CharT, typename _OutIter>
+ void
+ num_put<_CharT, _OutIter>::
+ _M_group_float(const string& __grouping, _CharT __sep, const _CharT* __p,
+ _CharT* __new, _CharT* __cs, int& __len) const
+ {
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+ //282. What types does numpunct grouping refer to?
+ // Add grouping, if necessary.
+ _CharT* __p2;
+ int __declen = __p ? __p - __cs : __len;
+ __p2 = __add_grouping(__new, __sep,
+ __grouping.c_str(),
+ __grouping.c_str() + __grouping.size(),
+ __cs, __cs + __declen);
+
+ // Tack on decimal part.
+ int __newlen = __p2 - __new;
+ if (__p)
+ {
+ char_traits<_CharT>::copy(__p2, __p, __len - __declen);
+ __newlen += __len - __declen;
+ }
+ __len = __newlen;
+#endif
+ }
+
+ // The following code uses snprintf (or sprintf(), when
+ // _GLIBCPP_USE_C99 is not defined) to convert floating point values
+ // for insertion into a stream. An optimization would be to replace
+ // them with code that works directly on a wide buffer and then use
+ // __pad to do the padding. It would be good to replace them anyway
+ // to gain back the efficiency that C++ provides by knowing up front
+ // the type of the values to insert. Also, sprintf is dangerous
+ // since may lead to accidental buffer overruns. This
+ // implementation follows the C++ standard fairly directly as
// outlined in 22.2.2.2 [lib.locale.num.put]
template<typename _CharT, typename _OutIter>
template<typename _ValueT>
@@ -622,48 +876,55 @@ namespace std
_M_convert_float(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
_ValueT __v) const
{
- // Note: digits10 is rounded down. We need to add 1 to ensure
- // we get the full available precision.
- const int __max_digits = numeric_limits<_ValueT>::digits10 + 1;
+ // Note: digits10 is rounded down: add 1 to ensure the maximum
+ // available precision. Then, in general, one more 1 needs to
+ // be added since, when the %{g,G} conversion specifiers are
+ // chosen inside _S_format_float, the precision field is "the
+ // maximum number of significant digits", *not* the "number of
+ // digits to appear after the decimal point", as happens for
+ // %{e,E,f,F} (C99, 7.19.6.1,4).
+ const int __max_digits = numeric_limits<_ValueT>::digits10 + 2;
+
+ // Use default precision if out of range.
streamsize __prec = __io.precision();
-
if (__prec > static_cast<streamsize>(__max_digits))
__prec = static_cast<streamsize>(__max_digits);
+ else if (__prec < static_cast<streamsize>(0))
+ __prec = static_cast<streamsize>(6);
- // Long enough for the max format spec.
- char __fbuf[16];
+ typedef numpunct<_CharT> __facet_type;
+ typedef __locale_cache<numpunct<_CharT> > __cache_type;
+ const locale __loc = __io._M_getloc();
+ const __cache_type& __lc = __use_cache<__facet_type>(__loc);
// [22.2.2.2.2] Stage 1, numeric conversion to character.
int __len;
+ // Long enough for the max format spec.
+ char __fbuf[16];
+
#ifdef _GLIBCPP_USE_C99
- // First try a buffer perhaps big enough (for sure sufficient for
- // non-ios_base::fixed outputs)
+ // First try a buffer perhaps big enough (for sure sufficient
+ // for non-ios_base::fixed outputs)
int __cs_size = __max_digits * 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- const bool __fp = _S_format_float(__io, __fbuf, __mod, __prec);
- if (__fp)
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale, __prec);
- else
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v, _S_c_locale);
+ _S_format_float(__io, __fbuf, __mod, __prec);
+ __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
+ _S_c_locale, __prec);
// If the buffer was not large enough, try again with the correct size.
if (__len >= __cs_size)
{
__cs_size = __len + 1;
__cs = static_cast<char*>(__builtin_alloca(__cs_size));
- if (__fp)
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale, __prec);
- else
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale);
+ __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
+ _S_c_locale, __prec);
}
#else
// Consider the possibility of long ios_base::fixed outputs
const bool __fixed = __io.flags() & ios_base::fixed;
const int __max_exp = numeric_limits<_ValueT>::max_exponent10;
+
// ios_base::fixed outputs may need up to __max_exp+1 chars
// for the integer part + up to __max_digits chars for the
// fractional part + 3 chars for sign, decimal point, '\0'. On
@@ -673,187 +934,53 @@ namespace std
: __max_digits * 3;
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- if (_S_format_float(__io, __fbuf, __mod, __prec))
- __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale, __prec);
- else
- __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale);
-#endif
- return _M_widen_float(__s, __io, __fill, __cs, __len);
- }
-
- template<typename _CharT, typename _OutIter>
- template<typename _ValueT>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
- char __modl, _ValueT __v) const
- {
- // [22.2.2.2.2] Stage 1, numeric conversion to character.
-
- // Long enough for the max format spec.
- char __fbuf[16];
- _S_format_int(__io, __fbuf, __mod, __modl);
-#ifdef _GLIBCPP_USE_C99
- // First try a buffer perhaps big enough.
- int __cs_size = 64;
- char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- int __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale);
- // If the buffer was not large enough, try again with the correct size.
- if (__len >= __cs_size)
- {
- __cs_size = __len + 1;
- __cs = static_cast<char*>(__builtin_alloca(__cs_size));
- __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
- _S_c_locale);
- }
-#else
- // Leave room for "+/-," "0x," and commas. This size is
- // arbitrary, but should be largely sufficient.
- char __cs[128];
- int __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale);
+ _S_format_float(__io, __fbuf, __mod, __prec);
+ __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale, __prec);
#endif
- return _M_widen_int(__s, __io, __fill, __cs, __len);
- }
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_widen_float(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs,
- int __len) const
- {
- typedef char_traits<_CharT> __traits_type;
// [22.2.2.2.2] Stage 2, convert to char_type, using correct
// numpunct.decimal_point() values for '.' and adding grouping.
- const locale __loc = __io.getloc();
const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+
_CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len));
- // Grouping can add (almost) as many separators as the number of
- // digits, but no more.
- _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __len * 2));
__ctype.widen(__cs, __cs + __len, __ws);
// Replace decimal point.
+ const _CharT __cdec = __ctype.widen('.');
+ const _CharT __dec = __lc._M_decimal_point;
const _CharT* __p;
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
- if (__p = __traits_type::find(__ws, __len, __ctype.widen('.')))
- __ws[__p - __ws] = __np.decimal_point();
+ if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
+ __ws[__p - __ws] = __dec;
-#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
-//282. What types does numpunct grouping refer to?
// Add grouping, if necessary.
- const string __grouping = __np.grouping();
- ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
- if (__grouping.size())
+ _CharT* __ws2;
+ if (__lc._M_use_grouping)
{
- _CharT* __p2;
- int __declen = __p ? __p - __ws : __len;
- __p2 = __add_grouping(__ws2, __np.thousands_sep(),
- __grouping.c_str(),
- __grouping.c_str() + __grouping.size(),
- __ws, __ws + __declen);
- int __newlen = __p2 - __ws2;
-
- // Tack on decimal part.
- if (__p)
- {
- __traits_type::copy(__p2, __p, __len - __declen);
- __newlen += __len - __declen;
- }
-
- // Switch strings, establish correct new length.
- __ws = __ws2;
- __len = __newlen;
+ // Grouping can add (almost) as many separators as the
+ // number of digits, but no more.
+ __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len * 2));
+ _M_group_float(__lc._M_grouping, __lc._M_thousands_sep, __p,
+ __ws2, __ws, __len);
+ __ws = __ws2;
}
-#endif
- return _M_insert(__s, __io, __fill, __ws, __len);
- }
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_widen_int(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs,
- int __len) const
- {
- // [22.2.2.2.2] Stage 2, convert to char_type, using correct
- // numpunct.decimal_point() values for '.' and adding grouping.
- const locale __loc = __io.getloc();
- const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
- _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __len));
- // Grouping can add (almost) as many separators as the number of
- // digits, but no more.
- _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __len * 2));
- __ctype.widen(__cs, __cs + __len, __ws);
-
- // Add grouping, if necessary.
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
- const string __grouping = __np.grouping();
- const ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
- if (__grouping.size())
- {
- // By itself __add_grouping cannot deal correctly with __ws when
- // ios::showbase is set and ios_base::oct || ios_base::hex.
- // Therefore we take care "by hand" of the initial 0, 0x or 0X.
- // However, remember that the latter do not occur if the number
- // printed is '0' (__len == 1).
- streamsize __off = 0;
- if ((__io.flags() & ios_base::showbase) && __len > 1)
- if (__basefield == ios_base::oct)
- {
- __off = 1;
- *__ws2 = *__ws;
- }
- else if (__basefield == ios_base::hex)
- {
- __off = 2;
- *__ws2 = *__ws;
- *(__ws2 + 1) = *(__ws + 1);
- }
- _CharT* __p;
- __p = __add_grouping(__ws2 + __off, __np.thousands_sep(),
- __grouping.c_str(),
- __grouping.c_str() + __grouping.size(),
- __ws + __off, __ws + __len);
- __len = __p - __ws2;
- // Switch strings.
- __ws = __ws2;
- }
- return _M_insert(__s, __io, __fill, __ws, __len);
- }
-
- // For use by integer and floating-point types after they have been
- // converted into a char_type string.
- template<typename _CharT, typename _OutIter>
- _OutIter
- num_put<_CharT, _OutIter>::
- _M_insert(_OutIter __s, ios_base& __io, _CharT __fill, const _CharT* __ws,
- int __len) const
- {
- typedef char_traits<_CharT> __traits_type;
- // [22.2.2.2.2] Stage 3.
+ // Pad.
+ _CharT* __ws3;
streamsize __w = __io.width();
- _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
- * __w));
if (__w > static_cast<streamsize>(__len))
{
- __pad<_CharT, __traits_type>::_S_pad(__io, __fill, __ws2, __ws,
- __w, __len, true);
- __len = static_cast<int>(__w);
- // Switch strings.
- __ws = __ws2;
+ __ws3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
+ _M_pad(__fill, __w, __io, __ws3, __ws, __len);
+ __ws = __ws3;
}
__io.width(0);
-
+
// [22.2.2.2.2] Stage 4.
// Write resulting, fully-formatted string to output iterator.
- for (int __j = 0; __j < __len; ++__j, ++__s)
- *__s = __ws[__j];
- return __s;
- }
+ return __write(__s, __ws, __len);
+ }
template<typename _CharT, typename _OutIter>
_OutIter
@@ -864,19 +991,35 @@ namespace std
if ((__flags & ios_base::boolalpha) == 0)
{
unsigned long __uv = __v;
- __s = _M_convert_int(__s, __io, __fill, 'u', char(), __uv);
+ __s = _M_convert_int(__s, __io, __fill, __uv);
}
else
{
- typedef basic_string<_CharT> __string_type;
- locale __loc = __io.getloc();
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ typedef numpunct<_CharT> __facet_type;
+ typedef __locale_cache<numpunct<_CharT> > __cache_type;
+ const locale __loc = __io._M_getloc();
+ const __cache_type& __lc = __use_cache<__facet_type>(__loc);
+
+ typedef basic_string<_CharT> __string_type;
__string_type __name;
if (__v)
- __name = __np.truename();
+ __name = __lc._M_truename;
else
- __name = __np.falsename();
- __s = _M_insert(__s, __io, __fill, __name.c_str(), __name.size());
+ __name = __lc._M_falsename;
+
+ const _CharT* __cs = __name.c_str();
+ int __len = __name.size();
+ _CharT* __cs3;
+ streamsize __w = __io.width();
+ if (__w > static_cast<streamsize>(__len))
+ {
+ __cs3 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __w));
+ _M_pad(__fill, __w, __io, __cs3, __cs, __len);
+ __cs = __cs3;
+ }
+ __io.width(0);
+ __s = __write(__s, __cs, __len);
}
return __s;
}
@@ -885,28 +1028,28 @@ namespace std
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
- { return _M_convert_int(__s, __io, __fill, 'd', char(), __v); }
+ { return _M_convert_int(__s, __io, __fill, __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long __v) const
- { return _M_convert_int(__s, __io, __fill, 'u', char(), __v); }
+ { return _M_convert_int(__s, __io, __fill, __v); }
#ifdef _GLIBCPP_USE_LONG_LONG
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __b, char_type __fill, long long __v) const
- { return _M_convert_int(__s, __b, __fill, 'd', 'l', __v); }
+ { return _M_convert_int(__s, __b, __fill, __v); }
template<typename _CharT, typename _OutIter>
_OutIter
num_put<_CharT, _OutIter>::
do_put(iter_type __s, ios_base& __io, char_type __fill,
unsigned long long __v) const
- { return _M_convert_int(__s, __io, __fill, 'u', 'l', __v); }
+ { return _M_convert_int(__s, __io, __fill, __v); }
#endif
template<typename _CharT, typename _OutIter>
@@ -934,7 +1077,7 @@ namespace std
__io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
try
{
- __s = _M_convert_int(__s, __io, __fill, 'u', char(),
+ __s = _M_convert_int(__s, __io, __fill,
reinterpret_cast<unsigned long>(__v));
__io.flags(__flags);
}
@@ -1135,7 +1278,7 @@ namespace std
}
// Strip leading zeros.
- while (__temp_units[0] == __ctype.widen('0'))
+ while (__temp_units.size() > 1 && __temp_units[0] == __ctype.widen('0'))
__temp_units.erase(__temp_units.begin());
if (__sign.size() && __sign == __neg_sign)
@@ -1191,7 +1334,8 @@ namespace std
char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
int __len = __convert_from_v(__cs, 0, "%.01Lf", __units, _S_c_locale);
#endif
- _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __cs_size));
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __cs_size));
__ctype.widen(__cs, __cs + __len, __ws);
string_type __digits(__ws);
return this->do_put(__s, __intl, __io, __fill, __digits);
@@ -1285,7 +1429,7 @@ namespace std
const char* __gend = __gbeg + __grouping.size();
const int __n = (__end - __beg) * 2;
_CharT* __ws2 =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
+ static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __n));
_CharT* __ws_end = __add_grouping(__ws2, __sep, __gbeg,
__gend, __beg, __end);
__value.insert(0, __ws2, __ws_end - __ws2);
@@ -1354,8 +1498,7 @@ namespace std
}
// Write resulting, fully-formatted string to output iterator.
- for (size_type __j = 0; __j < __len; ++__j, ++__s)
- *__s = __res[__j];
+ __s = __write(__s, __res.c_str(), __len);
}
__io.width(0);
return __s;
@@ -1611,7 +1754,8 @@ namespace std
ios_base::iostate& __err) const
{
typedef char_traits<_CharT> __traits_type;
- int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int) * __indexlen));
+ int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int)
+ * __indexlen));
size_t __nmatches = 0;
size_t __pos = 0;
bool __testvalid = true;
@@ -1623,12 +1767,12 @@ namespace std
if (__c == __names[__i1][0])
__matches[__nmatches++] = __i1;
- while(__nmatches > 1)
+ while (__nmatches > 1)
{
// Find smallest matching string.
size_t __minlen = 10;
for (size_t __i2 = 0; __i2 < __nmatches; ++__i2)
- __minlen = min(__minlen,
+ __minlen = min(__minlen,
__traits_type::length(__names[__matches[__i2]]));
if (__pos < __minlen && __beg != __end)
@@ -1848,8 +1992,7 @@ namespace std
}
else
__format = __c;
- __s = this->do_put(__s, __io, char_type(), __tm, __format,
- __mod);
+ __s = this->do_put(__s, __io, _CharT(), __tm, __format, __mod);
}
else
{
@@ -1873,8 +2016,7 @@ namespace std
// NB: This size is arbitrary. Should this be a data member,
// initialized at construction?
const size_t __maxlen = 64;
- char_type* __res =
- static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
+ char_type* __res = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __maxlen));
// NB: In IEE 1003.1-200x, and perhaps other locale models, it
// is possible that the format character will be longer than one
@@ -1898,10 +2040,7 @@ namespace std
__tp._M_put(__res, __maxlen, __fmt, __tm);
// Write resulting, fully-formatted string to output iterator.
- size_t __len = char_traits<char_type>::length(__res);
- for (size_t __i = 0; __i < __len; ++__i, ++__s)
- *__s = __res[__i];
- return __s;
+ return __write(__s, __res, char_traits<char_type>::length(__res));
}
@@ -1923,9 +2062,37 @@ namespace std
do_compare(const _CharT* __lo1, const _CharT* __hi1,
const _CharT* __lo2, const _CharT* __hi2) const
{
+ // strcoll assumes zero-terminated strings so we make a copy
+ // and then put a zero at the end.
const string_type __one(__lo1, __hi1);
const string_type __two(__lo2, __hi2);
- return _M_compare(__one.c_str(), __two.c_str());
+
+ const _CharT* __p = __one.c_str();
+ const _CharT* __pend = __one.c_str() + __one.length();
+ const _CharT* __q = __two.c_str();
+ const _CharT* __qend = __two.c_str() + __two.length();
+
+ // strcoll stops when it sees a nul character so we break
+ // the strings into zero-terminated substrings and pass those
+ // to strcoll.
+ for (;;)
+ {
+ int __res = _M_compare(__p, __q);
+ if (__res)
+ return __res;
+
+ __p += char_traits<_CharT>::length(__p);
+ __q += char_traits<_CharT>::length(__q);
+ if (__p == __pend && __q == __qend)
+ return 0;
+ else if (__p == __pend)
+ return -1;
+ else if (__q == __qend)
+ return 1;
+
+ __p++;
+ __q++;
+ }
}
template<typename _CharT>
@@ -1933,19 +2100,43 @@ namespace std
collate<_CharT>::
do_transform(const _CharT* __lo, const _CharT* __hi) const
{
+ // strxfrm assumes zero-terminated strings so we make a copy
+ string_type __str(__lo, __hi);
+
+ const _CharT* __p = __str.c_str();
+ const _CharT* __pend = __str.c_str() + __str.length();
+
size_t __len = (__hi - __lo) * 2;
- // First try a buffer perhaps big enough.
- _CharT* __c =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
- size_t __res = _M_transform(__c, __lo, __len);
- // If the buffer was not large enough, try again with the correct size.
- if (__res >= __len)
+
+ string_type __ret;
+
+ // strxfrm stops when it sees a nul character so we break
+ // the string into zero-terminated substrings and pass those
+ // to strxfrm.
+ for (;;)
{
- __c =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__res + 1)));
- _M_transform(__c, __lo, __res + 1);
+ // First try a buffer perhaps big enough.
+ _CharT* __c =
+ static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __len));
+ size_t __res = _M_transform(__c, __p, __len);
+ // If the buffer was not large enough, try again with the
+ // correct size.
+ if (__res >= __len)
+ {
+ __len = __res + 1;
+ __c = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len));
+ __res = _M_transform(__c, __p, __res + 1);
+ }
+
+ __ret.append(__c, __res);
+ __p += char_traits<_CharT>::length(__p);
+ if (__p == __pend)
+ return __ret;
+
+ __p++;
+ __ret.push_back(_CharT());
}
- return string_type(__c);
}
template<typename _CharT>
@@ -1960,22 +2151,6 @@ namespace std
return static_cast<long>(__val);
}
- // Convert string to numeric value of type _Tv and store results.
- // NB: This is specialized for all required types, there is no
- // generic definition.
- template<typename _Tv>
- void
- __convert_to_v(const char* __in, _Tv& __out, ios_base::iostate& __err,
- const __c_locale& __cloc, int __base = 10);
-
- // Convert numeric value of type _Tv to string and return length of string.
- // If snprintf is available use it, otherwise fall back to the unsafe sprintf
- // which, in general, can be dangerous and should be avoided.
- template<typename _Tv>
- int
- __convert_from_v(char* __out, const int __size, const char* __fmt,
- _Tv __v, const __c_locale&, int __prec = -1);
-
// Construct correctly padded string, as per 22.2.2.2.2
// Assumes
// __newlen > __oldlen
@@ -1988,15 +2163,6 @@ namespace std
// NB: Of the two parameters, _CharT can be deduced from the
// function arguments. The other (_Traits) has to be explicitly specified.
template<typename _CharT, typename _Traits>
- struct __pad
- {
- static void
- _S_pad(ios_base& __io, _CharT __fill, _CharT* __news,
- const _CharT* __olds, const streamsize __newlen,
- const streamsize __oldlen, const bool __num);
- };
-
- template<typename _CharT, typename _Traits>
void
__pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill,
_CharT* __news, const _CharT* __olds,
@@ -2004,7 +2170,8 @@ namespace std
const streamsize __oldlen, const bool __num)
{
size_t __plen = static_cast<size_t>(__newlen - __oldlen);
- _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __plen));
+ _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __plen));
_Traits::assign(__pads, __plen, __fill);
_CharT* __beg;
@@ -2074,14 +2241,6 @@ namespace std
__newlen - __beglen - __mod);
}
- // Used by both numeric and monetary facets.
- // Check to make sure that the __grouping_tmp string constructed in
- // money_get or num_get matches the canonical grouping for a given
- // locale.
- // __grouping_tmp is parsed L to R
- // 1,222,444 == __grouping_tmp of "/1/3/3"
- // __grouping is parsed R to L
- // 1,222,444 == __grouping of "/3" == "/3/3/3"
template<typename _CharT>
bool
__verify_grouping(const basic_string<_CharT>& __grouping,
@@ -2106,11 +2265,6 @@ namespace std
return __test;
}
- // Used by both numeric and monetary facets.
- // Inserts "group separator" characters into an array of characters.
- // It's recursive, one iteration per group. It moves the characters
- // in the buffer this way: "xxxx12345" -> "12,345xxx". Call this
- // only with __gbeg != __gend.
template<typename _CharT>
_CharT*
__add_grouping(_CharT* __s, _CharT __sep,
@@ -2131,9 +2285,249 @@ namespace std
return __s;
}
+#if 1
+ // XXX GLIBCXX_ABI Deprecated, compatibility only.
+ template<typename _CharT, typename _OutIter>
+ template<typename _ValueT>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill, char __mod,
+ char __modl, _ValueT __v) const
+ {
+ // [22.2.2.2.2] Stage 1, numeric conversion to character.
+
+ // Long enough for the max format spec.
+ char __fbuf[16];
+ _S_format_int(__io, __fbuf, __mod, __modl);
+#ifdef _GLIBCPP_USE_C99
+ // First try a buffer perhaps big enough.
+ int __cs_size = 64;
+ char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+ int __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
+ _S_c_locale);
+ // If the buffer was not large enough, try again with the correct size.
+ if (__len >= __cs_size)
+ {
+ __cs_size = __len + 1;
+ __cs = static_cast<char*>(__builtin_alloca(__cs_size));
+ __len = __convert_from_v(__cs, __cs_size, __fbuf, __v,
+ _S_c_locale);
+ }
+#else
+ // Leave room for "+/-," "0x," and commas. This size is
+ // arbitrary, but should be largely sufficient.
+ char __cs[128];
+ int __len = __convert_from_v(__cs, 0, __fbuf, __v, _S_c_locale);
+#endif
+ return _M_widen_int(__s, __io, __fill, __cs, __len);
+ }
+
+ template<typename _CharT, typename _OutIter>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_widen_float(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs,
+ int __len) const
+ {
+ typedef char_traits<_CharT> __traits_type;
+ // [22.2.2.2.2] Stage 2, convert to char_type, using correct
+ // numpunct.decimal_point() values for '.' and adding grouping.
+ const locale __loc = __io.getloc();
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len));
+ // Grouping can add (almost) as many separators as the number of
+ // digits, but no more.
+ _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len * 2));
+ __ctype.widen(__cs, __cs + __len, __ws);
+
+ // Replace decimal point.
+ const _CharT* __p;
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ if (__p = __traits_type::find(__ws, __len, __ctype.widen('.')))
+ __ws[__p - __ws] = __np.decimal_point();
+
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+//282. What types does numpunct grouping refer to?
+ // Add grouping, if necessary.
+ const string __grouping = __np.grouping();
+ if (__grouping.size())
+ {
+ _CharT* __p2;
+ int __declen = __p ? __p - __ws : __len;
+ __p2 = __add_grouping(__ws2, __np.thousands_sep(),
+ __grouping.c_str(),
+ __grouping.c_str() + __grouping.size(),
+ __ws, __ws + __declen);
+ int __newlen = __p2 - __ws2;
+
+ // Tack on decimal part.
+ if (__p)
+ {
+ __traits_type::copy(__p2, __p, __len - __declen);
+ __newlen += __len - __declen;
+ }
+
+ // Switch strings, establish correct new length.
+ __ws = __ws2;
+ __len = __newlen;
+ }
+#endif
+ return _M_insert(__s, __io, __fill, __ws, __len);
+ }
+
+ template<typename _CharT, typename _OutIter>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_widen_int(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs,
+ int __len) const
+ {
+ // [22.2.2.2.2] Stage 2, convert to char_type, using correct
+ // numpunct.decimal_point() values for '.' and adding grouping.
+ const locale __loc = __io.getloc();
+ const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
+ _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len));
+ // Grouping can add (almost) as many separators as the number of
+ // digits, but no more.
+ _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __len * 2));
+ __ctype.widen(__cs, __cs + __len, __ws);
+
+ // Add grouping, if necessary.
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ const string __grouping = __np.grouping();
+ if (__grouping.size())
+ {
+ // By itself __add_grouping cannot deal correctly with __ws when
+ // ios::showbase is set and ios_base::oct || ios_base::hex.
+ // Therefore we take care "by hand" of the initial 0, 0x or 0X.
+ // However, remember that the latter do not occur if the number
+ // printed is '0' (__len == 1).
+ streamsize __off = 0;
+ const ios_base::fmtflags __basefield = __io.flags()
+ & ios_base::basefield;
+ if ((__io.flags() & ios_base::showbase) && __len > 1)
+ if (__basefield == ios_base::oct)
+ {
+ __off = 1;
+ *__ws2 = *__ws;
+ }
+ else if (__basefield == ios_base::hex)
+ {
+ __off = 2;
+ *__ws2 = *__ws;
+ *(__ws2 + 1) = *(__ws + 1);
+ }
+ _CharT* __p;
+ __p = __add_grouping(__ws2 + __off, __np.thousands_sep(),
+ __grouping.c_str(),
+ __grouping.c_str() + __grouping.size(),
+ __ws + __off, __ws + __len);
+ __len = __p - __ws2;
+ // Switch strings.
+ __ws = __ws2;
+ }
+ return _M_insert(__s, __io, __fill, __ws, __len);
+ }
+
+ // For use by integer and floating-point types after they have been
+ // converted into a char_type string.
+ template<typename _CharT, typename _OutIter>
+ _OutIter
+ num_put<_CharT, _OutIter>::
+ _M_insert(_OutIter __s, ios_base& __io, _CharT __fill, const _CharT* __ws,
+ int __len) const
+ {
+ typedef char_traits<_CharT> __traits_type;
+ // [22.2.2.2.2] Stage 3.
+ // If necessary, pad.
+ streamsize __w = __io.width();
+ _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
+ * __w));
+ if (__w > static_cast<streamsize>(__len))
+ {
+ __pad<_CharT, __traits_type>::_S_pad(__io, __fill, __ws2, __ws,
+ __w, __len, true);
+ __len = static_cast<int>(__w);
+ // Switch strings.
+ __ws = __ws2;
+ }
+ __io.width(0);
+
+ // [22.2.2.2.2] Stage 4.
+ // Write resulting, fully-formatted string to output iterator.
+ return __write(__s, __ws, __len);
+ }
+#endif
+
+ template<typename _CharT>
+ __locale_cache<numpunct<_CharT> >::__locale_cache(const locale& __loc)
+ : _M_truename(0), _M_falsename(0), _M_use_grouping(false),
+ _M_grouping(0)
+ {
+ if (has_facet<numpunct<_CharT> >(__loc))
+ {
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ _M_decimal_point = __np.decimal_point();
+ _M_thousands_sep = __np.thousands_sep();
+
+ string_type __false = __np.falsename();
+ _CharT* __falsename = new _CharT[__false.length() + 1];
+ __false.copy(__falsename, __false.length());
+ __falsename[__false.length()] = _CharT();
+ _M_falsename = __falsename;
+
+ string_type __true = __np.truename();
+ _CharT* __truename = new _CharT[__true.length() + 1];
+ __true.copy(__truename, __true.length());
+ __truename[__true.length()] = _CharT();
+ _M_truename = __truename;
+
+ string __grouping = __np.grouping();
+ char* __group = new char[__grouping.length() + 1];
+ __grouping.copy(__group, __grouping.length());
+ __group[__grouping.length()] = 0;
+ _M_grouping = __group;
+
+ _M_use_grouping = __grouping.length() != 0
+ && __grouping.data()[0] != 0;
+ }
+
+ if (has_facet<ctype<_CharT> >(__loc))
+ {
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
+ __ct.widen(__num_base::_S_atoms_out,
+ __num_base::_S_atoms_out + __num_base::_S_end,
+ _M_atoms_out);
+ }
+ }
+
+ // Static locale cache initialization. Only instantiated with char
+ // and wchar_t, so no need to check has_facet.
+ template<typename _CharT>
+ __locale_cache<numpunct<_CharT> >::
+ __locale_cache(const locale& __loc, bool)
+ {
+ // Grab pointers to numpunct static strings
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ _M_thousands_sep = __np._M_thousands_sep;
+ _M_decimal_point = __np._M_decimal_point;
+ _M_falsename = __np._M_falsename;
+ _M_truename = __np._M_truename;
+ _M_grouping = __np._M_grouping;
+ _M_use_grouping = false;
+
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
+ __ct.widen(__num_base::_S_atoms_out,
+ __num_base::_S_atoms_out + __num_base::_S_end,
+ _M_atoms_out);
+ }
+
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class moneypunct<char, false>;
extern template class moneypunct<char, true>;
extern template class moneypunct_byname<char, false>;
@@ -2387,6 +2781,7 @@ namespace std
bool
has_facet<messages<wchar_t> >(const locale&);
#endif
+#endif
} // namespace std
#endif
diff --git a/libstdc++-v3/include/bits/localefwd.h b/libstdc++-v3/include/bits/localefwd.h
index 76279609921..ac9e1a95425 100644
--- a/libstdc++-v3/include/bits/localefwd.h
+++ b/libstdc++-v3/include/bits/localefwd.h
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -37,18 +37,15 @@
* You should not attempt to use it directly.
*/
-#ifndef _CPP_BITS_LOCCORE_H
-#define _CPP_BITS_LOCCORE_H 1
+#ifndef _CPP_BITS_LOCALE_FWD_H
+#define _CPP_BITS_LOCALE_FWD_H 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/c++locale.h> // Defines __c_locale, config-specific includes
-#include <climits> // For CHAR_BIT
-#include <cctype> // For isspace, etc.
-#include <string> // For string.
+#include <iosfwd> // For ostreambuf_iterator, istreambuf_iterator
#include <bits/functexcept.h>
-#include <bits/atomicity.h>
namespace std
{
@@ -108,7 +105,6 @@ namespace std
inline _CharT
tolower(_CharT, const locale&);
-
// 22.2.1 and 22.2.1.3 ctype
class ctype_base;
template<typename _CharT>
@@ -175,324 +171,6 @@ namespace std
template<typename _CharT>
class messages_byname;
- // 22.1.1 Class locale
- class locale
- {
- public:
- // Types:
- typedef unsigned int category;
-
- // Forward decls and friends:
- class facet;
- class id;
- class _Impl;
-
- friend class facet;
- friend class _Impl;
-
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
-
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw();
-
- // Category values:
- // NB: Order must match _S_facet_categories definition in locale.cc
- static const category none = 0;
- static const category ctype = 1L << 0;
- static const category numeric = 1L << 1;
- static const category collate = 1L << 2;
- static const category time = 1L << 3;
- static const category monetary = 1L << 4;
- static const category messages = 1L << 5;
- static const category all = (ctype | numeric | collate |
- time | monetary | messages);
-
- // Construct/copy/destroy:
- locale() throw();
-
- locale(const locale& __other) throw();
-
- explicit
- locale(const char* __s);
-
- locale(const locale& __base, const char* __s, category __cat);
-
- locale(const locale& __base, const locale& __add, category __cat);
-
- template<typename _Facet>
- locale(const locale& __other, _Facet* __f);
-
- ~locale() throw();
-
- const locale&
- operator=(const locale& __other) throw();
-
- template<typename _Facet>
- locale
- combine(const locale& __other) const;
-
- // Locale operations:
- string
- name() const;
-
- bool
- operator==(const locale& __other) const throw ();
-
- inline bool
- operator!=(const locale& __other) const throw ()
- { return !(this->operator==(__other)); }
-
- template<typename _Char, typename _Traits, typename _Alloc>
- bool
- operator()(const basic_string<_Char, _Traits, _Alloc>& __s1,
- const basic_string<_Char, _Traits, _Alloc>& __s2) const;
-
- // Global locale objects:
- static locale
- global(const locale&);
-
- static const locale&
- classic();
-
- private:
- // The (shared) implementation
- _Impl* _M_impl;
-
- // The "C" reference locale
- static _Impl* _S_classic;
-
- // Current global reference locale
- static _Impl* _S_global;
-
- // Number of standard categories. For C++, these categories are
- // collate, ctype, monetary, numeric, time, and messages. These
- // directly correspond to ISO C99 macros LC_COLLATE, LC_CTYPE,
- // LC_MONETARY, LC_NUMERIC, and LC_TIME. In addition, POSIX (IEEE
- // 1003.1-2001) specifies LC_MESSAGES.
- static const size_t _S_categories_size = 6;
-
- // In addition to the standard categories, the underlying
- // operating system is allowed to define extra LC_*
- // macros. For GNU systems, the following are also valid:
- // LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,
- // and LC_IDENTIFICATION.
- static const size_t _S_extra_categories_size = _GLIBCPP_NUM_CATEGORIES;
-
- // Names of underlying locale categories.
- // NB: locale::global() has to know how to modify all the
- // underlying categories, not just the ones required by the C++
- // standard.
- static const char* _S_categories[_S_categories_size
- + _S_extra_categories_size];
-
- explicit
- locale(_Impl*) throw();
-
- static inline void
- _S_initialize()
- {
- if (!_S_classic)
- classic();
- }
-
- static category
- _S_normalize_category(category);
-
- void
- _M_coalesce(const locale& __base, const locale& __add, category __cat);
- };
-
-
- // Implementation object for locale
- class locale::_Impl
- {
- public:
- // Friends.
- friend class locale;
- friend class locale::facet;
-
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
-
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw();
-
- private:
- // Data Members.
- _Atomic_word _M_references;
- facet** _M_facets;
- size_t _M_facets_size;
-
- char* _M_names[_S_categories_size
- + _S_extra_categories_size];
- static const locale::id* const _S_id_ctype[];
- static const locale::id* const _S_id_numeric[];
- static const locale::id* const _S_id_collate[];
- static const locale::id* const _S_id_time[];
- static const locale::id* const _S_id_monetary[];
- static const locale::id* const _S_id_messages[];
- static const locale::id* const* const _S_facet_categories[];
-
- inline void
- _M_add_reference() throw()
- { __atomic_add(&_M_references, 1); }
-
- inline void
- _M_remove_reference() throw()
- {
- if (__exchange_and_add(&_M_references, -1) == 1)
- {
- try
- { delete this; }
- catch(...)
- { }
- }
- }
-
- _Impl(const _Impl&, size_t);
- _Impl(const char*, size_t);
- _Impl(facet**, size_t, bool);
-
- ~_Impl() throw();
-
- _Impl(const _Impl&); // Not defined.
-
- void
- operator=(const _Impl&); // Not defined.
-
- inline bool
- _M_check_same_name()
- {
- bool __ret = true;
- for (size_t __i = 0;
- __ret && __i < _S_categories_size + _S_extra_categories_size - 1;
- ++__i)
- __ret &= (strcmp(_M_names[__i], _M_names[__i + 1]) == 0);
- return __ret;
- }
-
- void
- _M_replace_categories(const _Impl*, category);
-
- void
- _M_replace_category(const _Impl*, const locale::id* const*);
-
- void
- _M_replace_facet(const _Impl*, const locale::id*);
-
- void
- _M_install_facet(const locale::id*, facet*);
-
- template<typename _Facet>
- inline void
- _M_init_facet(_Facet* __facet)
- { _M_install_facet(&_Facet::id, __facet); }
- };
-
- template<typename _Facet>
- locale::locale(const locale& __other, _Facet* __f)
- {
- _M_impl = new _Impl(*__other._M_impl, 1);
- _M_impl->_M_install_facet(&_Facet::id, __f);
- for (size_t __i = 0;
- __i < _S_categories_size + _S_extra_categories_size; ++__i)
- {
- delete [] _M_impl->_M_names[__i];
- char* __new = new char[2];
- strcpy(__new, "*");
- _M_impl->_M_names[__i] = __new;
- }
- }
-
- // 22.1.1.1.2 Class locale::facet
- class locale::facet
- {
- private:
- friend class locale;
- friend class locale::_Impl;
-
- _Atomic_word _M_references;
-
- protected:
- // Contains data from the underlying "C" library for default "C"
- // or "POSIX" locale.
- static __c_locale _S_c_locale;
-
- explicit
- facet(size_t __refs = 0) throw();
-
- virtual
- ~facet();
-
- static void
- _S_create_c_locale(__c_locale& __cloc, const char* __s,
- __c_locale __old = 0);
-
- static __c_locale
- _S_clone_c_locale(__c_locale& __cloc);
-
- static void
- _S_destroy_c_locale(__c_locale& __cloc);
-
- private:
- void
- _M_add_reference() throw();
-
- void
- _M_remove_reference() throw();
-
- facet(const facet&); // Not defined.
-
- void
- operator=(const facet&); // Not defined.
- };
-
-
- // 22.1.1.1.3 Class locale::id
- class locale::id
- {
- private:
- friend class locale;
- friend class locale::_Impl;
- template<typename _Facet>
- friend const _Facet&
- use_facet(const locale&);
- template<typename _Facet>
- friend bool
- has_facet(const locale&) throw ();
-
- // NB: There is no accessor for _M_index because it may be used
- // before the constructor is run; the effect of calling a member
- // function (even an inline) would be undefined.
- mutable size_t _M_index;
-
- // Last id number assigned.
- static _Atomic_word _S_highwater;
-
- void
- operator=(const id&); // Not defined.
-
- id(const id&); // Not defined.
-
- public:
- // NB: This class is always a static data member, and thus can be
- // counted on to be zero-initialized.
- id();
-
- inline size_t
- _M_id() const
- {
- if (!_M_index)
- _M_index = 1 + __exchange_and_add(&_S_highwater, 1);
- return _M_index - 1;
- }
- };
-
template<typename _Facet>
const _Facet&
use_facet(const locale& __loc);
diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc
index e42eca29192..ab15ae8703b 100644
--- a/libstdc++-v3/include/bits/ostream.tcc
+++ b/libstdc++-v3/include/bits/ostream.tcc
@@ -41,11 +41,19 @@ namespace std
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>::sentry::
sentry(basic_ostream<_CharT,_Traits>& __os)
- : _M_ok(__os.good()), _M_os(__os)
+ : _M_os(__os)
{
- // XXX MT
- if (_M_ok && __os.tie())
- __os.tie()->flush();
+ // XXX MT
+ if (__os.tie() && __os.good())
+ __os.tie()->flush();
+
+ if (__os.good())
+ _M_ok = true;
+ else
+ {
+ _M_ok = false;
+ __os.setstate(ios_base::failbit);
+ }
}
template<typename _CharT, typename _Traits>
@@ -58,11 +66,11 @@ namespace std
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -80,11 +88,11 @@ namespace std
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -102,11 +110,11 @@ namespace std
{
try
{ __pf(*this); }
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -126,11 +134,11 @@ namespace std
if (!__copy_streambufs(*this, __sbin, this->rdbuf()))
this->setstate(ios_base::failbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -153,11 +161,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -190,11 +198,11 @@ namespace std
this->setstate(ios_base::badbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -215,11 +223,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -254,11 +262,11 @@ namespace std
this->setstate(ios_base::badbit);
}
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -279,11 +287,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -305,11 +313,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -330,11 +338,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -355,11 +363,11 @@ namespace std
if (_M_fnumput->put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- this->setstate(ios_base::badbit);
+ this->_M_setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -468,7 +476,7 @@ namespace std
{
try
{
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * (__w + 1)));
__pads[0] = __c;
streamsize __len = 1;
@@ -481,11 +489,11 @@ namespace std
__out.write(__pads, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -504,7 +512,7 @@ namespace std
{
try
{
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
char* __pads = static_cast<char*>(__builtin_alloca(__w + 1));
__pads[0] = __c;
streamsize __len = 1;
@@ -517,11 +525,11 @@ namespace std
__out.write(__pads, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -539,7 +547,7 @@ namespace std
{
try
{
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
streamsize __len = static_cast<streamsize>(_Traits::length(__s));
if (__w > __len)
@@ -552,11 +560,11 @@ namespace std
__out.write(__s, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -588,7 +596,7 @@ namespace std
try
{
streamsize __len = static_cast<streamsize>(__clen);
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
if (__w > __len)
@@ -601,11 +609,11 @@ namespace std
__out.write(__str, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -626,7 +634,7 @@ namespace std
{
try
{
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
char* __pads = static_cast<char*>(__builtin_alloca(__w));
streamsize __len = static_cast<streamsize>(_Traits::length(__s));
@@ -640,11 +648,11 @@ namespace std
__out.write(__s, __len);
__out.width(0);
}
- catch(exception& __fail)
+ catch(...)
{
// 27.6.1.2.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
- __out.setstate(ios_base::badbit);
+ __out._M_setstate(ios_base::badbit);
if ((__out.exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
@@ -665,7 +673,7 @@ namespace std
if (__cerb)
{
const _CharT* __s = __str.data();
- streamsize __w = __out.width();
+ const streamsize __w = __out.width() > 0 ? __out.width() : 0;
_CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w));
streamsize __len = static_cast<streamsize>(__str.size());
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
@@ -689,6 +697,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_ostream<char>;
extern template ostream& endl(ostream&);
extern template ostream& ends(ostream&);
@@ -710,4 +719,5 @@ namespace std
extern template wostream& operator<<(wostream&, const wchar_t*);
extern template wostream& operator<<(wostream&, const char*);
#endif
+#endif
} // namespace std
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 009c409b6fb..3d226972251 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -609,7 +609,8 @@ namespace std
else {
__first = find(__first, __last, __val);
while (__first != __last) {
- _Integer __n = __count - 1;
+ typename iterator_traits<_ForwardIter>::difference_type __n = __count;
+ --__n;
_ForwardIter __i = __first;
++__i;
while (__i != __last && __n != 0 && *__i == __val) {
@@ -661,7 +662,8 @@ namespace std
++__first;
}
while (__first != __last) {
- _Integer __n = __count - 1;
+ typename iterator_traits<_ForwardIter>::difference_type __n = __count;
+ --__n;
_ForwardIter __i = __first;
++__i;
while (__i != __last && __n != 0 && __binary_pred(*__i, __val)) {
diff --git a/libstdc++-v3/include/bits/stl_alloc.h b/libstdc++-v3/include/bits/stl_alloc.h
index bab39fb7150..9677c3e89ee 100644
--- a/libstdc++-v3/include/bits/stl_alloc.h
+++ b/libstdc++-v3/include/bits/stl_alloc.h
@@ -1,6 +1,6 @@
// Allocators -*- C++ -*-
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003 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
@@ -85,7 +85,6 @@
#include <cstddef>
#include <cstdlib>
#include <cstring>
-#include <cassert>
#include <bits/functexcept.h> // For __throw_bad_alloc
#include <bits/stl_threads.h>
@@ -129,9 +128,7 @@ namespace std
{
private:
static void* _S_oom_malloc(size_t);
-#ifdef _GLIBCPP_DEPRECATED
static void* _S_oom_realloc(void*, size_t);
-#endif
static void (* __malloc_alloc_oom_handler)();
public:
@@ -148,7 +145,6 @@ namespace std
deallocate(void* __p, size_t /* __n */)
{ free(__p); }
-#ifdef _GLIBCPP_DEPRECATED
static void*
reallocate(void* __p, size_t /* old_sz */, size_t __new_sz)
{
@@ -157,7 +153,6 @@ namespace std
__result = _S_oom_realloc(__p, __new_sz);
return __result;
}
-#endif
static void (* __set_malloc_handler(void (*__f)()))()
{
@@ -191,7 +186,6 @@ namespace std
}
}
-#ifdef _GLIBCPP_DEPRECATED
template<int __inst>
void*
__malloc_alloc_template<__inst>::
@@ -211,7 +205,6 @@ namespace std
return __result;
}
}
-#endif
// Should not be referenced within the library anymore.
typedef __new_alloc __mem_interface;
@@ -257,10 +250,7 @@ namespace std
/**
* @if maint
* An adaptor for an underlying allocator (_Alloc) to check the size
- * arguments for debugging. Errors are reported using assert; these
- * checks can be disabled via NDEBUG, but the space penalty is still
- * paid, therefore it is far better to just use the underlying allocator
- * by itelf when no checking is desired.
+ * arguments for debugging.
*
* "There is some evidence that this can confuse Purify." - SGI comment
*
@@ -289,23 +279,23 @@ namespace std
deallocate(void* __p, size_t __n)
{
char* __real_p = (char*)__p - (int) _S_extra;
- assert(*(size_t*)__real_p == __n);
+ if (*(size_t*)__real_p != __n)
+ abort();
_Alloc::deallocate(__real_p, __n + (int) _S_extra);
}
-#ifdef _GLIBCPP_DEPRECATED
static void*
reallocate(void* __p, size_t __old_sz, size_t __new_sz)
{
char* __real_p = (char*)__p - (int) _S_extra;
- assert(*(size_t*)__real_p == __old_sz);
+ if (*(size_t*)__real_p != __old_sz)
+ abort();
char* __result = (char*) _Alloc::reallocate(__real_p,
__old_sz + (int) _S_extra,
__new_sz + (int) _S_extra);
*(size_t*)__result = __new_sz;
return __result + (int) _S_extra;
}
-#endif
};
@@ -407,8 +397,6 @@ namespace std
__atomic_add(&_S_force_new, 1);
else
__atomic_add(&_S_force_new, -1);
- // Trust but verify...
- assert(_S_force_new != 0);
}
if ((__n > (size_t) _MAX_BYTES) || (_S_force_new > 0))
@@ -456,10 +444,8 @@ namespace std
}
}
-#ifdef _GLIBCPP_DEPRECATED
static void*
reallocate(void* __p, size_t __old_sz, size_t __new_sz);
-#endif
};
template<bool __threads, int __inst> _Atomic_word
@@ -514,8 +500,8 @@ namespace std
_Obj* volatile* __my_free_list =
_S_free_list + _S_freelist_index(__bytes_left);
- ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;
- *__my_free_list = (_Obj*)_S_start_free;
+ ((_Obj*)(void*)_S_start_free) -> _M_free_list_link = *__my_free_list;
+ *__my_free_list = (_Obj*)(void*)_S_start_free;
}
_S_start_free = (char*) __new_alloc::allocate(__bytes_to_get);
if (_S_start_free == 0)
@@ -573,12 +559,12 @@ namespace std
__my_free_list = _S_free_list + _S_freelist_index(__n);
// Build free list in chunk.
- __result = (_Obj*)__chunk;
- *__my_free_list = __next_obj = (_Obj*)(__chunk + __n);
+ __result = (_Obj*)(void*)__chunk;
+ *__my_free_list = __next_obj = (_Obj*)(void*)(__chunk + __n);
for (__i = 1; ; __i++)
{
__current_obj = __next_obj;
- __next_obj = (_Obj*)((char*)__next_obj + __n);
+ __next_obj = (_Obj*)(void*)((char*)__next_obj + __n);
if (__nobjs - 1 == __i)
{
__current_obj -> _M_free_list_link = 0;
@@ -591,7 +577,6 @@ namespace std
}
-#ifdef _GLIBCPP_DEPRECATED
template<bool threads, int inst>
void*
__default_alloc_template<threads, inst>::
@@ -610,7 +595,6 @@ namespace std
deallocate(__p, __old_sz);
return __result;
}
-#endif
template<bool __threads, int __inst>
_STL_mutex_lock
@@ -980,9 +964,11 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class allocator<char>;
extern template class allocator<wchar_t>;
extern template class __default_alloc_template<true,0>;
+#endif
} // namespace std
#endif
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index fd066cc7e1f..529ad774175 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -106,9 +106,12 @@ namespace std
public:
/**
- * The default constructor gives an undefined state to this %iterator.
+ * The default constructor default-initializes member @p current.
+ * If it is a pointer, that means it is zero-initialized.
*/
- reverse_iterator() { }
+ // _GLIBCPP_RESOLVE_LIB_DEFECTS
+ // 235 No specification of default ctor for reverse_iterator
+ reverse_iterator() : current() { }
/**
* This %iterator will move in the opposite direction that @p x does.
diff --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc
index 5f57df583a7..be858621b85 100644
--- a/libstdc++-v3/include/bits/streambuf.tcc
+++ b/libstdc++-v3/include/bits/streambuf.tcc
@@ -1,6 +1,6 @@
// Stream buffer classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -67,8 +67,7 @@ namespace std
{
int_type __ret;
bool __testpos = _M_in_cur && _M_in_beg < _M_in_cur;
- bool __testne = _M_in_cur && !traits_type::eq(__c, this->gptr()[-1]);
- if (!__testpos || __testne)
+ if (!__testpos || !traits_type::eq(__c, this->gptr()[-1]))
__ret = this->pbackfail(traits_type::to_int_type(__c));
else
{
@@ -199,54 +198,46 @@ namespace std
basic_streambuf<_CharT, _Traits>* __sbin,
basic_streambuf<_CharT, _Traits>* __sbout)
{
- typedef typename _Traits::int_type int_type;
-
- streamsize __ret = 0;
- streamsize __bufsize = __sbin->in_avail();
- streamsize __xtrct;
- bool __testput = __sbout->_M_mode & ios_base::out;
- try
- {
- while (__testput && __bufsize != -1)
- {
- if (__bufsize != 0 && __sbin->gptr() != NULL
- && __sbin->gptr() + __bufsize <= __sbin->egptr())
- {
- __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
- __ret += __xtrct;
- __sbin->_M_in_cur_move(__xtrct);
- if (__xtrct != __bufsize)
- break;
- }
- else
- {
- size_t __size =
- __sbin->_M_buf_size_opt > 0 ? __sbin->_M_buf_size_opt : 1;
- _CharT* __buf =
- static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __size));
- streamsize __charsread = __sbin->sgetn(__buf, __size);
- __xtrct = __sbout->sputn(__buf, __charsread);
- __ret += __xtrct;
- if (__xtrct != __charsread)
- break;
- }
- if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof()))
- break;
- __bufsize = __sbin->in_avail();
- }
- }
- catch(exception& __fail)
- {
- __ios.setstate(ios_base::failbit);
- if ((__ios.exceptions() & ios_base::failbit) != 0)
- __throw_exception_again;
- }
- return __ret;
- }
+ streamsize __ret = 0;
+ try
+ {
+ typename _Traits::int_type __c = __sbin->sgetc();
+ while (!_Traits::eq_int_type(__c, _Traits::eof()))
+ {
+ const size_t __n = __sbin->_M_in_end - __sbin->_M_in_cur;
+ if (__n > 1)
+ {
+ const size_t __wrote = __sbout->sputn(__sbin->_M_in_cur,
+ __n);
+ __sbin->_M_in_cur_move(__wrote);
+ __ret += __wrote;
+ if (__wrote < __n)
+ break;
+ __c = __sbin->underflow();
+ }
+ else
+ {
+ __c = __sbout->sputc(_Traits::to_char_type(__c));
+ if (_Traits::eq_int_type(__c, _Traits::eof()))
+ break;
+ ++__ret;
+ __c = __sbin->snextc();
+ }
+ }
+ }
+ catch(exception& __fail)
+ {
+ __ios.setstate(ios_base::failbit);
+ if ((__ios.exceptions() & ios_base::failbit) != 0)
+ __throw_exception_again;
+ }
+ return __ret;
+ }
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template class basic_streambuf<char>;
extern template
streamsize
@@ -260,6 +251,7 @@ namespace std
__copy_streambufs(basic_ios<wchar_t>&, basic_streambuf<wchar_t>*,
basic_streambuf<wchar_t>*);
#endif
+#endif
} // namespace std
#endif
diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h b/libstdc++-v3/include/bits/streambuf_iterator.h
index 152df9c6e4b..d482aba8256 100644
--- a/libstdc++-v3/include/bits/streambuf_iterator.h
+++ b/libstdc++-v3/include/bits/streambuf_iterator.h
@@ -1,6 +1,6 @@
// Streambuf iterators
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -28,8 +28,6 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-// XXX Should specialize copy, find algorithms for streambuf iterators.
-
/** @file streambuf_iterator.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
@@ -40,6 +38,10 @@
#pragma GCC system_header
+#include <streambuf>
+
+// NB: Should specialize copy, find algorithms for streambuf iterators.
+
namespace std
{
// 24.5.3 Template class istreambuf_iterator
@@ -166,7 +168,6 @@ namespace std
bool _M_failed;
public:
- inline
ostreambuf_iterator(ostream_type& __s) throw ()
: _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { }
@@ -174,7 +175,13 @@ namespace std
: _M_sbuf(__s), _M_failed(!_M_sbuf) { }
ostreambuf_iterator&
- operator=(_CharT __c);
+ operator=(_CharT __c)
+ {
+ if (!_M_failed &&
+ _Traits::eq_int_type(_M_sbuf->sputc(__c), _Traits::eof()))
+ _M_failed = true;
+ return *this;
+ }
ostreambuf_iterator&
operator*() throw()
@@ -191,16 +198,15 @@ namespace std
bool
failed() const throw()
{ return _M_failed; }
- };
- template<typename _CharT, typename _Traits>
- inline ostreambuf_iterator<_CharT, _Traits>&
- ostreambuf_iterator<_CharT, _Traits>::operator=(_CharT __c)
- {
- if (!_M_failed &&
- _Traits::eq_int_type(_M_sbuf->sputc(__c), _Traits::eof()))
- _M_failed = true;
- return *this;
- }
+ ostreambuf_iterator&
+ _M_put(const _CharT* __ws, streamsize __len)
+ {
+ if (__builtin_expect(!_M_failed, true) &&
+ __builtin_expect(this->_M_sbuf->sputn(__ws, __len) != __len, false))
+ _M_failed = true;
+ return *this;
+ }
+ };
} // namespace std
#endif
diff --git a/libstdc++-v3/include/bits/valarray_meta.h b/libstdc++-v3/include/bits/valarray_meta.h
index 8b3e74fedc3..29a2dac2af4 100644
--- a/libstdc++-v3/include/bits/valarray_meta.h
+++ b/libstdc++-v3/include/bits/valarray_meta.h
@@ -268,7 +268,7 @@ namespace std
{
template<typename _Tp>
bool operator()(const _Tp& __x, const _Tp& __y) const
- { return __x == __y; }
+ { return __x != __y; }
};
struct __less
@@ -457,7 +457,7 @@ namespace std
_UnBase(const _Arg& __e) : _M_expr(__e) {}
value_type operator[](size_t __i) const
- { return _M_expr[__i]; }
+ { return _Oper()(_M_expr[__i]); }
size_t size() const { return _M_expr.size(); }
diff --git a/libstdc++-v3/include/c_std/std_cmath.h b/libstdc++-v3/include/c_std/std_cmath.h
index b2f65c82d67..1264c4dba69 100644
--- a/libstdc++-v3/include/c_std/std_cmath.h
+++ b/libstdc++-v3/include/c_std/std_cmath.h
@@ -1,6 +1,6 @@
// -*- C++ -*- C forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -76,6 +76,91 @@
#undef tan
#undef tanh
+// ...and in the darkness bind them...
+namespace __gnu_cxx
+{
+ namespace __c99_binding
+ {
+#if _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_CHECK || \
+ _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
+ extern "C" float (acosf)(float);
+ extern "C" float (asinf)(float);
+ extern "C" float (atanf)(float);
+ extern "C" float (atan2f)(float, float);
+ extern "C" float (ceilf)(float);
+ extern "C" float (coshf)(float);
+ extern "C" float (expf)(float);
+ extern "C" float (floorf)(float);
+ extern "C" float (fmodf)(float, float);
+ extern "C" float (frexpf)(float, int*);
+ extern "C" float (ldexpf)(float, int);
+ extern "C" float (logf)(float);
+ extern "C" float (log10f)(float);
+ extern "C" float (modff)(float, float*);
+ extern "C" float (powf)(float, float);
+ extern "C" float (sinhf)(float);
+ extern "C" float (tanf)(float);
+ extern "C" float (tanhf)(float);
+#endif
+#if !_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
+#if _GLIBCPP_HAVE_ACOSF
+ using ::acosf;
+#endif
+#if _GLIBCPP_HAVE_ASINF
+ using ::asinf;
+#endif
+#if _GLIBCPP_HAVE_ATANF
+ using ::atanf;
+#endif
+#if _GLIBCPP_HAVE_ATAN2F
+ using ::atan2f;
+#endif
+#if _GLIBCPP_HAVE_CEILF
+ using ::ceilf;
+#endif
+#if _GLIBCPP_HAVE_COSHF
+ using ::coshf;
+#endif
+#if _GLIBCPP_HAVE_EXPF
+ using ::expf;
+#endif
+#if _GLIBCPP_HAVE_FLOORF
+ using ::floorf;
+#endif
+#if _GLIBCPP_HAVE_FMODF
+ using ::fmodf;
+#endif
+#if _GLIBCPP_HAVE_FREXPF
+ using ::frexpf;
+#endif
+#if _GLIBCPP_HAVE_LDEXPF
+ using ::ldexpf;
+#endif
+#if _GLIBCPP_HAVE_LOGF
+ using ::logf;
+#endif
+#if _GLIBCPP_HAVE_LOG10F
+ using ::log10f;
+#endif
+#if _GLIBCPP_HAVE_MODFF
+ using ::modff;
+#endif
+#if _GLIBCPP_HAVE_POWF
+ using ::powf;
+#endif
+#if _GLIBCPP_HAVE_SINHF
+ using ::sinhf;
+#endif
+#if _GLIBCPP_HAVE_TANF
+ using ::tanf;
+#endif
+#if _GLIBCPP_HAVE_TANHF
+ using ::tanhf;
+#endif
+#endif /* _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC */
+ }
+}
+
namespace std
{
// Forward declaration of a helper function. This really should be
@@ -96,7 +181,7 @@ namespace std
#if _GLIBCPP_HAVE_ACOSF
inline float
- acos(float __x) { return ::acosf(__x); }
+ acos(float __x) { return __gnu_cxx::__c99_binding::acosf(__x); }
#else
inline float
acos(float __x) { return ::acos(static_cast<double>(__x)); }
@@ -116,7 +201,7 @@ namespace std
#if _GLIBCPP_HAVE_ASINF
inline float
- asin(float __x) { return ::asinf(__x); }
+ asin(float __x) { return __gnu_cxx::__c99_binding::asinf(__x); }
#else
inline float
asin(float __x) { return ::asin(static_cast<double>(__x)); }
@@ -134,7 +219,7 @@ namespace std
#if _GLIBCPP_HAVE_ATANF
inline float
- atan(float __x) { return ::atanf(__x); }
+ atan(float __x) { return __gnu_cxx::__c99_binding::atanf(__x); }
#else
inline float
atan(float __x) { return ::atan(static_cast<double>(__x)); }
@@ -152,7 +237,7 @@ namespace std
#if _GLIBCPP_HAVE_ATAN2F
inline float
- atan2(float __y, float __x) { return ::atan2f(__y, __x); }
+ atan2(float __y, float __x) { return __gnu_cxx::__c99_binding::atan2f(__y, __x); }
#else
inline float
atan2(float __y, float __x)
@@ -172,7 +257,7 @@ namespace std
#if _GLIBCPP_HAVE_CEILF
inline float
- ceil(float __x) { return ::ceilf(__x); }
+ ceil(float __x) { return __gnu_cxx::__c99_binding::ceilf(__x); }
#else
inline float
ceil(float __x) { return ::ceil(static_cast<double>(__x)); }
@@ -200,7 +285,7 @@ namespace std
#if _GLIBCPP_HAVE_COSHF
inline float
- cosh(float __x) { return ::coshf(__x); }
+ cosh(float __x) { return __gnu_cxx::__c99_binding::coshf(__x); }
#else
inline float
cosh(float __x) { return ::cosh(static_cast<double>(__x)); }
@@ -218,7 +303,7 @@ namespace std
#if _GLIBCPP_HAVE_EXPF
inline float
- exp(float __x) { return ::expf(__x); }
+ exp(float __x) { return __gnu_cxx::__c99_binding::expf(__x); }
#else
inline float
exp(float __x) { return ::exp(static_cast<double>(__x)); }
@@ -246,7 +331,7 @@ namespace std
#if _GLIBCPP_HAVE_FLOORF
inline float
- floor(float __x) { return ::floorf(__x); }
+ floor(float __x) { return __gnu_cxx::__c99_binding::floorf(__x); }
#else
inline float
floor(float __x) { return ::floor(static_cast<double>(__x)); }
@@ -264,7 +349,7 @@ namespace std
#if _GLIBCPP_HAVE_FMODF
inline float
- fmod(float __x, float __y) { return ::fmodf(__x, __y); }
+ fmod(float __x, float __y) { return __gnu_cxx::__c99_binding::fmodf(__x, __y); }
#else
inline float
fmod(float __x, float __y)
@@ -284,7 +369,7 @@ namespace std
#if _GLIBCPP_HAVE_FREXPF
inline float
- frexp(float __x, int* __exp) { return ::frexpf(__x, __exp); }
+ frexp(float __x, int* __exp) { return __gnu_cxx::__c99_binding::frexpf(__x, __exp); }
#else
inline float
frexp(float __x, int* __exp) { return ::frexp(__x, __exp); }
@@ -303,7 +388,7 @@ namespace std
#if _GLIBCPP_HAVE_LDEXPF
inline float
- ldexp(float __x, int __exp) { return ::ldexpf(__x, __exp); }
+ ldexp(float __x, int __exp) { return __gnu_cxx::__c99_binding::ldexpf(__x, __exp); }
#else
inline float
ldexp(float __x, int __exp)
@@ -323,7 +408,7 @@ namespace std
#if _GLIBCPP_HAVE_LOGF
inline float
- log(float __x) { return ::logf(__x); }
+ log(float __x) { return __gnu_cxx::__c99_binding::logf(__x); }
#else
inline float log(float __x)
{ return ::log(static_cast<double>(__x)); }
@@ -341,7 +426,7 @@ namespace std
#if _GLIBCPP_HAVE_LOG10F
inline float
- log10(float __x) { return ::log10f(__x); }
+ log10(float __x) { return __gnu_cxx::__c99_binding::log10f(__x); }
#else
inline float
log10(float __x) { return ::log10(static_cast<double>(__x)); }
@@ -359,7 +444,7 @@ namespace std
#if _GLIBCPP_HAVE_MODFF
inline float
- modf(float __x, float* __iptr) { return ::modff(__x, __iptr); }
+ modf(float __x, float* __iptr) { return __gnu_cxx::__c99_binding::modff(__x, __iptr); }
#else
inline float
modf(float __x, float* __iptr)
@@ -398,7 +483,7 @@ namespace std
#if _GLIBCPP_HAVE_POWF
inline float
- pow(float __x, float __y) { return ::powf(__x, __y); }
+ pow(float __x, float __y) { return __gnu_cxx::__c99_binding::powf(__x, __y); }
#else
inline float
pow(float __x, float __y)
@@ -440,7 +525,7 @@ namespace std
#if _GLIBCPP_HAVE_SINHF
inline float
- sinh(float __x) { return ::sinhf(__x); }
+ sinh(float __x) { return __gnu_cxx::__c99_binding::sinhf(__x); }
#else
inline float
sinh(float __x) { return ::sinh(static_cast<double>(__x)); }
@@ -468,7 +553,7 @@ namespace std
#if _GLIBCPP_HAVE_TANF
inline float
- tan(float __x) { return ::tanf(__x); }
+ tan(float __x) { return __gnu_cxx::__c99_binding::tanf(__x); }
#else
inline float
tan(float __x) { return ::tan(static_cast<double>(__x)); }
@@ -486,7 +571,7 @@ namespace std
#if _GLIBCPP_HAVE_TANHF
inline float
- tanh(float __x) { return ::tanhf(__x); }
+ tanh(float __x) { return __gnu_cxx::__c99_binding::tanhf(__x); }
#else
inline float
tanh(float __x) { return ::tanh(static_cast<double>(__x)); }
@@ -503,6 +588,7 @@ namespace std
#if _GLIBCPP_USE_C99
+#if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC
// These are possible macros imported from C99-land. For strict
// conformance, remove possible C99-injected names from the global
// namespace, and sequester them in the __gnu_cxx extension namespace.
@@ -561,6 +647,7 @@ namespace __gnu_cxx
__capture_isunordered(_Tp __f1, _Tp __f2)
{ return isunordered(__f1, __f2); }
}
+#endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */
#endif
#undef fpclassify
@@ -577,6 +664,7 @@ namespace __gnu_cxx
#undef isunordered
#if _GLIBCPP_USE_C99
+#if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC
namespace __gnu_cxx
{
template<typename _Tp>
@@ -647,6 +735,7 @@ namespace std
using __gnu_cxx::islessgreater;
using __gnu_cxx::isunordered;
}
+#endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */
#endif
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
diff --git a/libstdc++-v3/include/c_std/std_cstdio.h b/libstdc++-v3/include/c_std/std_cstdio.h
index 6fb8c79fb3d..3b4a6856739 100644
--- a/libstdc++-v3/include/c_std/std_cstdio.h
+++ b/libstdc++-v3/include/c_std/std_cstdio.h
@@ -1,6 +1,6 @@
// -*- C++ -*- forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -152,11 +152,24 @@ namespace std
namespace __gnu_cxx
{
+#if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" int
+ (snprintf)(char * restrict, size_t, const char * restrict, ...);
+ extern "C" int
+ (vfscanf)(FILE * restrict, const char * restrict, __gnuc_va_list);
+ extern "C" int (vscanf)(const char * restrict, __gnuc_va_list);
+ extern "C" int
+ (vsnprintf)(char * restrict, size_t, const char * restrict, __gnuc_va_list);
+ extern "C" int
+ (vsscanf)(const char * restrict, const char * restrict, __gnuc_va_list);
+#endif
+#if !_GLIBCPP_USE_C99_DYNAMIC
using ::snprintf;
using ::vfscanf;
using ::vscanf;
using ::vsnprintf;
using ::vsscanf;
+#endif
}
namespace std
diff --git a/libstdc++-v3/include/c_std/std_cstdlib.h b/libstdc++-v3/include/c_std/std_cstdlib.h
index 70fc8d3452e..e1436be1d7a 100644
--- a/libstdc++-v3/include/c_std/std_cstdlib.h
+++ b/libstdc++-v3/include/c_std/std_cstdlib.h
@@ -1,6 +1,6 @@
// -*- C++ -*- forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -135,8 +135,15 @@ namespace std
namespace __gnu_cxx
{
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::lldiv_t;
+#endif
+#if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" void (_Exit)(int);
+#endif
+#if !_GLIBCPP_USE_C99_DYNAMIC
using ::_Exit;
+#endif
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
@@ -144,6 +151,7 @@ namespace __gnu_cxx
inline long long
llabs(long long __x) { return __x >= 0 ? __x : -__x; }
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
inline lldiv_t
div(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
@@ -151,22 +159,36 @@ namespace __gnu_cxx
inline lldiv_t
lldiv(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
+#endif
+#if _GLIBCPP_USE_C99_LONG_LONG_CHECK || _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
+ extern "C" long long int (atoll)(const char *);
+ extern "C" long long int
+ (strtoll)(const char * restrict, char ** restrict, int);
+ extern "C" unsigned long long int
+ (strtoull)(const char * restrict, char ** restrict, int);
+#endif
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::atoll;
- using ::strtof;
using ::strtoll;
using ::strtoull;
+#endif
+ using ::strtof;
using ::strtold;
}
namespace std
{
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using __gnu_cxx::lldiv_t;
+#endif
using __gnu_cxx::_Exit;
using __gnu_cxx::abs;
using __gnu_cxx::llabs;
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using __gnu_cxx::div;
using __gnu_cxx::lldiv;
+#endif
using __gnu_cxx::atoll;
using __gnu_cxx::strtof;
using __gnu_cxx::strtoll;
diff --git a/libstdc++-v3/include/c_std/std_cwchar.h b/libstdc++-v3/include/c_std/std_cwchar.h
index f67f00610f5..8b33c52282f 100644
--- a/libstdc++-v3/include/c_std/std_cwchar.h
+++ b/libstdc++-v3/include/c_std/std_cwchar.h
@@ -1,6 +1,6 @@
// -*- C++ -*- forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -225,9 +225,23 @@ namespace std
namespace __gnu_cxx
{
+#if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC
+ extern "C" long double
+ (wcstold)(const wchar_t * restrict, wchar_t ** restrict);
+#endif
+#if !_GLIBCPP_USE_C99_DYNAMIC
using ::wcstold;
+#endif
+#if _GLIBCPP_USE_C99_LONG_LONG_CHECK || _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
+ extern "C" long long int
+ (wcstoll)(const wchar_t * restrict, wchar_t ** restrict, int);
+ extern "C" unsigned long long int
+ (wcstoull)(const wchar_t * restrict, wchar_t ** restrict, int);
+#endif
+#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC
using ::wcstoll;
using ::wcstoull;
+#endif
}
namespace std
diff --git a/libstdc++-v3/include/ext/stdio_filebuf.h b/libstdc++-v3/include/ext/stdio_filebuf.h
index 59ab41a03e5..4c6bf90a7c4 100644
--- a/libstdc++-v3/include/ext/stdio_filebuf.h
+++ b/libstdc++-v3/include/ext/stdio_filebuf.h
@@ -58,6 +58,7 @@ namespace __gnu_cxx
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
+ typedef std::size_t size_t;
protected:
// Stack-based buffer for unbuffered input.
@@ -75,7 +76,7 @@ namespace __gnu_cxx
* file will be closed when the stdio_filebuf is closed/destroyed.
*/
stdio_filebuf(int __fd, std::ios_base::openmode __mode, bool __del,
- int_type __size);
+ size_t __size);
/**
* @param f An open @c FILE*.
@@ -88,7 +89,7 @@ namespace __gnu_cxx
* stdio_filebuf is closed/destroyed.
*/
stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
- int_type __size = static_cast<int_type>(BUFSIZ));
+ size_t __size = static_cast<size_t>(BUFSIZ));
/**
* Possibly closes the external data stream, in the case of the file
@@ -117,7 +118,7 @@ namespace __gnu_cxx
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::
stdio_filebuf(int __fd, std::ios_base::openmode __mode, bool __del,
- int_type __size)
+ size_t __size)
{
_M_file.sys_open(__fd, __mode, __del);
if (this->is_open())
@@ -125,7 +126,7 @@ namespace __gnu_cxx
_M_mode = __mode;
if (__size > 0 && __size < 4)
{
- // Specify unbuffered.
+ // Specify not to use an allocated buffer.
_M_buf = _M_unbuf;
_M_buf_size = __size;
_M_buf_size_opt = 0;
@@ -142,7 +143,7 @@ namespace __gnu_cxx
template<typename _CharT, typename _Traits>
stdio_filebuf<_CharT, _Traits>::
stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode,
- int_type __size)
+ size_t __size)
{
_M_file.sys_open(__f, __mode);
if (this->is_open())
@@ -150,7 +151,7 @@ namespace __gnu_cxx
_M_mode = __mode;
if (__size > 0 && __size < 4)
{
- // Specify unbuffered.
+ // Specify not to use an allocated buffer.
_M_buf = _M_unbuf;
_M_buf_size = __size;
_M_buf_size_opt = 0;
diff --git a/libstdc++-v3/include/std/std_bitset.h b/libstdc++-v3/include/std/std_bitset.h
index e938662b4ee..ebe16504d18 100644
--- a/libstdc++-v3/include/std/std_bitset.h
+++ b/libstdc++-v3/include/std/std_bitset.h
@@ -219,7 +219,7 @@ namespace std
void
_Base_bitset<_Nw>::_M_do_left_shift(size_t __shift)
{
- if (__shift != 0)
+ if (__builtin_expect(__shift != 0, 1))
{
const size_t __wshift = __shift / _GLIBCPP_BITSET_BITS_PER_WORD;
const size_t __offset = __shift % _GLIBCPP_BITSET_BITS_PER_WORD;
@@ -244,7 +244,7 @@ namespace std
void
_Base_bitset<_Nw>::_M_do_right_shift(size_t __shift)
{
- if (__shift != 0)
+ if (__builtin_expect(__shift != 0, 1))
{
const size_t __wshift = __shift / _GLIBCPP_BITSET_BITS_PER_WORD;
const size_t __offset = __shift % _GLIBCPP_BITSET_BITS_PER_WORD;
@@ -570,6 +570,7 @@ namespace std
struct _Sanitize<0>
{ static void _S_do_sanitize(unsigned long) { } };
+
/**
* @brief The %bitset class represents a @e fixed-size sequence of bits.
*
@@ -578,17 +579,19 @@ namespace std
* (Note that %bitset does @e not meet the formal requirements of a
* <a href="tables.html#65">container</a>. Mainly, it lacks iterators.)
*
- * The template argument, @a _Nb, may be any non-negative number of type
- * size_t.
+ * The template argument, @a Nb, may be any non-negative number,
+ * specifying the number of bits (e.g., "0", "12", "1024*1024").
*
- * A %bitset of size N has N % (sizeof(unsigned long) * CHAR_BIT) unused
- * bits. (They are the high-order bits in the highest word.) It is
- * a class invariant that those unused bits are always zero.
+ * In the general unoptimized case, storage is allocated in word-sized
+ * blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B
+ * words will be used for storage. B - Nb%B bits are unused. (They are
+ * the high-order bits in the highest word.) It is a class invariant
+ * that those unused bits are always zero.
*
* If you think of %bitset as "a simple array of bits," be aware that
* your mental picture is reversed: a %bitset behaves the same way as
* bits in integers do, with the bit at index 0 in the "least significant
- * / right-hand" position, and the bit at index N-1 in the "most
+ * / right-hand" position, and the bit at index Nb-1 in the "most
* significant / left-hand" position. Thus, unlike other containers, a
* %bitset's index "counts from right to left," to put it very loosely.
*
@@ -619,6 +622,7 @@ namespace std
* @endcode
*
* Also see http://gcc.gnu.org/onlinedocs/libstdc++/ext/sgiexts.html#ch23
+ * for a description of extensions.
*
* @if maint
* Most of the actual code isn't contained in %bitset<> itself, but in the
@@ -805,16 +809,26 @@ namespace std
bitset<_Nb>&
operator<<=(size_t __pos)
{
- this->_M_do_left_shift(__pos);
- this->_M_do_sanitize();
+ if (__builtin_expect(__pos < _Nb, 1))
+ {
+ this->_M_do_left_shift(__pos);
+ this->_M_do_sanitize();
+ }
+ else
+ this->_M_do_reset();
return *this;
}
bitset<_Nb>&
operator>>=(size_t __pos)
{
- this->_M_do_right_shift(__pos);
- this->_M_do_sanitize();
+ if (__builtin_expect(__pos < _Nb, 1))
+ {
+ this->_M_do_right_shift(__pos);
+ this->_M_do_sanitize();
+ }
+ else
+ this->_M_do_reset();
return *this;
}
//@}
@@ -1183,6 +1197,7 @@ namespace std
typename basic_istream<_CharT, _Traits>::sentry __sentry(__is);
if (__sentry)
{
+ ios_base::iostate __state = ios_base::goodbit;
basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
for (size_t __i = 0; __i < _Nb; ++__i)
{
@@ -1191,7 +1206,7 @@ namespace std
typename _Traits::int_type __c1 = __buf->sbumpc();
if (_Traits::eq_int_type(__c1, __eof))
{
- __is.setstate(ios_base::eofbit);
+ __state |= ios_base::eofbit;
break;
}
else
@@ -1201,19 +1216,21 @@ namespace std
if (__c == '0' || __c == '1')
__tmp.push_back(__c);
- else if (_Traits::eq_int_type(__buf->sputbackc(__c2),
- __eof))
+ else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof))
{
- __is.setstate(ios_base::failbit);
+ __state |= ios_base::failbit;
break;
}
}
}
if (__tmp.empty() && !_Nb)
- __is.setstate(ios_base::failbit);
+ __state |= ios_base::failbit;
else
__x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb);
+
+ if (__state != ios_base::goodbit)
+ __is.setstate(__state); // may throw an exception
}
return __is;
diff --git a/libstdc++-v3/include/std/std_complex.h b/libstdc++-v3/include/std/std_complex.h
index f297296386b..252070b1389 100644
--- a/libstdc++-v3/include/std/std_complex.h
+++ b/libstdc++-v3/include/std/std_complex.h
@@ -456,7 +456,7 @@ namespace std
inline _Tp
norm(const complex<_Tp>& __z)
{
- return _Norm_helper<__is_floating<_Tp>::_M_type>::_S_do_it(__z);
+ return _Norm_helper<__is_floating<_Tp>::_M_type && !_GLIBCPP_FAST_MATH>::_S_do_it(__z);
}
template<typename _Tp>
@@ -565,24 +565,30 @@ namespace std
}
template<typename _Tp>
- inline complex<_Tp>
+ complex<_Tp>
pow(const complex<_Tp>& __x, const _Tp& __y)
{
- return exp(__y * log(__x));
+ if (__x.imag() == _Tp())
+ return pow(__x.real(), __y);
+
+ complex<_Tp> __t = log(__x);
+ return polar(exp(__y * __t.real()), __y * __t.imag());
}
template<typename _Tp>
inline complex<_Tp>
pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
{
- return exp(__y * log(__x));
+ return __x == _Tp() ? _Tp() : exp(__y * log(__x));
}
template<typename _Tp>
inline complex<_Tp>
pow(const _Tp& __x, const complex<_Tp>& __y)
{
- return exp(__y * log(__x));
+ return __x == _Tp()
+ ? _Tp()
+ : polar(pow(__x, __y.real()), __y.imag() * log(__x));
}
// 26.2.3 complex specializations
diff --git a/libstdc++-v3/include/std/std_fstream.h b/libstdc++-v3/include/std/std_fstream.h
index 685a38dd944..bcbbb971946 100644
--- a/libstdc++-v3/include/std/std_fstream.h
+++ b/libstdc++-v3/include/std/std_fstream.h
@@ -1,6 +1,6 @@
// File based streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -81,7 +81,6 @@ namespace std
typedef __basic_file<char> __file_type;
typedef typename traits_type::state_type __state_type;
typedef codecvt<char_type, char, __state_type> __codecvt_type;
- typedef typename __codecvt_type::result __res_type;
typedef ctype<char_type> __ctype_type;
//@}
@@ -159,7 +158,7 @@ namespace std
* @brief Returns true if the external file is open.
*/
bool
- is_open() const { return _M_file.is_open(); }
+ is_open() const throw() { return _M_file.is_open(); }
/**
* @brief Opens an external file.
@@ -189,7 +188,7 @@ namespace std
* If any operations fail, this function also fails.
*/
__filebuf_type*
- close();
+ close() throw();
protected:
/**
@@ -206,7 +205,7 @@ namespace std
* @endif
*/
void
- _M_destroy_internal_buffer();
+ _M_destroy_internal_buffer() throw();
// [27.8.1.4] overridden virtual functions
// [documentation is inherited]
@@ -234,11 +233,11 @@ namespace std
// [documentation is inherited]
virtual int_type
- underflow() { return _M_underflow_common(false); }
+ underflow();
// [documentation is inherited]
virtual int_type
- uflow() { return _M_underflow_common(true); }
+ uflow();
// [documentation is inherited]
virtual int_type
@@ -311,6 +310,7 @@ namespace std
virtual int
sync()
{
+ int __ret = 0;
bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
// Make sure that the internal buffer resyncs its idea of
@@ -319,14 +319,19 @@ namespace std
{
// Need to restore current position after the write.
off_type __off = _M_out_cur - _M_out_end;
- _M_really_overflow(); // _M_file.sync() will be called within
- if (__off)
+
+ // _M_file.sync() will be called within
+ if (traits_type::eq_int_type(_M_really_overflow(),
+ traits_type::eof()))
+ __ret = -1;
+ else if (__off)
_M_file.seekoff(__off, ios_base::cur);
}
else
_M_file.sync();
+
_M_last_overflowed = false;
- return 0;
+ return __ret;
}
// [documentation is inherited]
@@ -431,7 +436,7 @@ namespace std
}
};
- // Explicit specializations, defined in src/fstream.cc.
+ // Explicit specialization declarations, defined in src/fstream.cc.
template<>
basic_filebuf<char>::int_type
basic_filebuf<char>::_M_underflow_common(bool __bump);
@@ -442,6 +447,18 @@ namespace std
basic_filebuf<wchar_t>::_M_underflow_common(bool __bump);
#endif
+ // Generic definitions.
+ template <typename _CharT, typename _Traits>
+ typename basic_filebuf<_CharT, _Traits>::int_type
+ basic_filebuf<_CharT, _Traits>::underflow()
+ { return _M_underflow_common(false); }
+
+ template <typename _CharT, typename _Traits>
+ typename basic_filebuf<_CharT, _Traits>::int_type
+ basic_filebuf<_CharT, _Traits>::uflow()
+ { return _M_underflow_common(true); }
+
+
// [27.8.1.5] Template class basic_ifstream
/**
* @brief Controlling input for files.
diff --git a/libstdc++-v3/include/std/std_iomanip.h b/libstdc++-v3/include/std/std_iomanip.h
index 26756a8041c..490d5ac1cfb 100644
--- a/libstdc++-v3/include/std/std_iomanip.h
+++ b/libstdc++-v3/include/std/std_iomanip.h
@@ -1,6 +1,7 @@
// Standard stream manipulators -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003
+// 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
@@ -265,6 +266,7 @@ namespace std
// Inhibit implicit instantiations for required instantiations,
// which are defined via explicit instantiations elsewhere.
// NB: This syntax is a GNU extension.
+#if _GLIBCPP_EXTERN_TEMPLATE
extern template ostream& operator<<(ostream&, _Setfill<char>);
extern template ostream& operator<<(ostream&, _Setiosflags);
extern template ostream& operator<<(ostream&, _Resetiosflags);
@@ -292,6 +294,7 @@ namespace std
extern template wistream& operator>>(wistream&, _Setprecision);
extern template wistream& operator>>(wistream&, _Setw);
#endif
+#endif
} // namespace std
#endif
diff --git a/libstdc++-v3/include/std/std_iosfwd.h b/libstdc++-v3/include/std/std_iosfwd.h
index 124c8ffc5ff..55b0e0b19fa 100644
--- a/libstdc++-v3/include/std/std_iosfwd.h
+++ b/libstdc++-v3/include/std/std_iosfwd.h
@@ -1,6 +1,7 @@
// Forwarding declarations -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003
+// 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
@@ -42,7 +43,9 @@
#pragma GCC system_header
#include <bits/c++config.h>
-#include <bits/stringfwd.h> // For string forward declarations.
+#include <bits/c++locale.h>
+#include <cctype> // For isspace, etc.
+#include <bits/stringfwd.h> // For string forward declarations.
#include <bits/fpos.h>
#include <bits/functexcept.h>
diff --git a/libstdc++-v3/include/std/std_istream.h b/libstdc++-v3/include/std/std_istream.h
index 7e050322328..da9c7db1883 100644
--- a/libstdc++-v3/include/std/std_istream.h
+++ b/libstdc++-v3/include/std/std_istream.h
@@ -73,6 +73,14 @@ namespace std
typedef num_get<_CharT, __istreambuf_iter> __numget_type;
typedef ctype<_CharT> __ctype_type;
+ template<typename _CharT2, typename _Traits2>
+ friend basic_istream<_CharT2, _Traits2>&
+ operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2&);
+
+ template<typename _CharT2, typename _Traits2>
+ friend basic_istream<_CharT2, _Traits2>&
+ operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
+
protected:
// Data Members:
/**
@@ -470,10 +478,6 @@ namespace std
*
* @note Since no characters are extracted, the next call to
* @c gcount() will return 0, as required by DR 60.
- *
- * @if maint
- * FIXME We don't comply with DR 60 here, _M_gcount is untouched.
- * @endif
*/
__istream_type&
putback(char_type __c);
@@ -507,9 +511,6 @@ namespace std
* @note This function does not count the number of characters
* extracted, if any, and therefore does not affect the next
* call to @c gcount().
- * @if maint
- * FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
- * @endif
*/
int
sync();
@@ -539,9 +540,6 @@ namespace std
* @note This function does not count the number of characters
* extracted, if any, and therefore does not affect the next
* call to @c gcount().
- * @if maint
- * FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
- * @endif
*/
__istream_type&
seekg(pos_type);
@@ -558,9 +556,6 @@ namespace std
* @note This function does not count the number of characters
* extracted, if any, and therefore does not affect the next
* call to @c gcount().
- * @if maint
- * FIXME We don't comply with DR 60 here, _M_gcount is zeroed.
- * @endif
*/
__istream_type&
seekg(off_type, ios_base::seekdir);
diff --git a/libstdc++-v3/include/std/std_limits.h b/libstdc++-v3/include/std/std_limits.h
index be4b5f2a90b..9be69477958 100644
--- a/libstdc++-v3/include/std/std_limits.h
+++ b/libstdc++-v3/include/std/std_limits.h
@@ -508,7 +508,7 @@ namespace std
static short denorm_min() throw()
{ return short(); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
@@ -558,7 +558,7 @@ namespace std
static unsigned short denorm_min() throw()
{ return static_cast<unsigned short>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
@@ -608,7 +608,7 @@ namespace std
static int denorm_min() throw()
{ return static_cast<int>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
@@ -658,7 +658,7 @@ namespace std
static unsigned int denorm_min() throw()
{ return static_cast<unsigned int>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
@@ -708,7 +708,7 @@ namespace std
static long denorm_min() throw()
{ return static_cast<long>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
@@ -758,7 +758,7 @@ namespace std
static unsigned long denorm_min() throw()
{ return static_cast<unsigned long>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
@@ -808,7 +808,7 @@ namespace std
static long long denorm_min() throw()
{ return static_cast<long long>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
@@ -858,7 +858,7 @@ namespace std
static unsigned long long denorm_min() throw()
{ return static_cast<unsigned long long>(0); }
- static const bool is_iec559 = true;
+ static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
diff --git a/libstdc++-v3/include/std/std_locale.h b/libstdc++-v3/include/std/std_locale.h
index 9c46b96bc2f..29602560766 100644
--- a/libstdc++-v3/include/std/std_locale.h
+++ b/libstdc++-v3/include/std/std_locale.h
@@ -1,6 +1,6 @@
// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2002, 2003 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
@@ -42,11 +42,8 @@
#pragma GCC system_header
#include <bits/localefwd.h>
+#include <bits/locale_classes.h>
#include <bits/locale_facets.h>
#include <bits/locale_facets.tcc>
#endif
-
-// Local Variables:
-// mode:c++
-// End:
diff --git a/libstdc++-v3/include/std/std_ostream.h b/libstdc++-v3/include/std/std_ostream.h
index 7a553296102..82f8a2864bc 100644
--- a/libstdc++-v3/include/std/std_ostream.h
+++ b/libstdc++-v3/include/std/std_ostream.h
@@ -73,6 +73,26 @@ namespace std
typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
typedef ctype<_CharT> __ctype_type;
+ template<typename _CharT2, typename _Traits2>
+ friend basic_ostream<_CharT2, _Traits2>&
+ operator<<(basic_ostream<_CharT2, _Traits2>&, _CharT2);
+
+ template<typename _Traits2>
+ friend basic_ostream<char, _Traits2>&
+ operator<<(basic_ostream<char, _Traits2>&, char);
+
+ template<typename _CharT2, typename _Traits2>
+ friend basic_ostream<_CharT2, _Traits2>&
+ operator<<(basic_ostream<_CharT2, _Traits2>&, const _CharT2*);
+
+ template<typename _Traits2>
+ friend basic_ostream<char, _Traits2>&
+ operator<<(basic_ostream<char, _Traits2>&, const char*);
+
+ template<typename _CharT2, typename _Traits2>
+ friend basic_ostream<_CharT2, _Traits2>&
+ operator<<(basic_ostream<_CharT2, _Traits2>&, const char*);
+
// [27.6.2.2] constructor/destructor
/**
* @brief Base constructor.
diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h
index aaec83f082b..0940e60f52e 100644
--- a/libstdc++-v3/include/std/std_sstream.h
+++ b/libstdc++-v3/include/std/std_sstream.h
@@ -1,6 +1,6 @@
// String based streams -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2002, 2003 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
@@ -140,7 +140,7 @@ namespace std
// _M_string, and may not be the correct size of the
// current stringbuf internal buffer.
__size_type __len = _M_string.size();
- if (_M_out_cur > _M_out_beg)
+ if (_M_out_end > _M_out_beg)
__len = max(__size_type(_M_out_end - _M_out_beg), __len);
return __string_type(_M_out_beg, _M_out_beg + __len);
}
diff --git a/libstdc++-v3/include/std/std_streambuf.h b/libstdc++-v3/include/std/std_streambuf.h
index 883401bf6ee..a1958c1a8e7 100644
--- a/libstdc++-v3/include/std/std_streambuf.h
+++ b/libstdc++-v3/include/std/std_streambuf.h
@@ -1,6 +1,6 @@
// Stream buffer classes -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -278,7 +278,7 @@ namespace std
// Assumptions:
// The pback buffer has only moved forward.
void
- _M_pback_destroy()
+ _M_pback_destroy() throw()
{
if (_M_pback_init)
{
@@ -364,7 +364,6 @@ namespace std
_M_buf_size = 0;
_M_buf_size_opt = 0;
_M_mode = ios_base::openmode(0);
- _M_buf_locale_init = false;
}
// [27.5.2.2.1] locales
@@ -393,12 +392,7 @@ namespace std
*/
locale
getloc() const
- {
- if (_M_buf_locale_init)
- return _M_buf_locale;
- else
- return locale();
- }
+ { return _M_buf_locale; }
// [27.5.2.2.2] buffer management and positioning
//@{
@@ -584,7 +578,7 @@ namespace std
_M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
_M_out_beg(0), _M_out_cur(0), _M_out_end(0),
_M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
- _M_buf_locale_init(false), _M_pback_cur_save(0), _M_pback_end_save(0),
+ _M_pback_cur_save(0), _M_pback_end_save(0),
_M_pback_init(false)
{ }
@@ -700,7 +694,6 @@ namespace std
virtual void
imbue(const locale& __loc)
{
- _M_buf_locale_init = true;
if (_M_buf_locale != __loc)
_M_buf_locale = __loc;
}