Merge "Replace stlport source with prebuilts."
diff --git a/Android.mk b/Android.mk
index e32a3c6..e33c1bd 100755
--- a/Android.mk
+++ b/Android.mk
@@ -14,76 +14,20 @@
tilapia \
ifneq (,$(filter $(TARGET_DEVICE),$(STLPORT_WHITELIST)))
+
LOCAL_PATH := $(call my-dir)
-libstlport_src_files := \
- src/dll_main.cpp \
- src/fstream.cpp \
- src/strstream.cpp \
- src/sstream.cpp \
- src/ios.cpp \
- src/stdio_streambuf.cpp \
- src/istream.cpp \
- src/ostream.cpp \
- src/iostream.cpp \
- src/codecvt.cpp \
- src/collate.cpp \
- src/ctype.cpp \
- src/monetary.cpp \
- src/num_get.cpp \
- src/num_put.cpp \
- src/num_get_float.cpp \
- src/num_put_float.cpp \
- src/numpunct.cpp \
- src/time_facets.cpp \
- src/messages.cpp \
- src/locale.cpp \
- src/locale_impl.cpp \
- src/locale_catalog.cpp \
- src/facets_byname.cpp \
- src/complex.cpp \
- src/complex_io.cpp \
- src/complex_trig.cpp \
- src/string.cpp \
- src/bitset.cpp \
- src/allocators.cpp \
- src/c_locale.c \
- src/cxa.c \
-
-libstlport_c_includes := \
- external/stlport/stlport \
- bionic \
- bionic/libstdc++/include \
-
-libstlport_cflags := -D_GNU_SOURCE
-libstlport_cppflags := -fuse-cxa-atexit
-
-##########################################
include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(libstlport_src_files)
-
LOCAL_MODULE := libstlport
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_SUFFIX := .so
+LOCAL_SRC_FILES := $(TARGET_DEVICE)/$(LOCAL_MODULE).so
-LOCAL_CFLAGS := $(libstlport_cflags)
-LOCAL_CPPFLAGS := $(libstlport_cppflags)
-LOCAL_C_INCLUDES := $(libstlport_c_includes)
-LOCAL_CXX_STL := none
-LOCAL_SHARED_LIBRARIES := libstdc++
-include $(BUILD_SHARED_LIBRARY)
+ifeq ($(TARGET_IS_64_BIT),true)
+LOCAL_MULTILIB := both
+LOCAL_SRC_FILES_32 := $(TARGET_DEVICE)/32/$(LOCAL_MODULE).so
+endif
-##########################################
-include $(CLEAR_VARS)
+include $(BUILD_PREBUILT)
-LOCAL_SRC_FILES := $(libstlport_src_files)
-
-LOCAL_MODULE := libstlport_static
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_CFLAGS := $(libstlport_cflags)
-LOCAL_CPPFLAGS := $(libstlport_cppflags)
-LOCAL_C_INCLUDES := $(libstlport_c_includes)
-LOCAL_CXX_STL := none
-include $(BUILD_STATIC_LIBRARY)
endif
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 8617ef9..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,166 +0,0 @@
-**********************************************************************
-* INSTALL file for STLport *
-* *
-**********************************************************************
-
-STLport is a full ANSI C++ Standard library.
-
-This distribution contains STLport sources only, no binaries.
-To use STLport iostreams, locale and complex numbers, you have to build STLport
-library from sources in "build/lib" directory and link your programs with it.
-
-Starting with 5.0 the 'wrapper' mode is not supported anymore. You cannot use native
-compiler iostreams implementation with STLport STL (see doc/FAQ for explanations).
-Now you have to choose between STLport iostreams or no iostreams.
-
-==== Unpacking and installing STLport ==========
-
-1) Unpack STLport archive to a directory accessible during compilation.
- NOTE: DO NOT overwrite header files coming with the compiler, even if you made
- a backup - this won't work! Most probably, you've already unpacked the archive before
- reading this file though ;)
-
-2) Make sure "stlport" directory of this distribution comes before compiler's one
- in your include paths when you compile the project.
-
- Note: for SunPro CC 5.0 and higher, there used to be special directory "stlport/SC5"
- this is now obsolete, please make sure you do not use it anymore.
-
-3) Make sure you do not rename this "stlport" subdirectory -
- that may result in compilation errors.
-
- NOTE: Your compiler should be recognized by STLport source code with no configuring.
- Please edit appropriate configuration header for your compiler
- directly if you have to make compiler-specific configuration changes
- (see stlport/stl/config).
-
-4) Run:
-
- configure --help
-
- Depending on your environment, Windows command shell or Unix like shell,
- configure.bat or configure script will be run respectively. For Windows users
- running configure script is mandatory in order to declare the compiler you are
- going to use.
-
-5) Go to "build/lib" subdirectory. It contains various makefiles for different
- compilers and 'make' utilities (GNU Make and Microsoft's nmake supported).
-
- Verify you can do command line compiles. IDE users may have to do something
- special, like add environment variables (for Microsoft) or install
- additional compiler components (for Metrowerks), before they can use their
- command line compilers (see doc/README.xxxx for additionnal information).
-
- configure script should have already created a Makefile file so that you only
- have to call 'make' or 'nmake' (for some platforms GNU make might be hidden
- behind 'gmake').
-
- IMPORTANT:
-
- If you DO NOT plan to use STLport iostreams and/or locale implementation but just
- the STL, you do not have to build the library.
-
- If you have decided to disable STLport iostreams and locale using _STLP_NO_IOSTREAMS
- configuration macro in stlport/stl/config/user_config.h, you may stop reading here.
-
-
-==== Building STLport iostreams library ==========
-
-Below are step-by-step instructions to build STLport streams library. This is a general
-build process description, for a more detailed one check README files in the doc folder:
-
-5) Using appropriate make command (make or nmake), do
-
- make clean install
-
- to build the STLport libraries. Make files are set up to build several different
- flavors - debug/nondebug, static/dynamic versions. But not all flavors will be build
- by default. See build/lib/README for other make targets.
-
- Note: 'install' target work slightly different than usual - it installs libraries into
- <STLport root dir>/lib and bin catalogs, NOT IN SYSTEM CATALOG. You can do the system
- install by just copying stlport and lib folder to the destination of your choise. For
- example on UNIX-like platforms this can be done with the following commands:
-
- su
- tar cf - stlport | (cd /usr/local/include; tar xf -)
- chmod -R a+r /usr/local/include/stlport
- chown -R root:root /usr/local/include/stlport
- (cd lib; tar cf - --exclude=CVS --exclude=.cvsignore .) | (cd /usr/local/lib; tar xf -)
- chown -R root:root /usr/local/lib/libstlport*
- exit
-
- Note: System install is optional, most of compilers/linkers support searching for includes
- and libs throught out the whole filesystem, just check your documentation on how to achieve
- this.
-
- If you use cross-compiler, you can find libraries in the <STLport root dir>/lib/<target platform>
- catalog.
-
-6) If build fails, you may choose to :
- - try fixing the build ;)
- - wait until somebody else will submit corresponding changes to be incorporated in next STLport
- release/snapshot.
-
- In case you do patch STLport, please submit your patches to
- https://sourceforge.net/tracker/?atid=766246&group_id=146814&func=browse
-
-==== Linking your application with STLport library ==========
-
-7) Check the build:
-
- Example:
-
- - under Linux and other Unixes:
-
- cd build/test/unit
- make install
- ../../../bin/stl_unit_test
- ../../../bin-g/stl_unit_test
-
- - under Windows:
-
- cd build\test\unit
- nmake install
- cd ..\..\..\bin
- stl_unit_test
- stl_unit_testd
- stl_unit_teststld
-
-8) Supply the "lib" subdirectory to the library search path and add desired
- library to the list of libraries to link with.
- Examples (imagine you have mytest.cpp in the same directory as this file is):
- With GCC : g++ -pthread -I./stlport mytest.cpp -L./lib/ -lstlport
- With DEC CC : cxx -I./stlport mytest.cpp -L./lib/ -lstlport
- With SUN CC : CC -mt -I./stlport mytest.cpp -L./lib/ -lstlport
- .....
- For several compilers supporting auto linking feature (VC++, Borland, DMC),
- you do not have to specify "stlport.M.m.lib" explicitly, as it is being choosen
- and forced to link automatically by "#pragma"'s in compiler config files
- Appropriate version is being selected based on compiler options and _STLP_DEBUG
- setting. All you have to do is to set library search path for the linker.
-
- Example :
- cl.exe /I.\stlport mytest.cpp /link /libpath:.\lib /MD
-
-9) If you linked your application with shared STLport library (.so or .dll), please
- make suze that your .so or .dll can be found by the dynamic linker.
- Under Windows, the paths searched depend on the particular flavor, see the MSDN
- documentation for LoadLibrary at http://msdn.microsoft.com. The easiest ways are to
- either modify the PATH environment variable or copy all .dll's next to the
- executable like it is done per default when unit tests executable are put next
- to dlls.
- Under Linux, the environment variable LD_LIBRARY_PATH can be adjusted to point
- to the dir containing .so. See the manpage for ld.so for more info.
-
-10) STLport builds only multithreaded libraries, so your application should be compiled
- as multithreaded, too. Use -pthread (or -pthreads on Solaris) option for GCC, -mt for SunPro,
- /MT for VC, and so on. Sometimes you should define _REENTRANT or something else, depends
- upon platform/compiler. See compiler's and linker's options on command line when you build
- unit tests (build/test/unit) for reference. The last is useful for ANY platform.
-
-11) Don't hesitate to read READMEs (doc/README*, build/lib/README*, build/test/unit/README*)
- and doc/FAQ.
-
-12) Have fun!
-
diff --git a/INSTALL.unixes b/INSTALL.unixes
deleted file mode 100644
index f9b2e21..0000000
--- a/INSTALL.unixes
+++ /dev/null
@@ -1,120 +0,0 @@
-**********************************************************************
-* INSTALL file for STLport 5.2 *
-* *
-**********************************************************************
-
-STLport is a full ANSI C++ Standard library.
-
-This distribution contains STLport sources only, no binaries.
-To use STLport iostreams, locale and complex numbers, you have
-to build STLport library from sources and link your programs with it.
-
-Starting with 5.0 the 'wrapper' mode is not supported anymore.
-You cannot use native compiler iostreams implementation with STLport STL
-(see doc/FAQ for explanations).
-
-==== Installing STLport ==========
-
-0) DO NOT overwrite/move/rename header files coming with the compiler,
- even if you made a backup---STLport need this headers and don't
- override ones.
-
-1) Run
-
- ./configure --help
-
- read options description; if you use compiler
- different from gcc, pay attention to --use-compiler-family= option.
-
-2) Run
-
- ./configure <option>
-
- Options here more-or-less traditional.
-
- Note: ./configure give hints only for library build, it dosen't
- create/edit any headers, check you system etc. This is simple way
- to store custom options, not more. If you want to change default
- behaviour of STLport, see stlport/stl/config/user_config.h and
- stlport/stl/config/host.h; read the comments in this files!
- Not all combinations of options healthy, you should understand
- what you do. If not, keep all unchanged.
-
- Note: you can find all recognised 'settings' in the file
- build/Makefiles/gmake/config.mak
-
- This is generated file, but only ./configure will rewrite one.
-
-3) Run
-
- make && make check
-
- Only GNU Make supported! Preferred verion of GNU Make >= 3.81;
- never use GNU Make before 3.79 --- build not work properly;
- GNU makes >= 3.79 and < 3.81 may fail to build library/tests
- properly, due to bugs; but the real results depends upon
- platform.
-
-4) If build fine, become superuser and run
-
- make install
-
- Note: you can use --prefix= to change installation path
- (or macro DESTDIR, as usual), or even skip installation and use
- STLport in-place.
-
-==== Usage STLport ==========
-
-1) The best way to understand how to use it, is to see on compilation,
- linking, running unit tests, i.e. see on options when you do
-
- (cd build/test/unit; make check)
-
-2) Make sure "stlport" directory of this distribution comes before
- compiler's one in your include paths (something like
- -I<base install path>/stlport); never rename 'stlport' part of path!
-
- Compilation:
-
- c++ -pthread -fexceptions -O2 -I/usr/local/include/stlport -c -o test.o test.cc
-
- In case of gcc, libstlport replace libstdc++ (not in all cases!)
-
- Link, variant 1:
-
- c++ -pthread -fexceptions -O2 -I/usr/local/include/stlport -nostdlib -o mytest \
- /usr/lib/gcc/i686-pc-linux-gnu/4.2.4/../../../crt1.o \
- /usr/lib/gcc/i686-pc-linux-gnu/4.2.4/../../../crti.o \
- /usr/lib/gcc/i686-pc-linux-gnu/4.2.4/crtbegin.o \
- test.o \
- -lstlport \
- -lgcc_s -lpthread -lc -lm \
- /usr/lib/gcc/i686-pc-linux-gnu/4.2.4/crtend.o \
- /usr/lib/gcc/i686-pc-linux-gnu/4.2.4/../../../crtn.o
-
- Of cause, names of start/stop files not hardcoded, you can locate it with
-
- c++ -print-file-name=crt1.o
-
- Link, variant 2:
-
- gcc -pthread -fexceptions -O2 -I/usr/local/include/stlport -o mytest \
- test.o -lstlport
-
- If you use gcc before 3.3, you must link with libstdc++, because
- language-support library (libsupc++.a) don't contain necessary
- functions.
-
-3) STLport builds only multithreaded libraries (by default), so your
- application should be compiled as multithreaded, too. Use -pthread
- (or -pthreads on Solaris) option for GCC, -mt for SunPro and so on.
- Sometimes you should define _REENTRANT or something else, depends
- upon platform/compiler. See compiler's and linker's options
- on command line when you build unit tests (build/test/unit)
- for reference. The last is useful for ANY platform (special
- attention for Windows users).
-
-4) Don't hesitate to read READMEs (doc/README*, build/lib/README*,
- build/test/unit/README*) and doc/FAQ.
-
-5) Have fun!
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 61cefb6..0000000
--- a/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# Time-stamp: <08/06/12 14:28:42 ptr>
-#
-# Copyright (c) 2004-2008
-# Petr Ovtchenkov
-#
-# Licensed under the Academic Free License version 3.0
-#
-
-SRCROOT := build
-SUBDIRS := build/lib
-
-include ${SRCROOT}/Makefiles/gmake/subdirs.mak
-
-all install depend clean clobber distclean check::
- +$(call doinsubdirs,${SUBDIRS})
-
-distclean clean depend clobber::
- +$(call doinsubdirs,build/test/unit)
-
-release-shared install-release-shared:
- +$(call doinsubdirs,${SUBDIRS})
-
-install::
- ${MAKE} -C build/lib install-headers
-
-.PHONY: all install depend clean clobber distclean check release-shared install-release-shared
diff --git a/configure b/configure
deleted file mode 100755
index 2f48511..0000000
--- a/configure
+++ /dev/null
@@ -1,333 +0,0 @@
-#!/bin/sh
-
-# Time-stamp: <08/06/07 15:22:19 yeti>
-
-base=`cd \`dirname $0\`; echo $PWD`
-
-configmak=$base/build/Makefiles/gmake/config.mak
-
-write_option() {
- target=`echo $1 | sed -e 's/^[^=]*=//'`
- echo $2 := $3$target >> ${configmak}
-}
-
-write_over_option() {
- target=`echo $1 | sed -e 's/^[^=]*=//'`
- echo $2 ?= $target >> ${configmak}
-}
-
-print_help() {
- cat <<EOF
-Configuration utility.
-
-Usage:
-
- configure [options]
-
-Available options:
-
- --prefix=<dir> base install path (/usr/local/)
- --bindir=<dir> install path for executables (PREFIX/bin)
- --libdir=<dir> install path for libraries (PREFIX/lib)
- --includedir=<dir> install path for headers (PREFIX/include)
-
- --target=<target> target platform (cross-compiling)
-
- --help print this help message and exit
-
- --with-stlport=<dir> use STLport in catalog <dir>
- --without-stlport compile without STLport
- --with-boost=<dir> use boost headers in catalog <dir>
- --with-system-boost use boost installed on this system
- --with-msvc=<dir> use MS VC from this catalog
- --with-mssdk=<dir> use MS SDK from this catalog
- --with-extra-cxxflags=<options>
- pass extra options to C++ compiler
- --with-extra-cflags=<options>
- pass extra options to C compiler
- --with-extra-ldflags=<options>
- pass extra options to linker (via C/C++)
- --use-static-gcc use static gcc libs instead of shared libgcc_s (useful for gcc compiler,
- that was builded with --enable-shared [default]; if compiler was builded
- with --disable-shared, static libraries will be used in any case)
- --clean remove custom settings (file ${configmak})
- and use default values
- --with-cxx=<name> use <name> as C++ compiler (use --target= for cross-compilation)
- --with-cc=<name> use <name> as C compiler (use --target= for cross-compilation)
- --use-compiler-family=<name> use compiler family; one of:
- gcc GNU compilers (default)
- icc Intel compilers
- aCC HP's aCC compilers
- CC SunPro's CC compilers
- bcc Borland's compilers
- --without-debug don't build debug variant
- --without-stldebug don't build STLport's STLP_DEBUG mode
- --enable-static build static
- --disable-shared don't build shared
- --with-lib-motif=<motif>
- Use this option to customize the generated library name.
- The motif will be used in the last place before version information,
- separated by an underscore, ex:
- stlportd_MOTIF.5.0.lib
- stlportstld_static_MOTIF.5.1.lib
- --without-thread Per default STLport libraries are built in order to be usable
- in a multithreaded context. If you don't need this you can ask
- for a not thread safe version with this option.
- --without-rtti Disable RTTI when building libraries.
- --with-static-rtl
- --with-dynamic-rtl
- Enables usage of static (libc.lib family) or dynamic (msvcrt.lib family)
- C/C++ runtime library when linking with STLport. If you want your appli/dll
- to link statically with STLport but using the dynamic C runtime use
- --with-dynamic-rtl; if you want to link dynamicaly with STLport but using the
- static C runtime use --with-static-rtl. See README.options for details.
- Don't forget to signal the link method when building your appli or dll, in
- stlport/stl/config/host.h set the following macro depending on the configure
- option:
- --with-static-rtl -> _STLP_USE_DYNAMIC_LIB"
- --with-dynamic-rtl -> _STLP_USE_STATIC_LIB"
- --windows-platform=<name>
- Targetted OS when building for Windows; one of:
- win95 Windows 95
- win98 Windows 98
- winxp Windows XP and later (default)
-
-Environment variables:
-
- \$CXX C++ compiler name (use --target= for cross-compilation)
- \$CC C compiler name (use --target= for cross-compilation)
- \$CXXFLAGS pass extra options to C++ compiler
- \$CFLAGS pass extra options to C compiler
- \$LDFLAGS pass extra options to linker (via C/C++)
-
- Options has preference over environment variables.
-
-EOF
-}
-
-default_settings () {
- # if [ "$boost_set" = "" ]; then
- # write_option "${PWD}/external/boost" BOOST_DIR
- # fi
-
- # if [ -z "${stlport_set}" ]; then
- # write_over_option "$base" STLPORT_DIR
- # fi
-
- # Set in Makefiles/gmake/top.mak
- if [ -z "${compiler_family_set}" ]; then
- # write_option gcc COMPILER_NAME
- echo include gcc.mak > ${base}/build/lib/Makefile
- echo include gcc.mak > ${base}/build/test/unit/Makefile
- echo include gcc.mak > ${base}/build/test/eh/Makefile
- fi
-
- # Set in Makefiles/gmake/targetdirs.mak
- # if [ -z "${prefix_set}" ]; then
- # write_option "/usr/local" BASE_INSTALL_DIR '${DESTDIR}'
- # fi
-}
-
-[ $# -eq 0 ] && { >${configmak}; default_settings; exit 0; }
-
-for a in $@ ; do
- case $a in
- --help)
- print_help
- exit 0
- ;;
- --clean)
- rm -f ${configmak}
- exit 0
- ;;
- esac
-done
-
->${configmak}
-
-while :
-do
- case $# in
- 0)
- break
- ;;
- esac
- option="$1"
- shift
- case $option in
- --target=*)
- write_option "$option" TARGET_OS
- target_set=y
- ;;
- --with-stlport=*)
- write_option "$option" STLPORT_DIR
- stlport_set=y
- ;;
- --without-stlport)
- write_option 1 WITHOUT_STLPORT
- stlport_set=y
- ;;
- --with-boost=*)
- write_option "$option" BOOST_DIR
- ;;
- --with-system-boost)
- write_option 1 USE_SYSTEM_BOOST
- ;;
- --with-msvc=*)
- write_option "$option" MSVC_DIR
- ;;
- --with-mssdk=*)
- write_option "$option" MSSDK_DIR
- ;;
- --with-extra-cxxflags=*)
- write_option "$option" EXTRA_CXXFLAGS
- cxxflags_set=y
- ;;
- --with-extra-cflags=*)
- write_option "$option" EXTRA_CFLAGS
- cflags_set=y
- ;;
- --with-extra-ldflags=*)
- write_option "$option" EXTRA_LDFLAGS
- ldflags_set=y
- ;;
- --with-lib-motif=*)
- echo "Using $option in generated library names"
- write_option "$option" LIB_MOTIF
- ;;
- --without-thread)
- write_option 1 WITHOUT_THREAD
- ;;
- --without-rtti)
- write_option 1 WITHOUT_RTTI
- ;;
- --with-dynamic-rtl)
- write_option 1 WITH_DYNAMIC_RTL
- ;;
- --with-static-rtl)
- write_option 1 WITH_STATIC_RTL
- ;;
- --use-static-gcc)
- write_option 1 USE_STATIC_LIBGCC
- ;;
- --without-debug)
- write_option 1 _NO_DBG_BUILD
- ;;
- --without-stldebug)
- write_option 1 _NO_STLDBG_BUILD
- ;;
- --enable-static)
- write_option 1 _STATIC_BUILD
- ;;
- --disable-shared)
- write_option 1 _NO_SHARED_BUILD
- ;;
- --with-cxx=*)
- write_option "$option" _FORCE_CXX
- cxx_set=y
- ;;
- --with-cc=*)
- write_option "$option" _FORCE_CC
- cc_set=y
- ;;
- --use-compiler-family=*)
- case `echo $option | sed -e 's/^[^=]*=//'` in
- gcc|icc|aCC|CC|bcc|dmc)
- target=`echo $option | sed -e 's/^[^=]*=//'`
- echo COMPILER_NAME := $target >> ${configmak}
- echo include $target.mak > ${base}/build/lib/Makefile
- echo include $target.mak > ${base}/build/test/unit/Makefile
- echo include $target.mak > ${base}/build/test/eh/Makefile
- ;;
- *)
- echo "Not supported compilers family"
- exit -1
- ;;
- esac
- compiler_family_set=y
- ;;
- --prefix=*)
- write_option "$option" BASE_INSTALL_DIR '${DESTDIR}'
- prefix_set=y
- ;;
- --bindir=*)
- write_option "$option" INSTALL_BIN_DIR '${DESTDIR}'
- ;;
- --libdir=*)
- write_option "$option" INSTALL_LIB_DIR '${DESTDIR}'
- ;;
- --includedir=*)
- write_option "$option" INSTALL_HDR_DIR '${DESTDIR}'
- ;;
- --windows-platform=*)
- case `echo $option | sed -e 's/^[^=]*=//'` in
- win95)
- write_option 0x0400 WINVER
- ;;
- win98)
- write_option 0x0410 WINVER
- ;;
- winxp)
- write_option 0x0501 WINVER
- ;;
- *)
- echo "Not supported windows platform"
- exit -1
- ;;
- esac
- ;;
- *)
- echo "Unknown configuration option '$option'"
- exit -1
- ;;
- esac
-done
-
-if [ -n "${CXX}" ]; then
- if [ -n "${cxx_set}" ]; then
- echo "Both --with-cxx and \$CXX set, using the first"
- elif [ -z "${target_set}" ]; then
- write_option "${CXX}" _FORCE_CXX
- else
- echo "For cross-compilation with gcc use --target option only"
- fi
- if [ -z "${CC}" -a -z "${cc_set}" ]; then
- echo "\$CXX set, but I don't see \$CC!"
- fi
-fi
-
-if [ -n "${CC}" ]; then
- if [ -n "${cxx_set}" ]; then
- echo "Both --with-cc and \$CC set, using the first"
- else
- write_option "${CC}" _FORCE_CC
- fi
-fi
-
-if [ -n "${CXXFLAGS}" ]; then
- if [ -z "${cxxflags_set}" ]; then
- write_option "${CXXFLAGS}" EXTRA_CXXFLAGS
- else
- echo "Both --with-extra-cxxflags and \$CXXFLAGS set, using the first"
- fi
-fi
-
-if [ -n "${CFLAGS}" ]; then
- if [ -z "${cflags_set}" ]; then
- write_option "${CFLAGS}" EXTRA_CFLAGS
- else
- echo "Both --with-extra-cflags and \$CFLAGS set, using the first"
- fi
-fi
-
-if [ -n "${LDFLAGS}" ]; then
- if [ -z "${ldflags_set}" ]; then
- write_option "${LDFLAGS}" EXTRA_LDFLAGS
- else
- echo "Both --with-extra-ldflags and \$LDFLAGS set, using the first"
- fi
-fi
-
-# default settings
-
-default_settings
diff --git a/configure.bat b/configure.bat
deleted file mode 100644
index 4f33f3d..0000000
--- a/configure.bat
+++ /dev/null
@@ -1,632 +0,0 @@
-@ECHO OFF
-REM **************************************************************************
-REM *
-REM * configure.bat for setting up compiling STLport under Windows
-REM * to see available options, call with option --help
-REM *
-REM * Copyright (C) 2004,2005 Michael Fink
-REM *
-REM **************************************************************************
-
-REM Attention! Batch file labels only have 8 significant characters!
-
-echo STLport Configuration Tool for Windows
-echo.
-
-REM no options at all?
-if NOT "%1xyz123" == "xyz123" goto init
-
-echo Please specify at least the compiler you are going to use,
-echo use "configure --help" to see the available ones.
-goto skp_comp
-
-:init
-
-REM initially create/overwrite config.mak
-echo # STLport Configuration Tool for Windows > build\Makefiles\nmake\config.mak
-echo # >> build\Makefiles\nmake\config.mak
-echo # config.mak generated with command line: >> build\Makefiles\nmake\config.mak
-echo # configure %1 %2 %3 %4 %5 %6 %7 %8 %9 >> build\Makefiles\nmake\config.mak
-echo # >> build\Makefiles\nmake\config.mak
-
-REM First parameter can only be help or compiler
-REM help option
-if "%1" == "-?" goto opt_help
-if "%1" == "-h" goto opt_help
-if "%1" == "/?" goto opt_help
-if "%1" == "/h" goto opt_help
-if "%1" == "--help" goto opt_help
-
-REM This is necessarily a compiler
-goto opt_comp
-
-REM
-REM option loop
-REM
-:loop
-
-REM platform option
-if "%1" == "-p" goto opt_plat
-if "%1" == "/p" goto opt_plat
-if "%1" == "--platform" goto opt_plat
-
-REM cross compiling
-if "%1" == "-x" goto opt_x
-if "%1" == "/x" goto opt_x
-if "%1" == "--cross" goto opt_x
-
-REM C runtime library
-if "%1" == "--with-static-rtl" goto opt_srtl
-if "%1" == "--with-dynamic-rtl" goto opt_drtl
-if "%1" == "--rtl-static" goto opt_srtl
-if "%1" == "--rtl-dynamic" goto opt_drtl
-
-REM boost support
-if "%1" == "--use-boost" goto opt_bst
-
-REM multithreading support
-if "%1" == "--not-thread-safe" goto opt_st
-if "%1" == "--without-thread" goto opt_st
-
-REM rtti support
-if "%1" == "--no-rtti" goto opt_rtti
-if "%1" == "--without-rtti" goto opt_rtti
-
-REM additional compiler options
-if "%1" == "--extra-cxxflag" goto opt_xtra
-
-REM library name customization
-if "%1" == "--lib-motif" goto opt_motf
-if "%1" == "--with-lib-motif" goto opt_motf
-
-REM build without STLport
-if "%1" == "--without-stlport" goto no_sport
-
-REM clean rule
-if "%1" == "--clean" goto opt_cln
-
-echo Unknown option: %1
-
-:cont_lp
-echo.
-shift
-
-REM no more options?
-if "%1xyz123" == "xyz123" goto end_loop
-
-goto loop
-
-
-REM **************************************************************************
-REM *
-REM * Help
-REM *
-REM **************************************************************************
-:opt_help
-echo The first parameter must be the compiler name, here are the available
-echo keywords:
-echo.
-echo msvc6 Microsoft Visual C++ 6.0
-echo msvc7 Microsoft Visual C++ .NET 2002
-echo msvc71 Microsoft Visual C++ .NET 2003
-echo msvc8 Microsoft Visual C++ 2005
-echo msvc9 Microsoft Visual C++ 2008
-echo icl Intel C++ Compiler
-echo evc3 Microsoft eMbedded Visual C++ 3 (*)
-echo evc4 Microsoft eMbedded Visual C++ .NET (*)
-echo evc8 Microsoft Visual C++ 2005 compiling for CE
-echo evc9 Microsoft Visual C++ 2008 compiling for CE
-echo.
-echo (*) For these compilers the target processor is determined automatically.
-echo You must run the WCE*.BAT file you wish to build STLport for before
-echo running configure.
-echo.
-echo Then the following options are available:
-echo.
-echo "-p <platform>" or "--platform <platform>"
-echo Build STLport for the specified platform. Not all existing platforms are
-echo available, only the ones that make a difference when building STLport are.
-echo The following keywords are available:
-echo win95 Windows 95 compatible
-echo win98 Windows 98 and up to Windows XP excluded
-echo winxp Windows XP or later (default)
-echo.
-echo "-x"
-echo Enables cross-compiling; the result is that all built files that are
-echo normally put under "bin" and "lib" get extra subfolders depending on
-echo the compiler name.
-echo.
-echo "--with-static-rtl"
-echo "--with-dynamic-rtl"
-echo Enables usage of static (libc.lib family) or dynamic (msvcrt.lib family)
-echo C/C++ runtime library when linking with STLport. If you want your appli/dll
-echo to link statically with STLport but using the dynamic C runtime use
-echo --with-dynamic-rtl; if you want to link dynamicaly with STLport but using the
-echo static C runtime use --with-static-rtl. See README.options for details.
-echo Don't forget to signal the link method when building your appli or dll, in
-echo stlport/stl/config/host.h set the following macro depending on the configure
-echo option:
-echo "--with-static-rtl -> _STLP_USE_DYNAMIC_LIB"
-echo "--with-dynamic-rtl -> _STLP_USE_STATIC_LIB"
-echo.
-echo "--use-boost <boost install path>"
-echo Request use of boost support (www.boost.org). For the moment only the boost
-echo type_traits library is used to get type information and to implement some
-echo specific workaround not directly implemented by STLport. To use the same
-echo support when using STLport for your application don't forget to define
-echo _STLP_USE_BOOST_SUPPORT in stlport/stl/config/user_config.h file.
-echo.
-echo "--without-thread"
-echo Per default STLport libraries are built in order to be usable in a multithreaded
-echo context. If you don't need this you can ask for a not thread safe version with
-echo this option.
-echo.
-echo "--without-rtti"
-echo Remove rtti (run time type information) support if available.
-echo.
-echo "--extra-cxxflag <additional compilation options>"
-echo Use this option to add any compilation flag to the build system. For instance
-echo it can be used to activate a specific processor optimization depending on your
-echo processor. For Visual C++ .Net 2003, to activate pentium 3 optim you will use:
-echo --extra-cxxflag /G7
-echo If you have several options use several --extra-cxxflag options. For instance
-echo to also force use of wchar_t as an intrinsic type:
-echo --extra-cxxflag /G7 --extra-cxxflag /Zc:wchar_t
-echo.
-echo "--with-lib-motif <motif>"
-echo Use this option to customize the generated library name. The motif will be used
-echo in the last place before version information, separated by an underscore, ex:
-echo stlportd_MOTIF.5.0.lib
-echo stlportstld_static_MOTIF.5.1.lib
-echo Do not forget to define _STLP_LIB_NAME_MOTIF macro in STLport configuration file
-echo to the same value if you want to keep the auto link feature supported by some
-echo compilers.
-echo.
-echo "--without-stlport"
-echo Option specially targetting build of the unit tests project without STLport. This
-echo is a good way to challenge the C++ Standard library implementation comming with
-echo your compiler with STLport.
-echo.
-echo "--clean"
-echo Removes the build configuration file.
-goto skp_comp
-
-REM **************************************************************************
-REM *
-REM * Compiler configuration
-REM *
-REM **************************************************************************
-:opt_comp
-
-if "%1" == "msvc6" goto oc_msvc6
-if "%1" == "msvc71" goto oc_msv71
-if "%1" == "msvc7" goto oc_msvc7
-if "%1" == "msvc8" goto oc_msvc8
-if "%1" == "msvc9" goto oc_msvc9
-if "%1" == "icl" goto oc_icl
-
-if "%1" == "evc3" goto oc_evc3
-if "%1" == "evc4" goto oc_evc4
-if "%1" == "evc8" goto oc_evc8
-if "%1" == "evc9" goto oc_evc9
-
-if "%1" == "watcom" goto oc_wtm
-
-echo Unknown compiler: %1
-goto oc_end
-
-:oc_msvc6
-:oc_wtm
-echo Setting compiler: Microsoft Visual C++ 6.0
-echo COMPILER_NAME=vc6 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER_VERSION=60
-goto oc_msvc
-
-:oc_msvc7
-echo Setting compiler: Microsoft Visual C++ .NET 2002
-echo COMPILER_NAME=vc70 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER_VERSION=70
-goto oc_msvc
-
-:oc_msv71
-echo Setting compiler: Microsoft Visual C++ .NET 2003
-echo COMPILER_NAME=vc71 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER_VERSION=71
-goto oc_msvc
-
-:oc_msvc8
-echo Setting compiler: Microsoft Visual C++ 2005
-echo COMPILER_NAME=vc8 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER_VERSION=80
-goto oc_msvc
-
-:oc_msvc9
-echo Setting compiler: Microsoft Visual C++ 2008
-echo COMPILER_NAME=vc9 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER_VERSION=90
-goto oc_msvc
-
-:oc_msvc
-echo TARGET_OS=x86 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER=msvc
-echo !include msvc.mak > .\build\lib\Makefile
-echo !include msvc.mak > .\build\test\unit\Makefile
-echo !include msvc.mak > .\build\test\eh\Makefile
-goto oc_end
-
-:oc_icl
-echo Setting compiler: Intel C++ Compiler
-echo COMPILER_NAME=icl >> build\Makefiles\nmake\config.mak
-echo TARGET_OS=x86 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER=icl
-echo !include icl.mak > .\build\lib\Makefile
-echo !include icl.mak > .\build\test\unit\Makefile
-echo !include icl.mak > .\build\test\eh\Makefile
-goto oc_end
-
-:oc_evc3
-echo Setting compiler: Microsoft eMbedded Visual C++ 3
-echo COMPILER_NAME=evc3 >> build\Makefiles\nmake\config.mak
-rem TODO: branch on OSVERSION like below?
-echo CEVERSION=300 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER_VERSION=3
-goto oc_evc
-
-:oc_evc4
-echo Setting compiler: Microsoft eMbedded Visual C++ .NET
-echo COMPILER_NAME=evc4 >> build\Makefiles\nmake\config.mak
-if "%OSVERSION%"=="" (
- echo OSVERSION not set, assuming target is CE 4.2
- echo CEVERSION=420 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE400" (
- echo CEVERSION=400 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE420" (
- echo CEVERSION=420 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE500" (
- echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
-) else (
- echo Unknown value for OSVERSION.
- exit /b 1
-)
-set SELECTED_COMPILER_VERSION=4
-goto oc_evc
-
-:oc_evc8
-echo Setting compiler: Microsoft Visual C++ .NET 2005 for Windows CE
-echo COMPILER_NAME=evc8 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER_VERSION=80
-if "%OSVERSION%"=="" (
- echo OSVERSION not set, assuming target is CE 5.0
- echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE400" (
- echo CEVERSION=400 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE420" (
- echo CEVERSION=420 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE500" (
- echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
-) else (
- echo Unknown value for OSVERSION.
- exit /b 1
-)
-set PLATFORM_SPECIFIED=1
-set SELECTED_COMPILER=msvc
-echo !include evc.mak > .\build\lib\Makefile
-echo !include evc.mak > .\build\test\unit\Makefile
-echo !include evc.mak > .\build\test\eh\Makefile
-goto proc
-
-:oc_evc9
-echo Setting compiler: Microsoft Visual C++ .NET 2008 for Windows CE
-echo COMPILER_NAME=evc9 >> build\Makefiles\nmake\config.mak
-set SELECTED_COMPILER_VERSION=90
-if "%OSVERSION%"=="" (
- echo OSVERSION not set, assuming target is CE 5.0
- echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE400" (
- echo CEVERSION=400 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE420" (
- echo CEVERSION=420 >> build\Makefiles\nmake\config.mak
-) else if "%OSVERSION%"=="WCE500" (
- echo CEVERSION=500 >> build\Makefiles\nmake\config.mak
-) else (
- echo Unknown value for OSVERSION.
- exit /b 1
-)
-set PLATFORM_SPECIFIED=1
-set SELECTED_COMPILER=msvc
-echo !include evc.mak > .\build\lib\Makefile
-echo !include evc.mak > .\build\test\unit\Makefile
-echo !include evc.mak > .\build\test\eh\Makefile
-goto proc
-
-:oc_evc
-set PLATFORM_SPECIFIED=1
-set SELECTED_COMPILER=evc
-echo !include evc.mak > .\build\lib\Makefile
-echo !include evc.mak > .\build\test\unit\Makefile
-echo !include evc.mak > .\build\test\eh\Makefile
-goto proc
-
-:oc_end
-goto cont_lp
-
-
-REM **************************************************************************
-REM *
-REM * Target processor configuration (automatic)
-REM *
-REM **************************************************************************
-:proc
-
-if "%TARGETCPU%" == "ARM" goto pr_arm
-if "%TARGETCPU%" == "ARMV4" goto pr_arm
-if "%TARGETCPU%" == "ARMV4I" goto pr_arm
-if "%TARGETCPU%" == "ARMV4T" goto pr_arm
-
-if "%TARGETCPU%" == "X86" goto pr_x86
-REM Type from evc3 and/or PocketPC 2002 SDK reported here
-REM to correctly check the platform:
-if "%TARGETCPU%" == "X86EMnset CFG=none" goto pr_emul
-if "%TARGETCPU%" == "x86" goto pr_x86
-if "%TARGETCPU%" == "emulator" goto pr_emul
-
-if "%TARGETCPU%" == "R4100" goto pr_mips
-if "%TARGETCPU%" == "R4111" goto pr_mips
-if "%TARGETCPU%" == "R4300" goto pr_mips
-if "%TARGETCPU%" == "MIPS16" goto pr_mips
-if "%TARGETCPU%" == "MIPSII" goto pr_mips
-if "%TARGETCPU%" == "MIPSII_FP" goto pr_mips
-if "%TARGETCPU%" == "MIPSIV" goto pr_mips
-if "%TARGETCPU%" == "MIPSIV_FP" goto pr_mips
-
-if "%TARGETCPU%" == "SH3" goto pr_sh3
-if "%TARGETCPU%" == "SH4" goto pr_sh4
-
-:pr_err
-echo Unknown target CPU: %TARGETCPU%
-goto pr_end
-
-:pr_arm
-echo Target processor: ARM
-echo TARGET_PROC=arm >> build\Makefiles\nmake\config.mak
-echo TARGET_PROC_SUBTYPE=%TARGETCPU% >> build\Makefiles\nmake\config.mak
-goto pr_end
-
-:pr_x86
-echo Target processor: x86
-echo TARGET_PROC=x86 >> build\Makefiles\nmake\config.mak
-goto pr_end
-
-:pr_emul
-echo Target processor: Emulator
-echo TARGET_PROC=x86 >> build\Makefiles\nmake\config.mak
-echo TARGET_PROC_SUBTYPE=emulator >> build\Makefiles\nmake\config.mak
-goto pr_end
-
-:pr_mips
-echo Target processor: MIPS
-echo TARGET_PROC=mips >> build\Makefiles\nmake\config.mak
-echo TARGET_PROC_SUBTYPE=%TARGETCPU% >> build\Makefiles\nmake\config.mak
-
-goto pr_end
-
-:pr_sh3
-echo Target processor: %TARGETCPU%
-echo TARGET_PROC=sh3 >> build\Makefiles\nmake\config.mak
-goto pr_end
-
-:pr_sh4
-echo Target processor: %TARGETCPU%
-echo TARGET_PROC=sh4 >> build\Makefiles\nmake\config.mak
-goto pr_end
-
-:pr_end
-goto oc_end
-
-
-REM **************************************************************************
-REM *
-REM * Platform configuration
-REM *
-REM **************************************************************************
-:opt_plat
-
-if "%2" == "win95" goto op_win95
-if "%2" == "win98" goto op_win98
-if "%2" == "winxp" goto op_winxp
-
-echo Unknown platform: %2
-goto op_end
-
-:op_win95
-echo Setting platform: Windows 95
-echo WINVER=0x0400 >> build\Makefiles\nmake\config.mak
-set PLATFORM_SPECIFIED=1
-goto op_end
-
-:op_win98
-echo Setting platform: Windows 98
-echo WINVER=0x0410 >> build\Makefiles\nmake\config.mak
-set PLATFORM_SPECIFIED=1
-goto op_end
-
-:op_winxp
-echo Setting platform: Windows XP
-echo WINVER=0x0501 >> build\Makefiles\nmake\config.mak
-set PLATFORM_SPECIFIED=1
-goto op_end
-
-:op_end
-shift
-
-goto cont_lp
-
-
-REM **************************************************************************
-REM *
-REM * Cross Compiling option
-REM *
-REM **************************************************************************
-
-:opt_x
-echo Setting up for cross compiling.
-echo CROSS_COMPILING=1 >> build\Makefiles\nmake\config.mak
-goto cont_lp
-
-
-REM **************************************************************************
-REM *
-REM * C runtime library selection
-REM *
-REM **************************************************************************
-
-:opt_srtl
-if "%SELECTED_COMPILER%" == "msvc" goto or_sok
-goto or_err
-
-:opt_drtl
-if "%SELECTED_COMPILER%" == "msvc" goto or_dok
-goto or_err
-
-:or_err
-echo Error: Setting C runtime library for compiler other than microsoft ones!
-goto or_end
-
-:or_sok
-echo Selecting static C runtime library for STLport
-echo WITH_STATIC_RTL=1 >> build\Makefiles\nmake\config.mak
-goto or_end
-
-:or_dok
-echo Selecting dynamic C runtime library for STLport
-echo WITH_DYNAMIC_RTL=1 >> build\Makefiles\nmake\config.mak
-goto or_end
-
-:or_end
-goto cont_lp
-
-REM **************************************************************************
-REM *
-REM * boost support
-REM *
-REM **************************************************************************
-:opt_bst
-REM if (Exists("%2")) goto ob_ok
-REM if !("%2" == "") goto ob_ok
-goto ob_ok
-
-echo Error: Invalid boost intallation folder ("%2").
-goto ob_end
-
-:ob_ok
-echo Activating boost support using "%2" path
-echo STLP_BUILD_BOOST_PATH="%2" >> build\Makefiles\nmake\config.mak
-
-:ob_end
-shift
-
-goto cont_lp
-
-REM **************************************************************************
-REM *
-REM * Multithreading support
-REM *
-REM **************************************************************************
-:opt_st
-echo Removing thread safety support
-echo WITHOUT_THREAD=1 >> build\Makefiles\nmake\config.mak
-goto cont_lp
-
-REM **************************************************************************
-REM *
-REM * rtti support
-REM *
-REM **************************************************************************
-:opt_rtti
-echo Removing rtti support
-echo WITHOUT_RTTI=1 >> build\Makefiles\nmake\config.mak
-goto cont_lp
-
-REM **************************************************************************
-REM *
-REM * Extra compilation flags
-REM *
-REM **************************************************************************
-:opt_xtra
-echo Adding '%2' compilation option
-if "%ONE_OPTION_ADDED%" == "1" goto ox_n
-
-echo DEFS = %2 >> build\Makefiles\nmake\config.mak
-set ONE_OPTION_ADDED=1
-goto ox_end
-
-:ox_n
-echo DEFS = $(DEFS) %2 >> build\Makefiles\nmake\config.mak
-
-:ox_end
-shift
-goto cont_lp
-
-REM **************************************************************************
-REM *
-REM * Library name configuration
-REM *
-REM **************************************************************************
-:opt_motf
-echo Using '%2' in generated library names
-
-echo LIB_MOTIF = %2 >> build\Makefiles\nmake\config.mak
-
-shift
-goto cont_lp
-
-REM **************************************************************************
-REM *
-REM * Build without STLport
-REM *
-REM **************************************************************************
-:no_sport
-echo Configured to build without STLport
-
-echo WITHOUT_STLPORT=1 >> build\Makefiles\nmake\config.mak
-
-shift
-goto cont_lp
-
-REM **************************************************************************
-REM *
-REM * Clean
-REM *
-REM **************************************************************************
-:opt_cln
-del build\Makefiles\nmake\config.mak
-echo STLport configuration file removed.
-goto skp_comp
-
-REM **************************************************************************
-REM *
-REM * End loop
-REM *
-REM **************************************************************************
-
-:end_loop
-
-if "%PLATFORM_SPECIFIED%" == "1" goto comp
-echo Setting platform: Windows XP
-echo.
-echo WINVER=0x0501 >> build\Makefiles\nmake\config.mak
-
-:comp
-echo Done configuring STLport.
-echo.
-echo Go to build/lib folder and type "nmake clean install" to build and
-echo install STLport to the "lib" and "bin" folders.
-echo Go to build/test/unit folder and type nmake clean install to
-echo build unit tests and install them in bin folder.
-echo.
-
-:skp_comp
-set SELECTED_COMPILER=
-set SELECTED_COMPILER_VERSION=
-set ONE_OPTION_ADDED=
-set PLATFORM_SPECIFIED=
diff --git a/deb/libstlport.so b/deb/libstlport.so
new file mode 100755
index 0000000..2df3a6f
--- /dev/null
+++ b/deb/libstlport.so
Binary files differ
diff --git a/flo/libstlport.so b/flo/libstlport.so
new file mode 100755
index 0000000..2df3a6f
--- /dev/null
+++ b/flo/libstlport.so
Binary files differ
diff --git a/flounder/32/libstlport.so b/flounder/32/libstlport.so
new file mode 100755
index 0000000..2df3a6f
--- /dev/null
+++ b/flounder/32/libstlport.so
Binary files differ
diff --git a/flounder/libstlport.so b/flounder/libstlport.so
new file mode 100755
index 0000000..239ac17
--- /dev/null
+++ b/flounder/libstlport.so
Binary files differ
diff --git a/fugu/libstlport.so b/fugu/libstlport.so
new file mode 100755
index 0000000..1a478ca
--- /dev/null
+++ b/fugu/libstlport.so
Binary files differ
diff --git a/grouper/libstlport.so b/grouper/libstlport.so
new file mode 100755
index 0000000..108f4ac
--- /dev/null
+++ b/grouper/libstlport.so
Binary files differ
diff --git a/hammerhead/libstlport.so b/hammerhead/libstlport.so
new file mode 100755
index 0000000..2df3a6f
--- /dev/null
+++ b/hammerhead/libstlport.so
Binary files differ
diff --git a/libstlport.mk b/libstlport.mk
deleted file mode 100644
index 799ed6f..0000000
--- a/libstlport.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-# New projects shouldn't use this file. To use libc++, add the following line to
-# your makefile.
-LOCAL_CXX_STL := stlport
diff --git a/mako/libstlport.so b/mako/libstlport.so
new file mode 100755
index 0000000..2df3a6f
--- /dev/null
+++ b/mako/libstlport.so
Binary files differ
diff --git a/manta/libstlport.so b/manta/libstlport.so
new file mode 100755
index 0000000..2df3a6f
--- /dev/null
+++ b/manta/libstlport.so
Binary files differ
diff --git a/shamu/libstlport.so b/shamu/libstlport.so
new file mode 100755
index 0000000..2df3a6f
--- /dev/null
+++ b/shamu/libstlport.so
Binary files differ
diff --git a/src/_stdio_file.h b/src/_stdio_file.h
deleted file mode 100644
index d913fc4..0000000
--- a/src/_stdio_file.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#ifndef _STLP_STDIO_FILE_H
-#define _STLP_STDIO_FILE_H
-
-/* This file provides a low-level interface between the internal
- * representation of struct FILE, from the C stdio library, and
- * the C++ I/O library. */
-
-#ifndef _STLP_CSTDIO
-# include <cstdio>
-#endif
-#ifndef _STLP_CSTDDEF
-# include <cstddef>
-#endif
-
-#if defined (__MSL__)
-# include <unix.h> /* get the definition of fileno */
-#endif
-
-_STLP_BEGIN_NAMESPACE
-
-#if defined (_STLP_WCE)
-
-inline int _FILE_fd(const FILE *__f) {
- /* Check if FILE is one of the three standard streams
- We do this check first, because invoking _fileno() on one of them
- causes a terminal window to be created. This also happens if you do
- any IO on them, but merely retrieving the filedescriptor shouldn't
- already do that.
-
- Obviously this is pretty implementation-specific because it requires
- that indeed the first three FDs are always the same, but that is not
- only common but almost guaranteed. */
- for (int __fd = 0; __fd != 3; ++__fd) {
- if (__f == _getstdfilex(__fd))
- return __fd;
- }
-
- /* Normal files. */
- return (int)::_fileno((FILE*)__f);
-}
-
-# elif defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR)
-
-inline int _FILE_fd(const FILE *__f) { return __f->__file; }
-
-# elif defined (__sun) && defined (_LP64)
-
-inline int _FILE_fd(const FILE *__f) { return (int) __f->__pad[2]; }
-
-#elif defined (__hpux) /* && defined(__hppa) && defined(__HP_aCC)) */ || \
- defined (__MVS__) || \
- defined (_STLP_USE_UCLIBC) /* should be before _STLP_USE_GLIBC */
-
-inline int _FILE_fd(const FILE *__f) { return fileno(__CONST_CAST(FILE*, __f)); }
-
-#elif defined (_STLP_USE_GLIBC)
-
-inline int _FILE_fd(const FILE *__f) { return __f->_fileno; }
-
-#elif defined (__BORLANDC__)
-
-inline int _FILE_fd(const FILE *__f) { return __f->fd; }
-
-#elif defined (__MWERKS__)
-
-/* using MWERKS-specific defines here to detect other OS targets
- * dwa: I'm not sure they provide fileno for all OS's, but this should
- * work for Win32 and WinCE
-
- * Hmm, at least for Novell NetWare __dest_os == __mac_os true too..
- * May be both __dest_os and __mac_os defined and empty? - ptr */
-# if __dest_os == __mac_os
-inline int _FILE_fd(const FILE *__f) { return ::fileno(__CONST_CAST(FILE*, __f)); }
-# else
-inline int _FILE_fd(const FILE *__f) { return ::_fileno(__CONST_CAST(FILE*, __f)); }
-# endif
-
-#elif defined (__QNXNTO__) || defined (__WATCOMC__) || defined (__EMX__)
-
-inline int _FILE_fd(const FILE *__f) { return __f->_handle; }
-
-#elif defined (__Lynx__)
-
-/* the prototypes are taken from LynxOS patch for STLport 4.0 */
-inline int _FILE_fd(const FILE *__f) { return __f->_fd; }
-
-#else /* The most common access to file descriptor. */
-
-inline int _FILE_fd(const FILE *__f) { return __f->_file; }
-
-#endif
-
-_STLP_END_NAMESPACE
-
-#endif /* _STLP_STDIO_FILE_H */
-
-/* Local Variables:
- * mode:C++
- * End: */
diff --git a/src/acquire_release.h b/src/acquire_release.h
deleted file mode 100644
index 5ea73da..0000000
--- a/src/acquire_release.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#ifndef ACQUIRE_RELEASE_H
-#define ACQUIRE_RELEASE_H
-
-#include "c_locale.h"
-
-_STLP_BEGIN_NAMESPACE
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-_Locale_ctype* _STLP_CALL __acquire_ctype(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
-_Locale_codecvt* _STLP_CALL __acquire_codecvt(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
-_Locale_numeric* _STLP_CALL __acquire_numeric(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
-_Locale_collate* _STLP_CALL __acquire_collate(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
-_Locale_monetary* _STLP_CALL __acquire_monetary(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
-_Locale_time* _STLP_CALL __acquire_time(const char* &name, char *buf, _Locale_name_hint*, int *__err_code);
-_Locale_messages* _STLP_CALL __acquire_messages(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
-
-void _STLP_CALL __release_ctype(_Locale_ctype* cat);
-void _STLP_CALL __release_codecvt(_Locale_codecvt* cat);
-void _STLP_CALL __release_numeric(_Locale_numeric* cat);
-void _STLP_CALL __release_collate(_Locale_collate* cat);
-void _STLP_CALL __release_monetary(_Locale_monetary* cat);
-void _STLP_CALL __release_time(_Locale_time* __time);
-void _STLP_CALL __release_messages(_Locale_messages* cat);
-
-_STLP_MOVE_TO_STD_NAMESPACE
-_STLP_END_NAMESPACE
-
-#endif /* ACQUIRE_RELEASE_H */
diff --git a/src/aligned_buffer.h b/src/aligned_buffer.h
deleted file mode 100644
index 6ff6ca6..0000000
--- a/src/aligned_buffer.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef ALIGNED_BUFFER_H
-#define ALIGNED_BUFFER_H
-
-_STLP_BEGIN_NAMESPACE
-// this is for fake initialization
-template<class T>
-union _Stl_aligned_buffer {
- char buf[sizeof(T)];
- struct { double a; double b; } padding;
-
- T* operator&() {
- return __REINTERPRET_CAST(T*, this);
- }
-
- T const* operator&() const {
- return __REINTERPRET_CAST(T const*, this);
- }
-};
-_STLP_END_NAMESPACE
-
-#endif
diff --git a/src/allocators.cpp b/src/allocators.cpp
deleted file mode 100644
index 8bbcca8..0000000
--- a/src/allocators.cpp
+++ /dev/null
@@ -1,1121 +0,0 @@
-/*
- *
- * Copyright (c) 1996,1997
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1997
- * Moscow Center for SPARC Technology
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include <memory>
-
-#if defined (__GNUC__) && (defined (__CYGWIN__) || defined (__MINGW32__))
-# include <malloc.h>
-#endif
-
-#if defined (_STLP_PTHREADS) && !defined (_STLP_NO_THREADS)
-# include <pthread_alloc>
-# include <cerrno>
-#endif
-
-#include <stl/_threads.h>
-
-#include "lock_free_slist.h"
-
-#if defined (__WATCOMC__)
-# pragma warning 13 9
-# pragma warning 367 9
-# pragma warning 368 9
-#endif
-
-#if defined (_STLP_SGI_THREADS)
- // We test whether threads are in use before locking.
- // Perhaps this should be moved into stl_threads.h, but that
- // probably makes it harder to avoid the procedure call when
- // it isn't needed.
-extern "C" {
- extern int __us_rsthread_malloc;
-}
-#endif
-
-// Specialised debug form of new operator which does not provide "false"
-// memory leaks when run with debug CRT libraries.
-#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1020 && defined (_STLP_DEBUG_ALLOC)) && !defined (_STLP_WCE)
-# include <crtdbg.h>
-inline char* __stlp_new_chunk(size_t __bytes) {
- void *__chunk = _STLP_CHECK_NULL_ALLOC(::operator new(__bytes, __FILE__, __LINE__));
- return __STATIC_CAST(char*, __chunk);
-}
-inline void __stlp_delete_chunck(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
-#else
-# ifdef _STLP_NODE_ALLOC_USE_MALLOC
-# include <cstdlib>
-inline char* __stlp_new_chunk(size_t __bytes) {
- // do not use _STLP_CHECK_NULL_ALLOC, this macro is dedicated to new operator.
- void *__chunk = _STLP_VENDOR_CSTD::malloc(__bytes);
- if (__chunk == 0) {
- _STLP_THROW_BAD_ALLOC;
- }
- return __STATIC_CAST(char*, __chunk);
-}
-inline void __stlp_delete_chunck(void* __p) { _STLP_VENDOR_CSTD::free(__p); }
-# else
-inline char* __stlp_new_chunk(size_t __bytes)
-{ return __STATIC_CAST(char*, _STLP_STD::__stl_new(__bytes)); }
-inline void __stlp_delete_chunck(void* __p) { _STLP_STD::__stl_delete(__p); }
-# endif
-#endif
-
-/* This is an additional atomic operations to the ones already defined in
- * stl/_threads.h, platform should try to support it to improve performance.
- * __add_atomic_t _STLP_ATOMIC_ADD(volatile __add_atomic_t* __target, __add_atomic_t __val) :
- * does *__target = *__target + __val and returns the old *__target value */
-typedef long __add_atomic_t;
-typedef unsigned long __uadd_atomic_t;
-
-#if defined (__GNUC__) && defined (__i386__)
-inline long _STLP_atomic_add_gcc_x86(long volatile* p, long addend) {
- long result;
- __asm__ __volatile__
- ("lock; xaddl %1, %0;"
- :"=m" (*p), "=r" (result)
- :"m" (*p), "1" (addend)
- :"cc");
- return result + addend;
-}
-# define _STLP_ATOMIC_ADD(__dst, __val) _STLP_atomic_add_gcc_x86(__dst, __val)
-#elif defined (_STLP_WIN32THREADS)
-// The Win32 API function InterlockedExchangeAdd is not available on Windows 95.
-# if !defined (_STLP_WIN95_LIKE)
-# if defined (_STLP_NEW_PLATFORM_SDK)
-# define _STLP_ATOMIC_ADD(__dst, __val) InterlockedExchangeAdd(__dst, __val)
-# else
-# define _STLP_ATOMIC_ADD(__dst, __val) InterlockedExchangeAdd(__CONST_CAST(__add_atomic_t*, __dst), __val)
-# endif
-# endif
-#endif
-
-#if defined (__OS400__)
-// dums 02/05/2007: is it really necessary ?
-enum { _ALIGN = 16, _ALIGN_SHIFT = 4 };
-#else
-enum { _ALIGN = 2 * sizeof(void*), _ALIGN_SHIFT = 2 + sizeof(void*) / 4 };
-#endif
-
-#define _S_FREELIST_INDEX(__bytes) ((__bytes - size_t(1)) >> (int)_ALIGN_SHIFT)
-
-_STLP_BEGIN_NAMESPACE
-
-// malloc_alloc out-of-memory handling
-static __oom_handler_type __oom_handler = __STATIC_CAST(__oom_handler_type, 0);
-
-#ifdef _STLP_THREADS
-_STLP_mutex __oom_handler_lock;
-#endif
-
-void* _STLP_CALL __malloc_alloc::allocate(size_t __n)
-{
- void *__result = malloc(__n);
- if ( 0 == __result ) {
- __oom_handler_type __my_malloc_handler;
-
- for (;;) {
- {
-#ifdef _STLP_THREADS
- _STLP_auto_lock _l( __oom_handler_lock );
-#endif
- __my_malloc_handler = __oom_handler;
- }
- if ( 0 == __my_malloc_handler) {
- _STLP_THROW_BAD_ALLOC;
- }
- (*__my_malloc_handler)();
- __result = malloc(__n);
- if ( __result )
- return __result;
- }
- }
- return __result;
-}
-
-__oom_handler_type _STLP_CALL __malloc_alloc::set_malloc_handler(__oom_handler_type __f)
-{
-#ifdef _STLP_THREADS
- _STLP_auto_lock _l( __oom_handler_lock );
-#endif
- __oom_handler_type __old = __oom_handler;
- __oom_handler = __f;
- return __old;
-}
-
-// *******************************************************
-// Default node allocator.
-// With a reasonable compiler, this should be roughly as fast as the
-// original STL class-specific allocators, but with less fragmentation.
-//
-// Important implementation properties:
-// 1. If the client request an object of size > _MAX_BYTES, the resulting
-// object will be obtained directly from malloc.
-// 2. In all other cases, we allocate an object of size exactly
-// _S_round_up(requested_size). Thus the client has enough size
-// information that we can return the object to the proper free list
-// without permanently losing part of the object.
-//
-
-#define _STLP_NFREELISTS 16
-
-#if defined (_STLP_LEAKS_PEDANTIC) && defined (_STLP_USE_DYNAMIC_LIB)
-/*
- * We can only do cleanup of the node allocator memory pool if we are
- * sure that the STLport library is used as a shared one as it guaranties
- * the unicity of the node allocator instance. Without that guaranty node
- * allocator instances might exchange memory blocks making the implementation
- * of a cleaning process much more complicated.
- */
-# define _STLP_DO_CLEAN_NODE_ALLOC
-#endif
-
-/* When STLport is used without multi threaded safety we use the node allocator
- * implementation with locks as locks becomes no-op. The lock free implementation
- * always use system specific atomic operations which are slower than 'normal'
- * ones.
- */
-#if defined (_STLP_THREADS) && \
- defined (_STLP_HAS_ATOMIC_FREELIST) && defined (_STLP_ATOMIC_ADD)
-/*
- * We have an implementation of the atomic freelist (_STLP_atomic_freelist)
- * for this architecture and compiler. That means we can use the non-blocking
- * implementation of the node-allocation engine.*/
-# define _STLP_USE_LOCK_FREE_IMPLEMENTATION
-#endif
-
-#if !defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
-# if defined (_STLP_THREADS)
-
-class _Node_Alloc_Lock {
- static _STLP_STATIC_MUTEX& _S_Mutex() {
- static _STLP_STATIC_MUTEX mutex _STLP_MUTEX_INITIALIZER;
- return mutex;
- }
-public:
- _Node_Alloc_Lock() {
-# if defined (_STLP_SGI_THREADS)
- if (__us_rsthread_malloc)
-# endif
- _S_Mutex()._M_acquire_lock();
- }
-
- ~_Node_Alloc_Lock() {
-# if defined (_STLP_SGI_THREADS)
- if (__us_rsthread_malloc)
-# endif
- _S_Mutex()._M_release_lock();
- }
-};
-
-# else
-
-class _Node_Alloc_Lock {
-public:
- _Node_Alloc_Lock() { }
- ~_Node_Alloc_Lock() { }
-};
-
-# endif
-
-struct _Node_alloc_obj {
- _Node_alloc_obj * _M_next;
-};
-#endif
-
-class __node_alloc_impl {
- static inline size_t _STLP_CALL _S_round_up(size_t __bytes)
- { return (((__bytes) + (size_t)_ALIGN-1) & ~((size_t)_ALIGN - 1)); }
-
-#if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
- typedef _STLP_atomic_freelist::item _Obj;
- typedef _STLP_atomic_freelist _Freelist;
- typedef _STLP_atomic_freelist _ChunkList;
-
- // Header of blocks of memory that have been allocated as part of
- // a larger chunk but have not yet been chopped up into nodes.
- struct _FreeBlockHeader : public _STLP_atomic_freelist::item {
- char* _M_end; // pointer to end of free memory
- };
-#else
- typedef _Node_alloc_obj _Obj;
- typedef _Obj* _STLP_VOLATILE _Freelist;
- typedef _Obj* _ChunkList;
-#endif
-
-private:
- // Returns an object of size __n, and optionally adds to size __n free list.
- static _Obj* _S_refill(size_t __n);
- // Allocates a chunk for nobjs of size __p_size. nobjs may be reduced
- // if it is inconvenient to allocate the requested number.
- static char* _S_chunk_alloc(size_t __p_size, int& __nobjs);
- // Chunk allocation state.
- static _Freelist _S_free_list[_STLP_NFREELISTS];
- // Amount of total allocated memory
-#if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
- static _STLP_VOLATILE __add_atomic_t _S_heap_size;
-#else
- static size_t _S_heap_size;
-#endif
-
-#if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
- // List of blocks of free memory
- static _STLP_atomic_freelist _S_free_mem_blocks;
-#else
- // Start of the current free memory buffer
- static char* _S_start_free;
- // End of the current free memory buffer
- static char* _S_end_free;
-#endif
-
-#if defined (_STLP_DO_CLEAN_NODE_ALLOC)
-public:
- // Methods to report alloc/dealloc calls to the counter system.
-# if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
- typedef _STLP_VOLATILE __stl_atomic_t _AllocCounter;
-# else
- typedef __stl_atomic_t _AllocCounter;
-# endif
- static _AllocCounter& _STLP_CALL _S_alloc_counter();
- static void _S_alloc_call();
- static void _S_dealloc_call();
-
-private:
- // Free all the allocated chuncks of memory
- static void _S_chunk_dealloc();
- // Beginning of the linked list of allocated chunks of memory
- static _ChunkList _S_chunks;
-#endif /* _STLP_DO_CLEAN_NODE_ALLOC */
-
-public:
- /* __n must be > 0 */
- static void* _M_allocate(size_t& __n);
- /* __p may not be 0 */
- static void _M_deallocate(void *__p, size_t __n);
-};
-
-#if !defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
-void* __node_alloc_impl::_M_allocate(size_t& __n) {
- __n = _S_round_up(__n);
- _Obj * _STLP_VOLATILE * __my_free_list = _S_free_list + _S_FREELIST_INDEX(__n);
- _Obj *__r;
-
- // Acquire the lock here with a constructor call.
- // This ensures that it is released in exit or during stack
- // unwinding.
- _Node_Alloc_Lock __lock_instance;
-
- if ( (__r = *__my_free_list) != 0 ) {
- *__my_free_list = __r->_M_next;
- } else {
- __r = _S_refill(__n);
- }
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
- _S_alloc_call();
-# endif
- // lock is released here
- return __r;
-}
-
-void __node_alloc_impl::_M_deallocate(void *__p, size_t __n) {
- _Obj * _STLP_VOLATILE * __my_free_list = _S_free_list + _S_FREELIST_INDEX(__n);
- _Obj * __pobj = __STATIC_CAST(_Obj*, __p);
-
- // acquire lock
- _Node_Alloc_Lock __lock_instance;
- __pobj->_M_next = *__my_free_list;
- *__my_free_list = __pobj;
-
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
- _S_dealloc_call();
-# endif
- // lock is released here
-}
-
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
-# define _STLP_OFFSET sizeof(_Obj)
-# else
-# define _STLP_OFFSET 0
-# endif
-
-/* We allocate memory in large chunks in order to avoid fragmenting */
-/* the malloc heap too much. */
-/* We assume that size is properly aligned. */
-/* We hold the allocation lock. */
-char* __node_alloc_impl::_S_chunk_alloc(size_t _p_size, int& __nobjs) {
- char* __result;
- size_t __total_bytes = _p_size * __nobjs;
- size_t __bytes_left = _S_end_free - _S_start_free;
-
- if (__bytes_left > 0) {
- if (__bytes_left >= __total_bytes) {
- __result = _S_start_free;
- _S_start_free += __total_bytes;
- return __result;
- }
-
- if (__bytes_left >= _p_size) {
- __nobjs = (int)(__bytes_left / _p_size);
- __total_bytes = _p_size * __nobjs;
- __result = _S_start_free;
- _S_start_free += __total_bytes;
- return __result;
- }
-
- // Try to make use of the left-over piece.
- _Obj* _STLP_VOLATILE* __my_free_list = _S_free_list + _S_FREELIST_INDEX(__bytes_left);
- __REINTERPRET_CAST(_Obj*, _S_start_free)->_M_next = *__my_free_list;
- *__my_free_list = __REINTERPRET_CAST(_Obj*, _S_start_free);
- _S_start_free = _S_end_free = 0;
- }
-
- size_t __bytes_to_get = 2 * __total_bytes + _S_round_up(_S_heap_size) + _STLP_OFFSET;
-
- _STLP_TRY {
- _S_start_free = __stlp_new_chunk(__bytes_to_get);
- }
-#if defined (_STLP_USE_EXCEPTIONS)
- catch (const _STLP_STD::bad_alloc&) {
- _Obj* _STLP_VOLATILE* __my_free_list;
- _Obj* __p;
- // Try to do with what we have. That can't hurt.
- // We do not try smaller requests, since that tends
- // to result in disaster on multi-process machines.
- for (size_t __i = _p_size; __i <= (size_t)_MAX_BYTES; __i += (size_t)_ALIGN) {
- __my_free_list = _S_free_list + _S_FREELIST_INDEX(__i);
- __p = *__my_free_list;
- if (0 != __p) {
- *__my_free_list = __p -> _M_next;
- _S_start_free = __REINTERPRET_CAST(char*, __p);
- _S_end_free = _S_start_free + __i;
- return _S_chunk_alloc(_p_size, __nobjs);
- // Any leftover piece will eventually make it to the
- // right free list.
- }
- }
- __bytes_to_get = __total_bytes + _STLP_OFFSET;
- _S_start_free = __stlp_new_chunk(__bytes_to_get);
- }
-#endif
-
- _S_heap_size += __bytes_to_get >> 4;
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
- __REINTERPRET_CAST(_Obj*, _S_start_free)->_M_next = _S_chunks;
- _S_chunks = __REINTERPRET_CAST(_Obj*, _S_start_free);
-# endif
- _S_end_free = _S_start_free + __bytes_to_get;
- _S_start_free += _STLP_OFFSET;
- return _S_chunk_alloc(_p_size, __nobjs);
-}
-
-/* Returns an object of size __n, and optionally adds to size __n free list.*/
-/* We assume that __n is properly aligned. */
-/* We hold the allocation lock. */
-_Node_alloc_obj* __node_alloc_impl::_S_refill(size_t __n) {
- int __nobjs = 20;
- char* __chunk = _S_chunk_alloc(__n, __nobjs);
-
- if (1 == __nobjs) return __REINTERPRET_CAST(_Obj*, __chunk);
-
- _Obj* _STLP_VOLATILE* __my_free_list = _S_free_list + _S_FREELIST_INDEX(__n);
- _Obj* __result;
- _Obj* __current_obj;
- _Obj* __next_obj;
-
- /* Build free list in chunk */
- __result = __REINTERPRET_CAST(_Obj*, __chunk);
- *__my_free_list = __next_obj = __REINTERPRET_CAST(_Obj*, __chunk + __n);
- for (--__nobjs; --__nobjs; ) {
- __current_obj = __next_obj;
- __next_obj = __REINTERPRET_CAST(_Obj*, __REINTERPRET_CAST(char*, __next_obj) + __n);
- __current_obj->_M_next = __next_obj;
- }
- __next_obj->_M_next = 0;
- return __result;
-}
-
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
-void __node_alloc_impl::_S_alloc_call()
-{ ++_S_alloc_counter(); }
-
-void __node_alloc_impl::_S_dealloc_call() {
- __stl_atomic_t &counter = _S_alloc_counter();
- if (--counter == 0)
- { _S_chunk_dealloc(); }
-}
-
-/* We deallocate all the memory chunks */
-void __node_alloc_impl::_S_chunk_dealloc() {
- _Obj *__pcur = _S_chunks, *__pnext;
- while (__pcur != 0) {
- __pnext = __pcur->_M_next;
- __stlp_delete_chunck(__pcur);
- __pcur = __pnext;
- }
- _S_chunks = 0;
- _S_start_free = _S_end_free = 0;
- _S_heap_size = 0;
- memset(__REINTERPRET_CAST(char*, __CONST_CAST(_Obj**, &_S_free_list[0])), 0, _STLP_NFREELISTS * sizeof(_Obj*));
-}
-# endif
-
-#else
-
-void* __node_alloc_impl::_M_allocate(size_t& __n) {
- __n = _S_round_up(__n);
- _Obj* __r = _S_free_list[_S_FREELIST_INDEX(__n)].pop();
- if (__r == 0)
- { __r = _S_refill(__n); }
-
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
- _S_alloc_call();
-# endif
- return __r;
-}
-
-void __node_alloc_impl::_M_deallocate(void *__p, size_t __n) {
- _S_free_list[_S_FREELIST_INDEX(__n)].push(__STATIC_CAST(_Obj*, __p));
-
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
- _S_dealloc_call();
-# endif
-}
-
-/* Returns an object of size __n, and optionally adds additional ones to */
-/* freelist of objects of size __n. */
-/* We assume that __n is properly aligned. */
-__node_alloc_impl::_Obj* __node_alloc_impl::_S_refill(size_t __n) {
- int __nobjs = 20;
- char* __chunk = _S_chunk_alloc(__n, __nobjs);
-
- if (__nobjs <= 1)
- return __REINTERPRET_CAST(_Obj*, __chunk);
-
- // Push all new nodes (minus first one) onto freelist
- _Obj* __result = __REINTERPRET_CAST(_Obj*, __chunk);
- _Obj* __cur_item = __result;
- _Freelist* __my_freelist = _S_free_list + _S_FREELIST_INDEX(__n);
- for (--__nobjs; __nobjs != 0; --__nobjs) {
- __cur_item = __REINTERPRET_CAST(_Obj*, __REINTERPRET_CAST(char*, __cur_item) + __n);
- __my_freelist->push(__cur_item);
- }
- return __result;
-}
-
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
-# define _STLP_OFFSET _ALIGN
-# else
-# define _STLP_OFFSET 0
-# endif
-
-/* We allocate memory in large chunks in order to avoid fragmenting */
-/* the malloc heap too much. */
-/* We assume that size is properly aligned. */
-char* __node_alloc_impl::_S_chunk_alloc(size_t _p_size, int& __nobjs) {
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
- //We are going to add a small memory block to keep all the allocated blocks
- //address, we need to do so respecting the memory alignment. The following
- //static assert checks that the reserved block is big enough to store a pointer.
- _STLP_STATIC_ASSERT(sizeof(_Obj) <= _ALIGN)
-# endif
- char* __result = 0;
- __add_atomic_t __total_bytes = __STATIC_CAST(__add_atomic_t, _p_size) * __nobjs;
-
- _FreeBlockHeader* __block = __STATIC_CAST(_FreeBlockHeader*, _S_free_mem_blocks.pop());
- if (__block != 0) {
- // We checked a block out and can now mess with it with impugnity.
- // We'll put the remainder back into the list if we're done with it below.
- char* __buf_start = __REINTERPRET_CAST(char*, __block);
- __add_atomic_t __bytes_left = __block->_M_end - __buf_start;
-
- if ((__bytes_left < __total_bytes) && (__bytes_left >= __STATIC_CAST(__add_atomic_t, _p_size))) {
- // There's enough left for at least one object, but not as much as we wanted
- __result = __buf_start;
- __nobjs = (int)(__bytes_left/_p_size);
- __total_bytes = __STATIC_CAST(__add_atomic_t, _p_size) * __nobjs;
- __bytes_left -= __total_bytes;
- __buf_start += __total_bytes;
- }
- else if (__bytes_left >= __total_bytes) {
- // The block has enough left to satisfy all that was asked for
- __result = __buf_start;
- __bytes_left -= __total_bytes;
- __buf_start += __total_bytes;
- }
-
- if (__bytes_left != 0) {
- // There is still some memory left over in block after we satisfied our request.
- if ((__result != 0) && (__bytes_left >= (__add_atomic_t)sizeof(_FreeBlockHeader))) {
- // We were able to allocate at least one object and there is still enough
- // left to put remainder back into list.
- _FreeBlockHeader* __newblock = __REINTERPRET_CAST(_FreeBlockHeader*, __buf_start);
- __newblock->_M_end = __block->_M_end;
- _S_free_mem_blocks.push(__newblock);
- }
- else {
- // We were not able to allocate enough for at least one object.
- // Shove into freelist of nearest (rounded-down!) size.
- size_t __rounded_down = _S_round_up(__bytes_left + 1) - (size_t)_ALIGN;
- if (__rounded_down > 0)
- _S_free_list[_S_FREELIST_INDEX(__rounded_down)].push((_Obj*)__buf_start);
- }
- }
- if (__result != 0)
- return __result;
- }
-
- // We couldn't satisfy it from the list of free blocks, get new memory.
- __add_atomic_t __bytes_to_get = 2 * __total_bytes +
- __STATIC_CAST(__add_atomic_t,
- _S_round_up(__STATIC_CAST(__uadd_atomic_t, _STLP_ATOMIC_ADD(&_S_heap_size, 0)))) +
- _STLP_OFFSET;
- _STLP_TRY {
- __result = __stlp_new_chunk(__bytes_to_get);
- }
-#if defined (_STLP_USE_EXCEPTIONS)
- catch (const bad_alloc&) {
- // Allocation failed; try to canibalize from freelist of a larger object size.
- for (size_t __i = _p_size; __i <= (size_t)_MAX_BYTES; __i += (size_t)_ALIGN) {
- _Obj* __p = _S_free_list[_S_FREELIST_INDEX(__i)].pop();
- if (0 != __p) {
- if (__i < sizeof(_FreeBlockHeader)) {
- // Not enough to put into list of free blocks, divvy it up here.
- // Use as much as possible for this request and shove remainder into freelist.
- __nobjs = (int)(__i/_p_size);
- __total_bytes = __nobjs * __STATIC_CAST(__add_atomic_t, _p_size);
- size_t __bytes_left = __i - __total_bytes;
- size_t __rounded_down = _S_round_up(__bytes_left+1) - (size_t)_ALIGN;
- if (__rounded_down > 0) {
- _S_free_list[_S_FREELIST_INDEX(__rounded_down)].push(__REINTERPRET_CAST(_Obj*, __REINTERPRET_CAST(char*, __p) + __total_bytes));
- }
- return __REINTERPRET_CAST(char*, __p);
- }
- else {
- // Add node to list of available blocks and recursively allocate from it.
- _FreeBlockHeader* __newblock = (_FreeBlockHeader*)__p;
- __newblock->_M_end = __REINTERPRET_CAST(char*, __p) + __i;
- _S_free_mem_blocks.push(__newblock);
- return _S_chunk_alloc(_p_size, __nobjs);
- }
- }
- }
-
- // We were not able to find something in a freelist, try to allocate a smaller amount.
- __bytes_to_get = __total_bytes + _STLP_OFFSET;
- __result = __stlp_new_chunk(__bytes_to_get);
-
- // This should either throw an exception or remedy the situation.
- // Thus we assume it succeeded.
- }
-#endif
- // Alignment check
- _STLP_VERBOSE_ASSERT(((__REINTERPRET_CAST(size_t, __result) & __STATIC_CAST(size_t, _ALIGN - 1)) == 0),
- _StlMsg_DBA_DELETED_TWICE)
- _STLP_ATOMIC_ADD(&_S_heap_size, __bytes_to_get >> 4);
-
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
- // We have to track the allocated memory chunks for release on exit.
- _S_chunks.push(__REINTERPRET_CAST(_Obj*, __result));
- __result += _ALIGN;
- __bytes_to_get -= _ALIGN;
-# endif
-
- if (__bytes_to_get > __total_bytes) {
- // Push excess memory allocated in this chunk into list of free memory blocks
- _FreeBlockHeader* __freeblock = __REINTERPRET_CAST(_FreeBlockHeader*, __result + __total_bytes);
- __freeblock->_M_end = __result + __bytes_to_get;
- _S_free_mem_blocks.push(__freeblock);
- }
- return __result;
-}
-
-# if defined (_STLP_DO_CLEAN_NODE_ALLOC)
-void __node_alloc_impl::_S_alloc_call()
-{ _STLP_ATOMIC_INCREMENT(&_S_alloc_counter()); }
-
-void __node_alloc_impl::_S_dealloc_call() {
- _STLP_VOLATILE __stl_atomic_t *pcounter = &_S_alloc_counter();
- if (_STLP_ATOMIC_DECREMENT(pcounter) == 0)
- _S_chunk_dealloc();
-}
-
-/* We deallocate all the memory chunks */
-void __node_alloc_impl::_S_chunk_dealloc() {
- // Note: The _Node_alloc_helper class ensures that this function
- // will only be called when the (shared) library is unloaded or the
- // process is shutdown. It's thus not possible that another thread
- // is currently trying to allocate a node (we're not thread-safe here).
- //
-
- // Clear the free blocks and all freelistst. This makes sure that if
- // for some reason more memory is allocated again during shutdown
- // (it'd also be really nasty to leave references to deallocated memory).
- _S_free_mem_blocks.clear();
- _S_heap_size = 0;
-
- for (size_t __i = 0; __i < _STLP_NFREELISTS; ++__i) {
- _S_free_list[__i].clear();
- }
-
- // Detach list of chunks and free them all
- _Obj* __chunk = _S_chunks.clear();
- while (__chunk != 0) {
- _Obj* __next = __chunk->_M_next;
- __stlp_delete_chunck(__chunk);
- __chunk = __next;
- }
-}
-# endif
-
-#endif
-
-#if defined (_STLP_DO_CLEAN_NODE_ALLOC)
-struct __node_alloc_cleaner {
- ~__node_alloc_cleaner()
- { __node_alloc_impl::_S_dealloc_call(); }
-};
-
-# if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
-_STLP_VOLATILE __stl_atomic_t& _STLP_CALL
-# else
-__stl_atomic_t& _STLP_CALL
-# endif
-__node_alloc_impl::_S_alloc_counter() {
- static _AllocCounter _S_counter = 1;
- static __node_alloc_cleaner _S_node_alloc_cleaner;
- return _S_counter;
-}
-#endif
-
-#if !defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
-_Node_alloc_obj * _STLP_VOLATILE
-__node_alloc_impl::_S_free_list[_STLP_NFREELISTS]
-= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-// The 16 zeros are necessary to make version 4.1 of the SunPro
-// compiler happy. Otherwise it appears to allocate too little
-// space for the array.
-#else
-_STLP_atomic_freelist __node_alloc_impl::_S_free_list[_STLP_NFREELISTS];
-_STLP_atomic_freelist __node_alloc_impl::_S_free_mem_blocks;
-#endif
-
-#if !defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
-char *__node_alloc_impl::_S_start_free = 0;
-char *__node_alloc_impl::_S_end_free = 0;
-#endif
-
-#if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
-_STLP_VOLATILE __add_atomic_t
-#else
-size_t
-#endif
-__node_alloc_impl::_S_heap_size = 0;
-
-#if defined (_STLP_DO_CLEAN_NODE_ALLOC)
-# if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION)
-_STLP_atomic_freelist __node_alloc_impl::_S_chunks;
-# else
-_Node_alloc_obj* __node_alloc_impl::_S_chunks = 0;
-# endif
-#endif
-
-void * _STLP_CALL __node_alloc::_M_allocate(size_t& __n)
-{ return __node_alloc_impl::_M_allocate(__n); }
-
-void _STLP_CALL __node_alloc::_M_deallocate(void *__p, size_t __n)
-{ __node_alloc_impl::_M_deallocate(__p, __n); }
-
-#if defined (_STLP_PTHREADS) && !defined (_STLP_NO_THREADS)
-
-# define _STLP_DATA_ALIGNMENT 8
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// *******************************************************
-// __perthread_alloc implementation
-union _Pthread_alloc_obj {
- union _Pthread_alloc_obj * __free_list_link;
- char __client_data[_STLP_DATA_ALIGNMENT]; /* The client sees this. */
-};
-
-// Pthread allocators don't appear to the client to have meaningful
-// instances. We do in fact need to associate some state with each
-// thread. That state is represented by _Pthread_alloc_per_thread_state.
-
-struct _Pthread_alloc_per_thread_state {
- typedef _Pthread_alloc_obj __obj;
- enum { _S_NFREELISTS = _MAX_BYTES / _STLP_DATA_ALIGNMENT };
-
- // Free list link for list of available per thread structures.
- // When one of these becomes available for reuse due to thread
- // termination, any objects in its free list remain associated
- // with it. The whole structure may then be used by a newly
- // created thread.
- _Pthread_alloc_per_thread_state() : __next(0)
- { memset((void *)__CONST_CAST(_Pthread_alloc_obj**, __free_list), 0, (size_t)_S_NFREELISTS * sizeof(__obj *)); }
- // Returns an object of size __n, and possibly adds to size n free list.
- void *_M_refill(size_t __n);
-
- _Pthread_alloc_obj* volatile __free_list[_S_NFREELISTS];
- _Pthread_alloc_per_thread_state *__next;
- // this data member is only to be used by per_thread_allocator, which returns memory to the originating thread.
- _STLP_mutex _M_lock;
-};
-
-// Pthread-specific allocator.
-class _Pthread_alloc_impl {
-public: // but only for internal use:
- typedef _Pthread_alloc_per_thread_state __state_type;
- typedef char value_type;
-
- // Allocates a chunk for nobjs of size size. nobjs may be reduced
- // if it is inconvenient to allocate the requested number.
- static char *_S_chunk_alloc(size_t __size, size_t &__nobjs, __state_type*);
-
- enum {_S_ALIGN = _STLP_DATA_ALIGNMENT};
-
- static size_t _S_round_up(size_t __bytes)
- { return (((__bytes) + (int)_S_ALIGN - 1) & ~((int)_S_ALIGN - 1)); }
- static size_t _S_freelist_index(size_t __bytes)
- { return (((__bytes) + (int)_S_ALIGN - 1) / (int)_S_ALIGN - 1); }
-
-private:
- // Chunk allocation state. And other shared state.
- // Protected by _S_chunk_allocator_lock.
- static _STLP_STATIC_MUTEX _S_chunk_allocator_lock;
- static char *_S_start_free;
- static char *_S_end_free;
- static size_t _S_heap_size;
- static __state_type *_S_free_per_thread_states;
- static pthread_key_t _S_key;
- static bool _S_key_initialized;
- // Pthread key under which per thread state is stored.
- // Allocator instances that are currently unclaimed by any thread.
- static void _S_destructor(void *instance);
- // Function to be called on thread exit to reclaim per thread
- // state.
- static __state_type *_S_new_per_thread_state();
-public:
- // Return a recycled or new per thread state.
- static __state_type *_S_get_per_thread_state();
-private:
- // ensure that the current thread has an associated
- // per thread state.
- class _M_lock;
- friend class _M_lock;
- class _M_lock {
- public:
- _M_lock () { _S_chunk_allocator_lock._M_acquire_lock(); }
- ~_M_lock () { _S_chunk_allocator_lock._M_release_lock(); }
- };
-
-public:
-
- /* n must be > 0 */
- static void * allocate(size_t& __n);
-
- /* p may not be 0 */
- static void deallocate(void *__p, size_t __n);
-
- // boris : versions for per_thread_allocator
- /* n must be > 0 */
- static void * allocate(size_t& __n, __state_type* __a);
-
- /* p may not be 0 */
- static void deallocate(void *__p, size_t __n, __state_type* __a);
-
- static void * reallocate(void *__p, size_t __old_sz, size_t& __new_sz);
-};
-
-/* Returns an object of size n, and optionally adds to size n free list.*/
-/* We assume that n is properly aligned. */
-/* We hold the allocation lock. */
-void *_Pthread_alloc_per_thread_state::_M_refill(size_t __n) {
- typedef _Pthread_alloc_obj __obj;
- size_t __nobjs = 128;
- char * __chunk = _Pthread_alloc_impl::_S_chunk_alloc(__n, __nobjs, this);
- __obj * volatile * __my_free_list;
- __obj * __result;
- __obj * __current_obj, * __next_obj;
- size_t __i;
-
- if (1 == __nobjs) {
- return __chunk;
- }
-
- __my_free_list = __free_list + _Pthread_alloc_impl::_S_freelist_index(__n);
-
- /* Build free list in chunk */
- __result = (__obj *)__chunk;
- *__my_free_list = __next_obj = (__obj *)(__chunk + __n);
- for (__i = 1; ; ++__i) {
- __current_obj = __next_obj;
- __next_obj = (__obj *)((char *)__next_obj + __n);
- if (__nobjs - 1 == __i) {
- __current_obj -> __free_list_link = 0;
- break;
- } else {
- __current_obj -> __free_list_link = __next_obj;
- }
- }
- return __result;
-}
-
-void _Pthread_alloc_impl::_S_destructor(void *__instance) {
- _M_lock __lock_instance; // Need to acquire lock here.
- _Pthread_alloc_per_thread_state* __s = (_Pthread_alloc_per_thread_state*)__instance;
- __s -> __next = _S_free_per_thread_states;
- _S_free_per_thread_states = __s;
-}
-
-_Pthread_alloc_per_thread_state* _Pthread_alloc_impl::_S_new_per_thread_state() {
- /* lock already held here. */
- if (0 != _S_free_per_thread_states) {
- _Pthread_alloc_per_thread_state *__result = _S_free_per_thread_states;
- _S_free_per_thread_states = _S_free_per_thread_states -> __next;
- return __result;
- }
- else {
- return new _Pthread_alloc_per_thread_state;
- }
-}
-
-_Pthread_alloc_per_thread_state* _Pthread_alloc_impl::_S_get_per_thread_state() {
- int __ret_code;
- __state_type* __result;
-
- if (_S_key_initialized && (__result = (__state_type*) pthread_getspecific(_S_key)))
- return __result;
-
- /*REFERENCED*/
- _M_lock __lock_instance; // Need to acquire lock here.
- if (!_S_key_initialized) {
- if (pthread_key_create(&_S_key, _S_destructor)) {
- _STLP_THROW_BAD_ALLOC; // failed
- }
- _S_key_initialized = true;
- }
-
- __result = _S_new_per_thread_state();
- __ret_code = pthread_setspecific(_S_key, __result);
- if (__ret_code) {
- if (__ret_code == ENOMEM) {
- _STLP_THROW_BAD_ALLOC;
- } else {
- // EINVAL
- _STLP_ABORT();
- }
- }
- return __result;
-}
-
-/* We allocate memory in large chunks in order to avoid fragmenting */
-/* the malloc heap too much. */
-/* We assume that size is properly aligned. */
-char *_Pthread_alloc_impl::_S_chunk_alloc(size_t __p_size, size_t &__nobjs, _Pthread_alloc_per_thread_state *__a) {
- typedef _Pthread_alloc_obj __obj;
- {
- char * __result;
- size_t __total_bytes;
- size_t __bytes_left;
- /*REFERENCED*/
- _M_lock __lock_instance; // Acquire lock for this routine
-
- __total_bytes = __p_size * __nobjs;
- __bytes_left = _S_end_free - _S_start_free;
- if (__bytes_left >= __total_bytes) {
- __result = _S_start_free;
- _S_start_free += __total_bytes;
- return __result;
- } else if (__bytes_left >= __p_size) {
- __nobjs = __bytes_left/__p_size;
- __total_bytes = __p_size * __nobjs;
- __result = _S_start_free;
- _S_start_free += __total_bytes;
- return __result;
- } else {
- size_t __bytes_to_get = 2 * __total_bytes + _S_round_up(_S_heap_size);
- // Try to make use of the left-over piece.
- if (__bytes_left > 0) {
- __obj * volatile * __my_free_list = __a->__free_list + _S_freelist_index(__bytes_left);
- ((__obj *)_S_start_free) -> __free_list_link = *__my_free_list;
- *__my_free_list = (__obj *)_S_start_free;
- }
-# ifdef _SGI_SOURCE
- // Try to get memory that's aligned on something like a
- // cache line boundary, so as to avoid parceling out
- // parts of the same line to different threads and thus
- // possibly different processors.
- {
- const int __cache_line_size = 128; // probable upper bound
- __bytes_to_get &= ~(__cache_line_size-1);
- _S_start_free = (char *)memalign(__cache_line_size, __bytes_to_get);
- if (0 == _S_start_free) {
- _S_start_free = (char *)__malloc_alloc::allocate(__bytes_to_get);
- }
- }
-# else /* !SGI_SOURCE */
- _S_start_free = (char *)__malloc_alloc::allocate(__bytes_to_get);
-# endif
- _S_heap_size += __bytes_to_get >> 4;
- _S_end_free = _S_start_free + __bytes_to_get;
- }
- }
- // lock is released here
- return _S_chunk_alloc(__p_size, __nobjs, __a);
-}
-
-
-/* n must be > 0 */
-void *_Pthread_alloc_impl::allocate(size_t& __n) {
- typedef _Pthread_alloc_obj __obj;
- __obj * volatile * __my_free_list;
- __obj * __result;
- __state_type* __a;
-
- if (__n > _MAX_BYTES) {
- return __malloc_alloc::allocate(__n);
- }
-
- __n = _S_round_up(__n);
- __a = _S_get_per_thread_state();
-
- __my_free_list = __a->__free_list + _S_freelist_index(__n);
- __result = *__my_free_list;
- if (__result == 0) {
- void *__r = __a->_M_refill(__n);
- return __r;
- }
- *__my_free_list = __result->__free_list_link;
- return __result;
-};
-
-/* p may not be 0 */
-void _Pthread_alloc_impl::deallocate(void *__p, size_t __n) {
- typedef _Pthread_alloc_obj __obj;
- __obj *__q = (__obj *)__p;
- __obj * volatile * __my_free_list;
- __state_type* __a;
-
- if (__n > _MAX_BYTES) {
- __malloc_alloc::deallocate(__p, __n);
- return;
- }
-
- __a = _S_get_per_thread_state();
-
- __my_free_list = __a->__free_list + _S_freelist_index(__n);
- __q -> __free_list_link = *__my_free_list;
- *__my_free_list = __q;
-}
-
-// boris : versions for per_thread_allocator
-/* n must be > 0 */
-void *_Pthread_alloc_impl::allocate(size_t& __n, __state_type* __a) {
- typedef _Pthread_alloc_obj __obj;
- __obj * volatile * __my_free_list;
- __obj * __result;
-
- if (__n > _MAX_BYTES) {
- return __malloc_alloc::allocate(__n);
- }
- __n = _S_round_up(__n);
-
- // boris : here, we have to lock per thread state, as we may be getting memory from
- // different thread pool.
- _STLP_auto_lock __lock(__a->_M_lock);
-
- __my_free_list = __a->__free_list + _S_freelist_index(__n);
- __result = *__my_free_list;
- if (__result == 0) {
- void *__r = __a->_M_refill(__n);
- return __r;
- }
- *__my_free_list = __result->__free_list_link;
- return __result;
-};
-
-/* p may not be 0 */
-void _Pthread_alloc_impl::deallocate(void *__p, size_t __n, __state_type* __a) {
- typedef _Pthread_alloc_obj __obj;
- __obj *__q = (__obj *)__p;
- __obj * volatile * __my_free_list;
-
- if (__n > _MAX_BYTES) {
- __malloc_alloc::deallocate(__p, __n);
- return;
- }
-
- // boris : here, we have to lock per thread state, as we may be returning memory from
- // different thread.
- _STLP_auto_lock __lock(__a->_M_lock);
-
- __my_free_list = __a->__free_list + _S_freelist_index(__n);
- __q -> __free_list_link = *__my_free_list;
- *__my_free_list = __q;
-}
-
-void *_Pthread_alloc_impl::reallocate(void *__p, size_t __old_sz, size_t& __new_sz) {
- void * __result;
- size_t __copy_sz;
-
- if (__old_sz > _MAX_BYTES && __new_sz > _MAX_BYTES) {
- return realloc(__p, __new_sz);
- }
-
- if (_S_round_up(__old_sz) == _S_round_up(__new_sz)) return __p;
- __result = allocate(__new_sz);
- __copy_sz = __new_sz > __old_sz? __old_sz : __new_sz;
- memcpy(__result, __p, __copy_sz);
- deallocate(__p, __old_sz);
- return __result;
-}
-
-_Pthread_alloc_per_thread_state* _Pthread_alloc_impl::_S_free_per_thread_states = 0;
-pthread_key_t _Pthread_alloc_impl::_S_key = 0;
-_STLP_STATIC_MUTEX _Pthread_alloc_impl::_S_chunk_allocator_lock _STLP_MUTEX_INITIALIZER;
-bool _Pthread_alloc_impl::_S_key_initialized = false;
-char *_Pthread_alloc_impl::_S_start_free = 0;
-char *_Pthread_alloc_impl::_S_end_free = 0;
-size_t _Pthread_alloc_impl::_S_heap_size = 0;
-
-void * _STLP_CALL _Pthread_alloc::allocate(size_t& __n)
-{ return _Pthread_alloc_impl::allocate(__n); }
-void _STLP_CALL _Pthread_alloc::deallocate(void *__p, size_t __n)
-{ _Pthread_alloc_impl::deallocate(__p, __n); }
-void * _STLP_CALL _Pthread_alloc::allocate(size_t& __n, __state_type* __a)
-{ return _Pthread_alloc_impl::allocate(__n, __a); }
-void _STLP_CALL _Pthread_alloc::deallocate(void *__p, size_t __n, __state_type* __a)
-{ _Pthread_alloc_impl::deallocate(__p, __n, __a); }
-void * _STLP_CALL _Pthread_alloc::reallocate(void *__p, size_t __old_sz, size_t& __new_sz)
-{ return _Pthread_alloc_impl::reallocate(__p, __old_sz, __new_sz); }
-_Pthread_alloc_per_thread_state* _STLP_CALL _Pthread_alloc::_S_get_per_thread_state()
-{ return _Pthread_alloc_impl::_S_get_per_thread_state(); }
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-#endif
-
-_STLP_END_NAMESPACE
-
-#undef _S_FREELIST_INDEX
diff --git a/src/bitset.cpp b/src/bitset.cpp
deleted file mode 100644
index 90f1799..0000000
--- a/src/bitset.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 1998
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include <bitset>
-
-_STLP_BEGIN_NAMESPACE
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// ------------------------------------------------------------
-// Lookup tables for find and count operations.
-
-size_t _Bs_G::_S_count(const unsigned char *__first,
- const unsigned char *__last)
-{
- static const unsigned char _bit_count[256] = {
- 0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */
- 2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */
- 2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */
- 4, /* 15 */ 1, /* 16 */ 2, /* 17 */ 2, /* 18 */ 3, /* 19 */
- 2, /* 20 */ 3, /* 21 */ 3, /* 22 */ 4, /* 23 */ 2, /* 24 */
- 3, /* 25 */ 3, /* 26 */ 4, /* 27 */ 3, /* 28 */ 4, /* 29 */
- 4, /* 30 */ 5, /* 31 */ 1, /* 32 */ 2, /* 33 */ 2, /* 34 */
- 3, /* 35 */ 2, /* 36 */ 3, /* 37 */ 3, /* 38 */ 4, /* 39 */
- 2, /* 40 */ 3, /* 41 */ 3, /* 42 */ 4, /* 43 */ 3, /* 44 */
- 4, /* 45 */ 4, /* 46 */ 5, /* 47 */ 2, /* 48 */ 3, /* 49 */
- 3, /* 50 */ 4, /* 51 */ 3, /* 52 */ 4, /* 53 */ 4, /* 54 */
- 5, /* 55 */ 3, /* 56 */ 4, /* 57 */ 4, /* 58 */ 5, /* 59 */
- 4, /* 60 */ 5, /* 61 */ 5, /* 62 */ 6, /* 63 */ 1, /* 64 */
- 2, /* 65 */ 2, /* 66 */ 3, /* 67 */ 2, /* 68 */ 3, /* 69 */
- 3, /* 70 */ 4, /* 71 */ 2, /* 72 */ 3, /* 73 */ 3, /* 74 */
- 4, /* 75 */ 3, /* 76 */ 4, /* 77 */ 4, /* 78 */ 5, /* 79 */
- 2, /* 80 */ 3, /* 81 */ 3, /* 82 */ 4, /* 83 */ 3, /* 84 */
- 4, /* 85 */ 4, /* 86 */ 5, /* 87 */ 3, /* 88 */ 4, /* 89 */
- 4, /* 90 */ 5, /* 91 */ 4, /* 92 */ 5, /* 93 */ 5, /* 94 */
- 6, /* 95 */ 2, /* 96 */ 3, /* 97 */ 3, /* 98 */ 4, /* 99 */
- 3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */
- 4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */
- 5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */
- 5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */
- 4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */
- 6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */
- 2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */
- 4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */
- 3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */
- 3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */
- 4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */
- 5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */
- 2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */
- 4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */
- 4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */
- 6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */
- 4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */
- 5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */
- 6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */
- 4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */
- 3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */
- 5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */
- 4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */
- 6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */
- 5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */
- 4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */
- 5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */
- 6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */
- 4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */
- 6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */
- 6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */
- 8 /* 255 */
- };
-
- size_t __result(0);
- while ( __first < __last ) {
- __result += _bit_count[*(__first++)];
- }
- return __result;
-}
-
-unsigned char _Bs_G::_S_first_one(unsigned char __byte)
-{
- static const unsigned char _first_one[256] = {
- 0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */
- 0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */
- 1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */
- 0, /* 15 */ 4, /* 16 */ 0, /* 17 */ 1, /* 18 */ 0, /* 19 */
- 2, /* 20 */ 0, /* 21 */ 1, /* 22 */ 0, /* 23 */ 3, /* 24 */
- 0, /* 25 */ 1, /* 26 */ 0, /* 27 */ 2, /* 28 */ 0, /* 29 */
- 1, /* 30 */ 0, /* 31 */ 5, /* 32 */ 0, /* 33 */ 1, /* 34 */
- 0, /* 35 */ 2, /* 36 */ 0, /* 37 */ 1, /* 38 */ 0, /* 39 */
- 3, /* 40 */ 0, /* 41 */ 1, /* 42 */ 0, /* 43 */ 2, /* 44 */
- 0, /* 45 */ 1, /* 46 */ 0, /* 47 */ 4, /* 48 */ 0, /* 49 */
- 1, /* 50 */ 0, /* 51 */ 2, /* 52 */ 0, /* 53 */ 1, /* 54 */
- 0, /* 55 */ 3, /* 56 */ 0, /* 57 */ 1, /* 58 */ 0, /* 59 */
- 2, /* 60 */ 0, /* 61 */ 1, /* 62 */ 0, /* 63 */ 6, /* 64 */
- 0, /* 65 */ 1, /* 66 */ 0, /* 67 */ 2, /* 68 */ 0, /* 69 */
- 1, /* 70 */ 0, /* 71 */ 3, /* 72 */ 0, /* 73 */ 1, /* 74 */
- 0, /* 75 */ 2, /* 76 */ 0, /* 77 */ 1, /* 78 */ 0, /* 79 */
- 4, /* 80 */ 0, /* 81 */ 1, /* 82 */ 0, /* 83 */ 2, /* 84 */
- 0, /* 85 */ 1, /* 86 */ 0, /* 87 */ 3, /* 88 */ 0, /* 89 */
- 1, /* 90 */ 0, /* 91 */ 2, /* 92 */ 0, /* 93 */ 1, /* 94 */
- 0, /* 95 */ 5, /* 96 */ 0, /* 97 */ 1, /* 98 */ 0, /* 99 */
- 2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */
- 0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */
- 1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */
- 0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */
- 3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */
- 0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */
- 1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */
- 0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */
- 2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */
- 0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */
- 1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */
- 0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */
- 5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */
- 0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */
- 1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */
- 0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */
- 2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */
- 0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */
- 1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */
- 0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */
- 3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */
- 0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */
- 1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */
- 0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */
- 2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */
- 0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */
- 1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */
- 0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */
- 4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */
- 0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */
- 1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */
- 0, /* 255 */
- };
- return _first_one[__byte];
-}
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-_STLP_END_NAMESPACE
diff --git a/src/c_locale.c b/src/c_locale.c
deleted file mode 100644
index 376e22e..0000000
--- a/src/c_locale.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include "c_locale.h"
-
-#if defined (_STLP_WIN32) && !defined (_STLP_WCE)
-# include "c_locale_win32/c_locale_win32.c"
-#elif defined (_STLP_USE_GLIBC2_LOCALIZATION)
-# include "c_locale_glibc/c_locale_glibc2.c" /* glibc 2.2 and newer */
-#else
-# include "c_locale_dummy/c_locale_dummy.c"
-#endif
diff --git a/src/c_locale.h b/src/c_locale.h
deleted file mode 100644
index 36d9961..0000000
--- a/src/c_locale.h
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-/*
- * It is impossible to write the C++ locale library in terms of locales
- * as defined in the C standard. Instead, we write the C++ locale and I/O
- * library in terms of a low level C-like interface. This file defines
- * that interface.
- *
- * The low-level locale interface can't be written portably; there
- * must be a version of it for each platform that the C++ library
- * is ported to. On many systems this interface may be a thin wrapper
- * for existing functionality.
- */
-
-#ifndef _STLP_C_LOCALE_IMPL_H
-#define _STLP_C_LOCALE_IMPL_H
-
-#include "stlport_prefix.h"
-
-#include <wchar.h> /* for mbstate_t */
-#include <stl/c_locale.h>
-
-struct _Locale_name_hint;
-
-#if defined (_GNU_SOURCE) && defined (__GLIBC__) && \
- ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
-# define _STLP_USE_GLIBC2_LOCALIZATION
-# include <nl_types.h>
-typedef nl_catd nl_catd_type;
-#else
-typedef int nl_catd_type;
-#endif
-
-/*
- * A number: the maximum length of a simple locale name.
- * (i.e. a name like like en_US, as opposed to a name like
- * en_US/de_AT/de_AT/es_MX/en_US/en_US) */
-#define _Locale_MAX_SIMPLE_NAME 256
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Typedefs:
- */
-typedef unsigned short int _Locale_mask_t;
-
-/* Function called during STLport library load phase. Might contain any
- * code necessary to the platform localization layer.
- */
-void _Locale_init(void);
-
-/* Function called during STLport library unload. Might contain any
- * code necessary to the platform localization layer.
- */
-void _Locale_final(void);
-
-/* Create a category of the locale with the given name.
- *
- * The char* argument is a simple (not a composite) locale name, which may
- * neither be an empty string nor a null pointer.
- *
- * These functions return NULL to indicate failure. Failure reason should be reported
- * using the __err_code pointer.
- */
-struct _Locale_ctype* _Locale_ctype_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
-struct _Locale_codecvt* _Locale_codecvt_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
-struct _Locale_numeric* _Locale_numeric_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
-struct _Locale_time* _Locale_time_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
-struct _Locale_collate* _Locale_collate_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
-struct _Locale_monetary* _Locale_monetary_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
-struct _Locale_messages* _Locale_messages_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
-
-/* Give error reason on failure of one of the _Locale_*_create functions. Available
- * reasons are:
- * 0: No specific error reason has been reported.
- * 1: No platform support for the given facet.
- * 2: Unknown locale name
- * 3: No platform API for localization support.
- * 4: No more memory
- */
-#define _STLP_LOC_UNDEFINED 0
-#define _STLP_LOC_UNSUPPORTED_FACET_CATEGORY 1
-#define _STLP_LOC_UNKNOWN_NAME 2
-#define _STLP_LOC_NO_PLATFORM_SUPPORT 3
-#define _STLP_LOC_NO_MEMORY 4
-
-/* Release a category of a locale
- *
- * These functions are used to release a category acquired with the
- * according _Locale_*_create() functions.
- */
-void _Locale_ctype_destroy(struct _Locale_ctype *);
-void _Locale_codecvt_destroy(struct _Locale_codecvt *);
-void _Locale_numeric_destroy(struct _Locale_numeric *);
-void _Locale_time_destroy(struct _Locale_time *);
-void _Locale_collate_destroy(struct _Locale_collate *);
-void _Locale_monetary_destroy(struct _Locale_monetary *);
-void _Locale_messages_destroy(struct _Locale_messages *);
-
-/*
- * Returns the name of the user's default locale in each
- * category, as a null-terminated string. A NULL value
- * means the default "C" locale.
- */
-const char * _Locale_ctype_default(char * __buf);
-const char * _Locale_numeric_default(char * __buf);
-const char * _Locale_time_default(char * __buf);
-const char * _Locale_collate_default(char * __buf);
-const char * _Locale_monetary_default(char * __buf);
-const char * _Locale_messages_default(char * __buf);
-
-/* Retrieve the name of the given category
- *
- * __buf points to a buffer that can hold at least _Locale_MAX_SIMPLE_NAME
- * characters. These functions store the name, as a null-terminated
- * string, in __buf. This function can't fail, at worst name is truncated.
- */
-char const* _Locale_ctype_name(const struct _Locale_ctype *, char* __buf);
-char const* _Locale_codecvt_name(const struct _Locale_codecvt *, char* __buf);
-char const* _Locale_numeric_name(const struct _Locale_numeric *, char* __buf);
-char const* _Locale_time_name(const struct _Locale_time *, char* __buf);
-char const* _Locale_collate_name(const struct _Locale_collate *, char* __buf);
-char const* _Locale_monetary_name(const struct _Locale_monetary *, char* __buf);
-char const* _Locale_messages_name(const struct _Locale_messages *, char* __buf);
-
-/*
- * cname is a (possibly composite) locale name---i.e. a name that can
- * be passed to setlocale. __buf points to an array large enough to
- * store at least _Locale_MAX_SIMPLE_NAME characters, and each of these
- * functions extracts the name of a single category, stores it in buf
- * as a null-terminated string, and returns buf.
- */
-char const* _Locale_extract_ctype_name(const char *cname, char *__buf,
- struct _Locale_name_hint* __hint, int *__err_code);
-char const* _Locale_extract_numeric_name(const char *cname, char *__buf,
- struct _Locale_name_hint* __hint, int *__err_code);
-char const* _Locale_extract_time_name(const char *cname, char *__buf,
- struct _Locale_name_hint* __hint, int *__err_code);
-char const* _Locale_extract_collate_name(const char *cname, char *__buf,
- struct _Locale_name_hint* __hint, int *__err_code);
-char const* _Locale_extract_monetary_name(const char *cname, char *__buf,
- struct _Locale_name_hint* __hint, int *__err_code);
-char const* _Locale_extract_messages_name(const char *cname, char *__buf,
- struct _Locale_name_hint* __hint, int *__err_code);
-
-/* Functions to improve locale creation process. For some locale API (Win32)
- * you need to find a locale identification from the name which can be a
- * rather expensive operation especially if you do so for all facets of a
- * locale. Those functions can be used to extract from a API dependent facet
- * struct the information necessary to skip this lookup process for other
- * facets creation. If not supported those function should return NULL.
- */
-struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype*);
-struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric*);
-struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time*);
-struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate*);
-struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary*);
-struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages*);
-
-/*
- * FUNCTIONS THAT USE CTYPE
- */
-
-/*
- * Narrow character functions:
- */
-
-/*
- * Returns a pointer to the beginning of the ctype table. The table is
- * at least 257 bytes long; if p is the pointer returned by this
- * function, then p[c] is valid if c is EOF or if p is any value of
- * type unsigned char.
- */
-const _Locale_mask_t * _Locale_ctype_table(struct _Locale_ctype *);
-
-/*
- * c is either EOF, or an unsigned char value.
- */
-int _Locale_toupper(struct _Locale_ctype *, int /* c */);
-int _Locale_tolower(struct _Locale_ctype *, int /* c */);
-
-
-#ifndef _STLP_NO_WCHAR_T
-/*
- * Wide character functions:
- */
-_Locale_mask_t _WLocale_ctype(struct _Locale_ctype *, wint_t, _Locale_mask_t);
-wint_t _WLocale_tolower(struct _Locale_ctype *, wint_t);
-wint_t _WLocale_toupper(struct _Locale_ctype *, wint_t);
-
-/*
- * Multibyte functions:
- */
-
-/*
- * Returns the number of bytes of the longest allowed multibyte
- * character in the current encoding.
- */
-int _WLocale_mb_cur_max(struct _Locale_codecvt *);
-
-/*
- * Returns the number of bytes of the shortest allowed multibyte
- * character in the current encoding.
- */
-int _WLocale_mb_cur_min(struct _Locale_codecvt *);
-
-/*
- * Returns 1 if the current multibyte encoding is stateless
- * and does not require the use of an mbstate_t value.
- */
-int _WLocale_is_stateless(struct _Locale_codecvt *);
-
-/*
- * Almost identical to mbrtowc, from 4.6.5.3.2 of NA1. The only
- * important difference is that mbrtowc treats null wide characters
- * as special, and we don't. Specifically: examines the characters
- * in [from, from + n), extracts a single wide character, and stores
- * it in *to. Modifies shift_state if appropriate. The return value,
- * which is always positive, is the number of characters extracted from
- * the input sequence. Return value is (size_t) -1 if there was an
- * encoding error in the input sequence, and (size_t) -2 if
- * [from, from + n) is correct but not complete. None of the pointer
- * arguments may be null pointers.
- */
-size_t _WLocale_mbtowc(struct _Locale_codecvt *,
- wchar_t * /* to */,
- const char * /* from */, size_t /* n */,
- mbstate_t *);
-
-/*
- * Again, very similar to wcrtomb. The differences are that (1) it
- * doesn't treat null characters as special; and (2) it stores at most
- * n characters. Converts c to a multibyte sequence, stores that
- * sequence in the array 'to', and returns the length of the sequence.
- * Modifies shift_state if appropriate. The return value is (size_t) -1
- * if c is not a valid wide character, and (size_t) -2 if the length of
- * the multibyte character sequence is greater than n.
- */
-size_t _WLocale_wctomb(struct _Locale_codecvt *,
- char *, size_t,
- const wchar_t,
- mbstate_t *);
-
-/*
- * Inserts whatever characters are necessary to restore st to an
- * initial shift state. Sets *next to buf + m, where m is the number
- * of characters inserted. (0 <= m <= n.) Returns m to indicate
- * success, (size_t) -1 to indicate error, (size_t) -2 to indicate
- * partial success (more than n characters needed). For success or partial
- * success, sets *next to buf + m.
- */
-size_t _WLocale_unshift(struct _Locale_codecvt *,
- mbstate_t *,
- char *, size_t, char **);
-#endif
-
-/*
- * FUNCTIONS THAT USE COLLATE
- */
-
-/*
- * Compares the two sequences [s1, s1 + n1) and [s2, s2 + n2). Neither
- * sequence is assumed to be null-terminated, and null characters
- * aren't special. If the two sequences are the same up through
- * min(n1, n2), then the sequence that compares less is whichever one
- * is shorter.
- */
-int _Locale_strcmp(struct _Locale_collate *,
- const char * /* s1 */, size_t /* n1 */,
- const char * /* s2 */, size_t /* n2 */);
-#ifndef _STLP_NO_WCHAR_T
-int _WLocale_strcmp(struct _Locale_collate *,
- const wchar_t * /* s1 */, size_t /* n1 */,
- const wchar_t * /* s2 */, size_t /* n2 */);
-#endif
-
-/*
- * Creates a transformed version of the string [s2, s2 + n2). The
- * string may contain embedded null characters; nulls aren't special.
- * The transformed string begins at s1, and contains at most n1
- * characters. The return value is the length of the transformed
- * string. If the return value is greater than n1 then this is an
- * error condition: it indicates that there wasn't enough space. In
- * that case, the contents of [s1, s1 + n1) is unspecified.
-*/
-size_t _Locale_strxfrm(struct _Locale_collate *,
- char * /* s1 */, size_t /* n1 */,
- const char * /* s2 */, size_t /* n2 */);
-
-#ifndef _STLP_NO_WCHAR_T
-size_t _WLocale_strxfrm(struct _Locale_collate *,
- wchar_t * /* s1 */, size_t /* n1 */,
- const wchar_t * /* s2 */, size_t /* n2 */);
-#endif
-
-
-/*
- * FUNCTIONS THAT USE NUMERIC
- */
-
-/*
- * Equivalent to the first three fields in struct lconv. (C standard,
- * section 7.4.)
- */
-char _Locale_decimal_point(struct _Locale_numeric *);
-char _Locale_thousands_sep(struct _Locale_numeric *);
-const char * _Locale_grouping(struct _Locale_numeric *);
-
-#ifndef _STLP_NO_WCHAR_T
-wchar_t _WLocale_decimal_point(struct _Locale_numeric *);
-wchar_t _WLocale_thousands_sep(struct _Locale_numeric *);
-#endif
-
-/*
- * Return "true" and "false" in English locales, and something
- * appropriate in non-English locales.
- */
-const char * _Locale_true(struct _Locale_numeric *);
-const char * _Locale_false(struct _Locale_numeric *);
-
-#ifndef _STLP_NO_WCHAR_T
-const wchar_t * _WLocale_true(struct _Locale_numeric *, wchar_t* /* buf */, size_t /* bufSize */);
-const wchar_t * _WLocale_false(struct _Locale_numeric *, wchar_t* /* buf */, size_t /* bufSize */);
-#endif
-
-/*
- * FUNCTIONS THAT USE MONETARY
- */
-
-/*
- * Return the obvious fields of struct lconv.
- */
-const char * _Locale_int_curr_symbol(struct _Locale_monetary *);
-const char * _Locale_currency_symbol(struct _Locale_monetary *);
-char _Locale_mon_decimal_point(struct _Locale_monetary *);
-char _Locale_mon_thousands_sep(struct _Locale_monetary *);
-const char * _Locale_mon_grouping(struct _Locale_monetary *);
-const char * _Locale_positive_sign(struct _Locale_monetary *);
-const char * _Locale_negative_sign(struct _Locale_monetary *);
-char _Locale_int_frac_digits(struct _Locale_monetary *);
-char _Locale_frac_digits(struct _Locale_monetary *);
-int _Locale_p_cs_precedes(struct _Locale_monetary *);
-int _Locale_p_sep_by_space(struct _Locale_monetary *);
-int _Locale_p_sign_posn(struct _Locale_monetary *);
-int _Locale_n_cs_precedes(struct _Locale_monetary *);
-int _Locale_n_sep_by_space(struct _Locale_monetary *);
-int _Locale_n_sign_posn(struct _Locale_monetary *);
-
-#ifndef _STLP_NO_WCHAR_T
-const wchar_t * _WLocale_int_curr_symbol(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */);
-const wchar_t * _WLocale_currency_symbol(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */);
-wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary *);
-wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary *);
-const wchar_t * _WLocale_positive_sign(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */);
-const wchar_t * _WLocale_negative_sign(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */);
-#endif
-
-/*
- * FUNCTIONS THAT USE TIME
- */
-
-/*
- * month is in the range [0, 12).
- */
-const char * _Locale_full_monthname(struct _Locale_time *, int /* month */);
-const char * _Locale_abbrev_monthname(struct _Locale_time *, int /* month */);
-
-#ifndef _STLP_NO_WCHAR_T
-const wchar_t * _WLocale_full_monthname(struct _Locale_time *, int /* month */,
- wchar_t* /* buf */, size_t /* bufSize */);
-const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time *, int /* month */,
- wchar_t* /* buf */, size_t /* bufSize */);
-#endif
-
-/*
- * day is in the range [0, 7). Sunday is 0.
- */
-const char * _Locale_full_dayofweek(struct _Locale_time *, int /* day */);
-const char * _Locale_abbrev_dayofweek(struct _Locale_time *, int /* day */);
-
-#ifndef _STLP_NO_WCHAR_T
-const wchar_t * _WLocale_full_dayofweek(struct _Locale_time *, int /* day */,
- wchar_t* /* buf */, size_t /* bufSize */);
-const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time *, int /* day */,
- wchar_t* /* buf */, size_t /* bufSize */);
-#endif
-
-const char * _Locale_d_t_fmt(struct _Locale_time *);
-const char * _Locale_d_fmt(struct _Locale_time *);
-const char * _Locale_t_fmt(struct _Locale_time *);
-const char * _Locale_long_d_t_fmt(struct _Locale_time*);
-const char * _Locale_long_d_fmt(struct _Locale_time*);
-
-const char * _Locale_am_str(struct _Locale_time *);
-const char * _Locale_pm_str(struct _Locale_time *);
-
-#ifndef _STLP_NO_WCHAR_T
-const wchar_t * _WLocale_am_str(struct _Locale_time *,
- wchar_t* /* buf */, size_t /* bufSize */);
-const wchar_t * _WLocale_pm_str(struct _Locale_time *,
- wchar_t* /* buf */, size_t /* bufSize */);
-#endif
-
-/*
- * FUNCTIONS THAT USE MESSAGES
- */
-
-/*
- * Very similar to catopen, except that it uses the given message
- * category to determine which catalog to open.
- */
-nl_catd_type _Locale_catopen(struct _Locale_messages*, const char*);
-
-/* Complementary to _Locale_catopen.
- * The catalog must be a value that was returned by a previous call
- * to _Locale_catopen.
- */
-void _Locale_catclose(struct _Locale_messages*, nl_catd_type);
-
-/*
- * Returns a string, identified by a set index and a message index,
- * from an opened message catalog. Returns the supplied default if
- * no such string exists.
- */
-const char * _Locale_catgets(struct _Locale_messages *, nl_catd_type,
- int, int,const char *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _STLP_C_LOCALE_IMPL_H */
diff --git a/src/c_locale_dummy/c_locale_dummy.c b/src/c_locale_dummy/c_locale_dummy.c
deleted file mode 100644
index 709c35e..0000000
--- a/src/c_locale_dummy/c_locale_dummy.c
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-/* This is a "stub" implementation of the "c_locale.h" interface,
- intended for operating systems where we have not yet written
- a real implementation. A C++ library using this stub implementation
- is still standard-conforming, since the C++ standard does not require
- that any locales other than "C" be supported.
-*/
-
-#include <string.h>
-#include <wchar.h>
-#include <ctype.h>
-#include <wctype.h>
-#include <limits.h>
-
-#if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
-# define _STLP_STRNCPY(D, DS, S, C) strncpy_s(D, DS, S, C)
-# if !defined (_STLP_NO_WCHAR_T)
-# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy_s(D, DS, S, C)
-# endif
-#else
-# define _STLP_STRNCPY(D, DS, S, C) strncpy(D, S, C)
-# if !defined (_STLP_NO_WCHAR_T)
-# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy(D, S, C)
-# endif
-#endif
-
-#define UNUSED __attribute__((__unused__))
-
-static const char *_C_name = "C";
-static const char *_empty_str = "";
-#ifndef _STLP_NO_WCHAR_T
-#if defined(WCHAR_MAX) && WCHAR_MAX == 255
-static const wchar_t *_empty_wstr = "";
-#else
-static const wchar_t *_empty_wstr = L"";
-#endif
-#endif
-
-static _Locale_mask_t ctable[256];
-
-/* Framework functions */
-
-void _Locale_init(void) {
- /* Ctype table for the ASCII character set. */
- char c;
- /* We might never reach 128 when char is signed. */
- for (c = 0; /* c != 128 */; ++c) {
- if (isalpha(c)) ctable[(unsigned char)c] |= _Locale_ALPHA;
- if (iscntrl(c)) ctable[(unsigned char)c] |= _Locale_CNTRL;
- if (isdigit(c)) ctable[(unsigned char)c] |= _Locale_DIGIT;
- if (isprint(c)) ctable[(unsigned char)c] |= _Locale_PRINT;
- if (ispunct(c)) ctable[(unsigned char)c] |= _Locale_PUNCT;
- if (isspace(c)) ctable[(unsigned char)c] |= _Locale_SPACE;
- if (isxdigit(c)) ctable[(unsigned char)c] |= _Locale_XDIGIT;
- if (isupper(c)) ctable[(unsigned char)c] |= _Locale_UPPER;
- if (islower(c)) ctable[(unsigned char)c] |= _Locale_LOWER;
- if (c == 127) break;
- }
-
- /* ASCII is a 7-bit code, so everything else is non-ASCII. */
- memset(&(ctable[128]), 0, 128 * sizeof(_Locale_mask_t));
-}
-
-void _Locale_final(void)
-{}
-
-void* _Locale_create(const char* name, int *__err_code) {
- if (name[0] == 'C' && name[1] == 0)
- { return (void*)0x1; }
- *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
-}
-
-struct _Locale_ctype* _Locale_ctype_create(const char *name,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return (struct _Locale_ctype*)_Locale_create(name, __err_code); }
-
-struct _Locale_codecvt* _Locale_codecvt_create(const char *name,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return (struct _Locale_codecvt*)_Locale_create(name, __err_code); }
-
-struct _Locale_numeric* _Locale_numeric_create(const char *name,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return (struct _Locale_numeric*)_Locale_create(name, __err_code); }
-
-struct _Locale_time* _Locale_time_create(const char *name,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return (struct _Locale_time*)_Locale_create(name, __err_code); }
-
-struct _Locale_collate* _Locale_collate_create(const char *name,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return (struct _Locale_collate*)_Locale_create(name, __err_code); }
-
-struct _Locale_monetary* _Locale_monetary_create(const char *name,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return (struct _Locale_monetary*)_Locale_create(name, __err_code); }
-
-struct _Locale_messages* _Locale_messages_create(const char *name,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return (struct _Locale_messages*)_Locale_create(name, __err_code); }
-
-const char *_Locale_ctype_default(char* buf UNUSED) { return _C_name; }
-const char *_Locale_numeric_default(char * buf UNUSED) { return _C_name; }
-const char *_Locale_time_default(char* buf UNUSED) { return _C_name; }
-const char *_Locale_collate_default(char* buf UNUSED) { return _C_name; }
-const char *_Locale_monetary_default(char* buf UNUSED) { return _C_name; }
-const char *_Locale_messages_default(char* buf UNUSED) { return _C_name; }
-
-char const* _Locale_ctype_name(const struct _Locale_ctype *lctype UNUSED, char* buf UNUSED)
-{ return _C_name; }
-
-char const* _Locale_codecvt_name(const struct _Locale_codecvt *lcodecvt UNUSED, char* buf UNUSED)
-{ return _C_name; }
-
-char const* _Locale_numeric_name(const struct _Locale_numeric *lnum UNUSED, char* buf UNUSED)
-{ return _C_name; }
-
-char const* _Locale_time_name(const struct _Locale_time *ltime UNUSED, char* buf UNUSED)
-{ return _C_name; }
-
-char const* _Locale_collate_name(const struct _Locale_collate *lcol UNUSED, char* buf UNUSED)
-{ return _C_name; }
-
-char const* _Locale_monetary_name(const struct _Locale_monetary *lmon UNUSED, char* buf UNUSED)
-{ return _C_name; }
-
-char const* _Locale_messages_name(const struct _Locale_messages *lmes UNUSED, char* buf UNUSED)
-{ return _C_name; }
-
-void _Locale_ctype_destroy(struct _Locale_ctype *lctype UNUSED) {}
-void _Locale_codecvt_destroy(struct _Locale_codecvt *lcodecvt UNUSED) {}
-void _Locale_numeric_destroy(struct _Locale_numeric *lnum UNUSED) {}
-void _Locale_time_destroy(struct _Locale_time *ltime UNUSED) {}
-void _Locale_collate_destroy(struct _Locale_collate *lcol UNUSED) {}
-void _Locale_monetary_destroy(struct _Locale_monetary *lmon UNUSED) {}
-void _Locale_messages_destroy(struct _Locale_messages *lmes UNUSED) {}
-
-static char const* _Locale_extract_name(const char* name, int *__err_code) {
- // When the request is the default locale or the "C" locale we answer "C".
- if (name[0] == 0 ||
- (name[0] == 'C' && name[1] == 0))
- { return _C_name; }
- *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
-}
-
-char const* _Locale_extract_ctype_name(const char *name,
- char *buf UNUSED,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return _Locale_extract_name(name, __err_code); }
-
-char const* _Locale_extract_numeric_name(const char *name,
- char *buf UNUSED,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return _Locale_extract_name(name, __err_code); }
-
-char const* _Locale_extract_time_name(const char *name,
- char *buf UNUSED,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return _Locale_extract_name(name, __err_code); }
-
-char const* _Locale_extract_collate_name(const char *name,
- char *buf UNUSED,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return _Locale_extract_name(name, __err_code); }
-
-char const* _Locale_extract_monetary_name(const char *name,
- char *buf UNUSED,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return _Locale_extract_name(name, __err_code); }
-
-char const* _Locale_extract_messages_name(const char *name,
- char *buf UNUSED,
- struct _Locale_name_hint* hint UNUSED,
- int *__err_code)
-{ return _Locale_extract_name(name, __err_code); }
-
-struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype* ctype UNUSED)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric* numeric UNUSED)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time* time UNUSED)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate* collate UNUSED)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary* monetary UNUSED)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages* messages UNUSED)
-{ return 0; }
-
-/* ctype */
-const _Locale_mask_t* _Locale_ctype_table(struct _Locale_ctype* lctype) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lctype)
- return ctable;
-}
-
-int _Locale_toupper(struct _Locale_ctype*lctype UNUSED, int c)
-{ return toupper(c); }
-
-int _Locale_tolower(struct _Locale_ctype*lctype UNUSED, int c)
-{ return tolower(c); }
-
-#ifndef _STLP_NO_WCHAR_T
-_Locale_mask_t _WLocale_ctype(struct _Locale_ctype *lctype UNUSED, wint_t wc, _Locale_mask_t mask) {
- _Locale_mask_t ret = 0;
- if ((mask & _Locale_ALPHA) != 0 && iswalpha(wc))
- ret |= _Locale_ALPHA;
-
- if ((mask & _Locale_CNTRL) != 0 && iswcntrl(wc))
- ret |= _Locale_CNTRL;
-
- if ((mask & _Locale_DIGIT) != 0 && iswdigit(wc))
- ret |= _Locale_DIGIT;
-
- if ((mask & _Locale_PRINT) != 0 && iswprint(wc))
- ret |= _Locale_PRINT;
-
- if ((mask & _Locale_PUNCT) != 0 && iswpunct(wc))
- ret |= _Locale_PUNCT;
-
- if ((mask & _Locale_SPACE) != 0 && iswspace(wc))
- ret |= _Locale_SPACE;
-
- if ((mask & _Locale_XDIGIT) != 0 && iswxdigit(wc))
- ret |= _Locale_XDIGIT;
-
- if ((mask & _Locale_UPPER) != 0 && iswupper(wc))
- ret |= _Locale_UPPER;
-
- if ((mask & _Locale_LOWER) != 0 && iswlower(wc))
- ret |= _Locale_LOWER;
-
- return ret;
-}
-
-wint_t _WLocale_tolower(struct _Locale_ctype *lctype UNUSED, wint_t wc)
-{ return towlower(wc); }
-
-wint_t _WLocale_toupper(struct _Locale_ctype *lctype UNUSED, wint_t wc)
-{ return towupper(wc); }
-
-int _WLocale_mb_cur_max (struct _Locale_codecvt *lcodecvt UNUSED) { return 1; }
-int _WLocale_mb_cur_min (struct _Locale_codecvt *lcodecvt UNUSED) { return 1; }
-int _WLocale_is_stateless (struct _Locale_codecvt *lcodecvt UNUSED) { return 1; }
-
-size_t _WLocale_mbtowc(struct _Locale_codecvt *lcodecvt UNUSED,
- wchar_t *to,
- const char *from, size_t n UNUSED,
- mbstate_t *st UNUSED)
-{ *to = *from; return 1; }
-
-size_t _WLocale_wctomb(struct _Locale_codecvt *lcodecvt UNUSED,
- char *to, size_t n UNUSED,
- const wchar_t c,
- mbstate_t *st UNUSED)
-{ *to = (char)c; return 1; }
-
-size_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt UNUSED,
- mbstate_t *st UNUSED,
- char *buf, size_t n UNUSED, char ** next)
-{ *next = buf; return 0; }
-#endif
-
-/* Collate */
- int _Locale_strcmp(struct _Locale_collate* lcol UNUSED,
- const char* s1, size_t n1, const char* s2, size_t n2) {
- int ret = 0;
- char buf1[64], buf2[64];
- while (n1 > 0 || n2 > 0) {
- size_t bufsize1 = n1 < 63 ? n1 : 63;
- size_t bufsize2 = n2 < 63 ? n2 : 63;
- _STLP_STRNCPY(buf1, 64, s1, bufsize1); buf1[bufsize1] = 0;
- _STLP_STRNCPY(buf2, 64, s2, bufsize2); buf2[bufsize2] = 0;
-
- ret = strcmp(buf1, buf2);
- if (ret != 0) return ret < 0 ? -1 : 1;
- s1 += bufsize1; n1 -= bufsize1;
- s2 += bufsize2; n2 -= bufsize2;
- }
- return ret == 0 ? 0 : (ret < 0 ? -1 : 1);
-}
-
-#ifndef _STLP_NO_WCHAR_T
-
-int _WLocale_strcmp(struct _Locale_collate* lcol UNUSED,
- const wchar_t* s1, size_t n1, const wchar_t* s2, size_t n2) {
- int ret = 0;
- wchar_t buf1[64], buf2[64];
- while (n1 > 0 || n2 > 0) {
- size_t bufsize1 = n1 < 63 ? n1 : 63;
- size_t bufsize2 = n2 < 63 ? n2 : 63;
- _STLP_WCSNCPY(buf1, 64, s1, bufsize1); buf1[bufsize1] = 0;
- _STLP_WCSNCPY(buf2, 64, s2, bufsize2); buf2[bufsize2] = 0;
-
- ret = wcscmp(buf1, buf2);
- if (ret != 0) return ret < 0 ? -1 : 1;
- s1 += bufsize1; n1 -= bufsize1;
- s2 += bufsize2; n2 -= bufsize2;
- }
- return ret == 0 ? 0 : (ret < 0 ? -1 : 1);
-}
-
-#endif
-
-size_t _Locale_strxfrm(struct _Locale_collate* lcol UNUSED,
- char* dest, size_t dest_n,
- const char* src, size_t src_n) {
- if (dest != 0) {
- _STLP_STRNCPY(dest, dest_n, src, dest_n - 1); dest[dest_n - 1] = 0;
- }
- return src_n;
-}
-
-#ifndef _STLP_NO_WCHAR_T
-
-size_t _WLocale_strxfrm(struct _Locale_collate* lcol UNUSED,
- wchar_t* dest, size_t dest_n,
- const wchar_t* src, size_t src_n) {
- if (dest != 0) {
- _STLP_WCSNCPY(dest, dest_n, src, dest_n - 1); dest[dest_n - 1] = 0;
- }
- return src_n;
-}
-
-#endif
-
-/* Numeric */
-
-char _Locale_decimal_point(struct _Locale_numeric* lnum UNUSED)
-{ return '.'; }
-char _Locale_thousands_sep(struct _Locale_numeric* lnum UNUSED)
-{ return ','; }
-const char* _Locale_grouping(struct _Locale_numeric * lnum UNUSED)
-{ return _empty_str; }
-const char * _Locale_true(struct _Locale_numeric * lnum UNUSED)
-{ return "true"; }
-const char * _Locale_false(struct _Locale_numeric * lnum UNUSED)
-{ return "false"; }
-
-#ifndef _STLP_NO_WCHAR_T
-wchar_t _WLocale_decimal_point(struct _Locale_numeric* lnum UNUSED)
-{ return L'.'; }
-wchar_t _WLocale_thousands_sep(struct _Locale_numeric* lnum UNUSED)
-{ return L','; }
-#if defined(WCHAR_MAX) && WCHAR_MAX == 255
-const wchar_t * _WLocale_true(struct _Locale_numeric* lnum UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return "true"; }
-const wchar_t * _WLocale_false(struct _Locale_numeric* lnum UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return "false"; }
-#else
-const wchar_t * _WLocale_true(struct _Locale_numeric* lnum UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return L"true"; }
-const wchar_t * _WLocale_false(struct _Locale_numeric* lnum UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return L"false"; }
-#endif
-#endif
-
-/* Monetary */
-
-const char* _Locale_int_curr_symbol(struct _Locale_monetary * lmon UNUSED)
-{ return _empty_str; }
-const char* _Locale_currency_symbol(struct _Locale_monetary * lmon UNUSED)
-{ return _empty_str; }
-char _Locale_mon_decimal_point(struct _Locale_monetary * lmon UNUSED)
-{ return '.'; }
-char _Locale_mon_thousands_sep(struct _Locale_monetary * lmon UNUSED)
-{ return ','; }
-const char* _Locale_mon_grouping(struct _Locale_monetary * lmon UNUSED)
-{ return _empty_str; }
-const char* _Locale_positive_sign(struct _Locale_monetary * lmon UNUSED)
-{ return _empty_str; }
-const char* _Locale_negative_sign(struct _Locale_monetary * lmon UNUSED)
-{ return _empty_str; }
-char _Locale_int_frac_digits(struct _Locale_monetary * lmon UNUSED)
-{ return 0; }
-char _Locale_frac_digits(struct _Locale_monetary * lmon UNUSED)
-{ return 0; }
-int _Locale_p_cs_precedes(struct _Locale_monetary * lmon UNUSED)
-{ return CHAR_MAX; }
-int _Locale_p_sep_by_space(struct _Locale_monetary * lmon UNUSED)
-{ return CHAR_MAX; }
-int _Locale_p_sign_posn(struct _Locale_monetary * lmon UNUSED)
-{ return CHAR_MAX; }
-int _Locale_n_cs_precedes(struct _Locale_monetary * lmon UNUSED)
-{ return CHAR_MAX; }
-int _Locale_n_sep_by_space(struct _Locale_monetary * lmon UNUSED)
-{ return CHAR_MAX; }
-int _Locale_n_sign_posn(struct _Locale_monetary * lmon UNUSED)
-{ return CHAR_MAX; }
-
-#ifndef _STLP_NO_WCHAR_T
-const wchar_t* _WLocale_int_curr_symbol(struct _Locale_monetary * lmon UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return _empty_wstr; }
-const wchar_t* _WLocale_currency_symbol(struct _Locale_monetary * lmon UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return _empty_wstr; }
-wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary * lmon UNUSED)
-{ return L'.'; }
-wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary * lmon UNUSED)
-{ return L','; }
-const wchar_t* _WLocale_positive_sign(struct _Locale_monetary * lmon UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return _empty_wstr; }
-const wchar_t* _WLocale_negative_sign(struct _Locale_monetary * lmon UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return _empty_wstr; }
-#endif
-
-/* Time */
-static const char* full_monthname[] =
-{ "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December" };
-const char * _Locale_full_monthname(struct _Locale_time * ltime UNUSED, int n)
-{ return full_monthname[n]; }
-
-static const char* abbrev_monthname[] =
-{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
-const char * _Locale_abbrev_monthname(struct _Locale_time * ltime UNUSED, int n)
-{ return abbrev_monthname[n]; }
-
-static const char* full_dayname[] =
-{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
-const char * _Locale_full_dayofweek(struct _Locale_time * ltime UNUSED, int n)
-{ return full_dayname[n]; }
-
-static const char* abbrev_dayname[] =
-{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
-const char * _Locale_abbrev_dayofweek(struct _Locale_time * ltime UNUSED, int n)
-{ return abbrev_dayname[n]; }
-
-const char* _Locale_d_t_fmt(struct _Locale_time* ltime UNUSED)
-{ return "%m/%d/%y"; }
-const char* _Locale_d_fmt(struct _Locale_time* ltime UNUSED)
-{ return "%m/%d/%y"; }
-const char* _Locale_t_fmt(struct _Locale_time* ltime UNUSED)
-{ return "%H:%M:%S"; }
-const char* _Locale_long_d_t_fmt(struct _Locale_time* ltime UNUSED)
-{ return _empty_str; }
-const char* _Locale_long_d_fmt(struct _Locale_time* ltime UNUSED)
-{ return _empty_str; }
-const char* _Locale_am_str(struct _Locale_time* ltime UNUSED)
-{ return "AM"; }
-const char* _Locale_pm_str(struct _Locale_time* ltime UNUSED)
-{ return "PM"; }
-
-#ifndef _STLP_NO_WCHAR_T
-#if defined(WCHAR_MAX) && WCHAR_MAX == 255
-static const wchar_t* full_wmonthname[] =
-{ "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December" };
-const wchar_t * _WLocale_full_monthname(struct _Locale_time * ltime, int n,
- wchar_t* buf, size_t bufSize)
-{ return full_wmonthname[n]; }
-
-static const wchar_t* abbrev_wmonthname[] =
-{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
-const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time * ltime, int n,
- wchar_t* buf, size_t bufSize)
-{ return abbrev_wmonthname[n]; }
-
-static const wchar_t* full_wdayname[] =
-{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
-const wchar_t * _WLocale_full_dayofweek(struct _Locale_time * ltime, int n,
- wchar_t* buf, size_t bufSize)
-{ return full_wdayname[n]; }
-
-static const wchar_t* abbrev_wdayname[] =
-{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
-const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time * ltime, int n,
- wchar_t* buf, size_t bufSize)
-{ return abbrev_wdayname[n]; }
-
-const wchar_t* _WLocale_am_str(struct _Locale_time* ltime,
- wchar_t* buf, size_t bufSize)
-{ return "AM"; }
-const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime,
- wchar_t* buf, size_t bufSize)
-{ return "PM"; }
-#else /* WCHAR_MAX != 255 */
-static const wchar_t* full_wmonthname[] =
-{ L"January", L"February", L"March", L"April", L"May", L"June",
- L"July", L"August", L"September", L"October", L"November", L"December" };
-const wchar_t * _WLocale_full_monthname(struct _Locale_time * ltime UNUSED,
- int n,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return full_wmonthname[n]; }
-
-static const wchar_t* abbrev_wmonthname[] =
-{ L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
- L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" };
-const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time * ltime UNUSED,
- int n,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return abbrev_wmonthname[n]; }
-
-static const wchar_t* full_wdayname[] =
-{ L"Sunday", L"Monday", L"Tuesday", L"Wednesday", L"Thursday", L"Friday", L"Saturday" };
-const wchar_t * _WLocale_full_dayofweek(struct _Locale_time * ltime UNUSED,
- int n,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return full_wdayname[n]; }
-
-static const wchar_t* abbrev_wdayname[] =
-{ L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat" };
-const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time * ltime UNUSED,
- int n,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return abbrev_wdayname[n]; }
-
-const wchar_t* _WLocale_am_str(struct _Locale_time* ltime UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return L"AM"; }
-const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime UNUSED,
- wchar_t* buf UNUSED,
- size_t bufSize UNUSED)
-{ return L"PM"; }
-#endif /* WCHAR_MAX != 255 */
-#endif
-
-/* Messages */
-
-nl_catd_type _Locale_catopen(struct _Locale_messages* lmes UNUSED,
- const char* name UNUSED)
-{ return -1; }
-void _Locale_catclose(struct _Locale_messages* lmes UNUSED, nl_catd_type cat UNUSED) {}
-const char* _Locale_catgets(struct _Locale_messages* lmes UNUSED,
- nl_catd_type cat UNUSED,
- int setid UNUSED,
- int msgid UNUSED,
- const char *dfault)
-{ return dfault; }
diff --git a/src/c_locale_glibc/c_locale_glibc2.c b/src/c_locale_glibc/c_locale_glibc2.c
deleted file mode 100644
index 0cf8279..0000000
--- a/src/c_locale_glibc/c_locale_glibc2.c
+++ /dev/null
@@ -1,705 +0,0 @@
-#include <locale.h>
-#include <langinfo.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <wctype.h>
-#include <string.h>
-#include <stdint.h>
-
-static const char *_empty_str = "";
-static const char *_C_name = "C";
-
-static wchar_t* _ToWChar(const char* buf, wchar_t *wbuf, size_t wbufSize) {
- wchar_t *wcur = wbuf;
- wchar_t *wend = wbuf + wbufSize - 1;
- for (; wcur != wend && *buf != 0; ++buf, ++wcur)
- *wcur = *buf;
- *wcur = 0;
- return wbuf;
-}
-
-#if 0
-struct _Locale_ctype
-{
- locale_t __cloc;
-};
-
-struct _Locale_numeric
-{
- locale_t __cloc;
-};
-
-struct _Locale_time
-{
- locale_t __cloc;
-};
-
-struct _Locale_collate
-{
- locale_t __cloc;
-};
-
-struct _Locale_monetary
-{
- locale_t __cloc;
-};
-
-struct _Locale_messages
-{
- locale_t __cloc;
-};
-#endif
-
-void _Locale_init()
-{}
-
-void _Locale_final()
-{}
-
-struct _Locale_ctype *_Locale_ctype_create(const char *nm, struct _Locale_name_hint* hint,
- int *__err_code) {
- *__err_code = _STLP_LOC_UNKNOWN_NAME;
- return (struct _Locale_ctype*)newlocale(LC_CTYPE_MASK, nm, NULL);
-}
-
-struct _Locale_codecvt *_Locale_codecvt_create(const char *nm, struct _Locale_name_hint* hint,
- int *__err_code) {
- // Glibc do not support multibyte manipulation for the moment, it simply implements "C".
- if (nm[0] == 'C' && nm[1] == 0)
- { return (struct _Locale_codecvt*)0x01; }
- *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
-}
-
-struct _Locale_numeric *_Locale_numeric_create(const char *nm, struct _Locale_name_hint* hint,
- int *__err_code) {
- *__err_code = _STLP_LOC_UNKNOWN_NAME;
- return (struct _Locale_numeric*)newlocale(LC_NUMERIC_MASK, nm, NULL);
-}
-
-struct _Locale_time *_Locale_time_create(const char *nm, struct _Locale_name_hint* hint,
- int *__err_code) {
- *__err_code = _STLP_LOC_UNKNOWN_NAME;
- return (struct _Locale_time*)newlocale(LC_TIME_MASK, nm, NULL);
-}
-
-struct _Locale_collate *_Locale_collate_create(const char *nm, struct _Locale_name_hint* hint,
- int *__err_code) {
- *__err_code = _STLP_LOC_UNKNOWN_NAME;
- return (struct _Locale_collate*)newlocale(LC_COLLATE_MASK, nm, NULL);
-}
-
-struct _Locale_monetary *_Locale_monetary_create(const char *nm, struct _Locale_name_hint* hint,
- int *__err_code) {
- *__err_code = _STLP_LOC_UNKNOWN_NAME;
- return (struct _Locale_monetary*)newlocale(LC_MONETARY_MASK, nm, NULL);
-}
-
-struct _Locale_messages *_Locale_messages_create(const char *nm, struct _Locale_name_hint* hint,
- int *__err_code) {
- *__err_code = _STLP_LOC_UNKNOWN_NAME;
- return (struct _Locale_messages*)newlocale(LC_MESSAGES_MASK, nm, NULL);
-}
-
-/*
- try to see locale category LC should be used from environment;
- according POSIX, the order is
- 1. LC_ALL
- 2. category (LC_CTYPE, LC_NUMERIC, ... )
- 3. LANG
- If set nothing, return "C" (this really implementation-specific).
-*/
-static const char *_Locale_aux_default( const char *LC, char *nm )
-{
- char *name = getenv( "LC_ALL" );
-
- if ( name != NULL && *name != 0 ) {
- return name;
- }
- name = getenv( LC );
- if ( name != NULL && *name != 0 ) {
- return name;
- }
- name = getenv( "LANG" );
- if ( name != NULL && *name != 0 ) {
- return name;
- }
-
- return _C_name;
-}
-
-const char *_Locale_ctype_default( char *nm )
-{
- return _Locale_aux_default( "LC_CTYPE", nm );
-}
-
-const char *_Locale_numeric_default( char *nm )
-{
- return _Locale_aux_default( "LC_NUMERIC", nm );
-}
-
-const char *_Locale_time_default( char *nm )
-{
- return _Locale_aux_default( "LC_TIME", nm );
-}
-
-const char *_Locale_collate_default( char *nm )
-{
- return _Locale_aux_default( "LC_COLLATE", nm );
-}
-
-const char *_Locale_monetary_default( char *nm )
-{
- return _Locale_aux_default( "LC_MONETARY", nm );
-}
-
-const char *_Locale_messages_default( char *nm )
-{
- return _Locale_aux_default( "LC_MESSAGES", nm );
-}
-
-char const*_Locale_ctype_name( const struct _Locale_ctype *__loc, char *buf )
-{
- return ((locale_t)__loc)->__names[LC_CTYPE];
-}
-
-char const*_Locale_codecvt_name( const struct _Locale_codecvt *__loc, char *buf )
-{
- return _C_name;
-}
-
-char const*_Locale_numeric_name( const struct _Locale_numeric *__loc, char *buf )
-{
- return ((locale_t)__loc)->__names[LC_NUMERIC];
-}
-
-char const*_Locale_time_name( const struct _Locale_time *__loc, char *buf )
-{
- return ((locale_t)__loc)->__names[LC_TIME];
-}
-
-char const*_Locale_collate_name( const struct _Locale_collate *__loc, char *buf )
-{
- return ((locale_t)__loc)->__names[LC_COLLATE];
-}
-
-char const*_Locale_monetary_name( const struct _Locale_monetary *__loc, char *buf )
-{
- return ((locale_t)__loc)->__names[LC_MONETARY];
-}
-
-char const*_Locale_messages_name( const struct _Locale_messages *__loc, char *buf )
-{
- return ((locale_t)__loc)->__names[LC_MESSAGES];
-}
-
-void _Locale_ctype_destroy( struct _Locale_ctype *__loc )
-{ freelocale((locale_t)__loc); }
-
-void _Locale_codecvt_destroy( struct _Locale_codecvt *__loc )
-{}
-
-void _Locale_numeric_destroy( struct _Locale_numeric *__loc )
-{ freelocale((locale_t)__loc); }
-
-void _Locale_time_destroy( struct _Locale_time *__loc )
-{ freelocale((locale_t)__loc); }
-
-void _Locale_collate_destroy( struct _Locale_collate *__loc )
-{ freelocale((locale_t)__loc); }
-
-void _Locale_monetary_destroy( struct _Locale_monetary *__loc )
-{ freelocale((locale_t)__loc); }
-
-void _Locale_messages_destroy( struct _Locale_messages* __loc )
-{ freelocale((locale_t)__loc); }
-
-/*
- * locale loc expected either locale name indeed (platform-specific)
- * or string like "LC_CTYPE=LocaleNameForCType;LC_NUMERIC=LocaleNameForNum;"
- *
- */
-
-static char const*__Extract_locale_name( const char *loc, const char *category, char *buf )
-{
- char *expr;
- size_t len_name;
-
- if( loc[0]=='L' && loc[1]=='C' && loc[2]=='_') {
- expr = strstr( (char*)loc, category );
- if ( expr == NULL )
- return NULL; /* Category not found. */
- ++expr;
- len_name = strcspn( expr, ";" );
- len_name = len_name >= _Locale_MAX_SIMPLE_NAME ? _Locale_MAX_SIMPLE_NAME - 1 : len_name;
- strncpy( buf, expr, len_name );
- buf[len_name] = 0;
- return buf;
- }
- return loc;
-}
-
-char const*_Locale_extract_ctype_name(const char *loc, char *buf,
- struct _Locale_name_hint* hint, int *__err_code)
-{ return __Extract_locale_name( loc, "LC_CTYPE=", buf ); }
-
-char const*_Locale_extract_numeric_name(const char *loc, char *buf,
- struct _Locale_name_hint* hint, int *__err_code)
-{ return __Extract_locale_name( loc, "LC_NUMERIC=", buf ); }
-
-char const*_Locale_extract_time_name(const char *loc, char *buf,
- struct _Locale_name_hint* hint, int *__err_code)
-{ return __Extract_locale_name( loc, "LC_TIME=", buf ); }
-
-char const*_Locale_extract_collate_name(const char *loc, char *buf,
- struct _Locale_name_hint* hint, int *__err_code)
-{ return __Extract_locale_name( loc, "LC_COLLATE=", buf ); }
-
-char const*_Locale_extract_monetary_name(const char *loc, char *buf,
- struct _Locale_name_hint* hint, int *__err_code)
-{ return __Extract_locale_name( loc, "LC_MONETARY=", buf ); }
-
-char const*_Locale_extract_messages_name(const char *loc, char *buf,
- struct _Locale_name_hint* hint, int *__err_code)
-{ return __Extract_locale_name( loc, "LC_MESSAGES=", buf ); }
-
-struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype* ctype)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric* numeric)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time* time)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate* collate)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary* monetary)
-{ return 0; }
-struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages* messages)
-{ return 0; }
-
-/* ctype */
-
-const _Locale_mask_t *_Locale_ctype_table( struct _Locale_ctype *__loc )
-{
- /* return table with masks (upper, lower, alpha, etc.) */
- _STLP_STATIC_ASSERT( sizeof(_Locale_mask_t) == sizeof(((locale_t)__loc)->__ctype_b[0]) )
- return ((locale_t)__loc)->__ctype_b;
-}
-
-int _Locale_toupper( struct _Locale_ctype *__loc, int c )
-{ return ((locale_t)__loc)->__ctype_toupper[c]; }
-
-int _Locale_tolower( struct _Locale_ctype *__loc, int c )
-{ return ((locale_t)__loc)->__ctype_tolower[c]; }
-
-#if !defined (_STLP_NO_WCHAR_T)
-_Locale_mask_t _WLocale_ctype( struct _Locale_ctype *__loc, wint_t wc, _Locale_mask_t __mask )
-{
- _Locale_mask_t ret = 0;
- if ((__mask & _Locale_ALPHA) != 0 && iswalpha_l(wc, (locale_t)__loc))
- ret |= _Locale_ALPHA;
-
- if ((__mask & _Locale_CNTRL) != 0 && iswcntrl_l(wc, (locale_t)__loc))
- ret |= _Locale_CNTRL;
-
- if ((__mask & _Locale_DIGIT) != 0 && iswdigit_l(wc, (locale_t)__loc))
- ret |= _Locale_DIGIT;
-
- if ((__mask & _Locale_PRINT) != 0 && iswprint_l(wc, (locale_t)__loc))
- ret |= _Locale_PRINT;
-
- if ((__mask & _Locale_PUNCT) != 0 && iswpunct_l(wc, (locale_t)__loc))
- ret |= _Locale_PUNCT;
-
- if ((__mask & _Locale_SPACE) != 0 && iswspace_l(wc, (locale_t)__loc))
- ret |= _Locale_SPACE;
-
- if ((__mask & _Locale_XDIGIT) != 0 && iswxdigit_l(wc, (locale_t)__loc))
- ret |= _Locale_XDIGIT;
-
- if ((__mask & _Locale_UPPER) != 0 && iswupper_l(wc, (locale_t)__loc))
- ret |= _Locale_UPPER;
-
- if ((__mask & _Locale_LOWER) != 0 && iswlower_l(wc, (locale_t)__loc))
- ret |= _Locale_LOWER;
-
- return ret;
-}
-
-wint_t _WLocale_tolower( struct _Locale_ctype *__loc, wint_t c )
-{
- return towlower_l( c, ((locale_t)__loc) );
-}
-
-wint_t _WLocale_toupper( struct _Locale_ctype *__loc, wint_t c )
-{
- return towupper_l( c, ((locale_t)__loc) );
-}
-#endif
-
-int _WLocale_mb_cur_max( struct _Locale_codecvt * lcodecvt) { return 1; }
-int _WLocale_mb_cur_min( struct _Locale_codecvt * lcodecvt) { return 1; }
-int _WLocale_is_stateless( struct _Locale_codecvt * lcodecvt) { return 1; }
-
-#if !defined (_STLP_NO_WCHAR_T)
-size_t _WLocale_mbtowc(struct _Locale_codecvt *lcodecvt,
- wchar_t *to,
- const char *from, size_t n,
- mbstate_t *st)
-{ *to = *from; return 1; }
-
-size_t _WLocale_wctomb(struct _Locale_codecvt *lcodecvt,
- char *to, size_t n,
- const wchar_t c,
- mbstate_t *st)
-{ *to = (char)c; return 1; }
-#endif
-
-size_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt,
- mbstate_t *st,
- char *buf, size_t n, char ** next)
-{ *next = buf; return 0; }
-
-/* Collate */
-int _Locale_strcmp(struct _Locale_collate * __loc,
- const char *s1, size_t n1,
- const char *s2, size_t n2) {
- int ret = 0;
- char buf1[64], buf2[64];
- while (n1 > 0 || n2 > 0) {
- size_t bufsize1 = n1 < 63 ? n1 : 63;
- size_t bufsize2 = n2 < 63 ? n2 : 63;
- strncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0;
- strncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0;
-
- ret = strcoll_l(buf1, buf2, (locale_t)__loc);
- if (ret != 0) return ret;
- s1 += bufsize1; n1 -= bufsize1;
- s2 += bufsize2; n2 -= bufsize2;
- }
- return ret;
-}
-
-#if !defined (_STLP_NO_WCHAR_T)
-int _WLocale_strcmp(struct _Locale_collate *__loc,
- const wchar_t *s1, size_t n1,
- const wchar_t *s2, size_t n2) {
- int ret = 0;
- wchar_t buf1[64], buf2[64];
- while (n1 > 0 || n2 > 0) {
- size_t bufsize1 = n1 < 63 ? n1 : 63;
- size_t bufsize2 = n2 < 63 ? n2 : 63;
- wcsncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0;
- wcsncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0;
-
- ret = wcscoll_l(buf1, buf2, (locale_t)__loc);
- if (ret != 0) return ret;
- s1 += bufsize1; n1 -= bufsize1;
- s2 += bufsize2; n2 -= bufsize2;
- }
- return ret;
-}
-
-#endif
-
-size_t _Locale_strxfrm(struct _Locale_collate *__loc,
- char *dest, size_t dest_n,
- const char *src, size_t src_n )
-{
- const char *real_src;
- char *buf = NULL;
- size_t result;
-
- if (src_n == 0)
- {
- if (dest != NULL) dest[0] = 0;
- return 0;
- }
- if (src[src_n] != 0) {
- buf = malloc(src_n + 1);
- strncpy(buf, src, src_n);
- buf[src_n] = 0;
- real_src = buf;
- }
- else
- real_src = src;
- result = strxfrm_l(dest, real_src, dest_n, (locale_t)__loc);
- if (buf != NULL) free(buf);
- return result;
-}
-
-# ifndef _STLP_NO_WCHAR_T
-
-size_t _WLocale_strxfrm( struct _Locale_collate *__loc,
- wchar_t *dest, size_t dest_n,
- const wchar_t *src, size_t src_n )
-{
- const wchar_t *real_src;
- wchar_t *buf = NULL;
- size_t result;
-
- if (src_n == 0)
- {
- if (dest != NULL) dest[0] = 0;
- return 0;
- }
- if (src[src_n] != 0) {
- buf = malloc((src_n + 1) * sizeof(wchar_t));
- wcsncpy(buf, src, src_n);
- buf[src_n] = 0;
- real_src = buf;
- }
- else
- real_src = src;
- result = wcsxfrm_l(dest, real_src, dest_n, (locale_t)__loc);
- if (buf != NULL) free(buf);
- return result;
-}
-
-# endif
-
-/* Numeric */
-
-char _Locale_decimal_point(struct _Locale_numeric *__loc)
-{
- return *(nl_langinfo_l(RADIXCHAR, (locale_t)__loc));
-}
-
-char _Locale_thousands_sep(struct _Locale_numeric *__loc)
-{
- return *(nl_langinfo_l(THOUSEP, (locale_t)__loc));
-}
-
-const char* _Locale_grouping(struct _Locale_numeric *__loc)
-{
- return (_Locale_thousands_sep(__loc) != 0 ) ? (nl_langinfo_l(GROUPING, (locale_t)__loc)) : _empty_str;
-}
-
-const char *_Locale_true(struct _Locale_numeric *__loc)
-{
- return nl_langinfo_l(YESSTR, (locale_t)__loc);
-}
-
-const char *_Locale_false(struct _Locale_numeric *__loc)
-{
- return nl_langinfo_l(NOSTR, (locale_t)__loc);
-}
-
-#ifndef _STLP_NO_WCHAR_T
-wchar_t _WLocale_decimal_point(struct _Locale_numeric *__loc)
-{ return (wchar_t)_Locale_decimal_point(__loc); }
-wchar_t _WLocale_thousands_sep(struct _Locale_numeric *__loc)
-{ return (wchar_t)_Locale_thousands_sep(__loc); }
-const wchar_t *_WLocale_true(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_true(__loc), buf, bufSize); }
-const wchar_t *_WLocale_false(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_false(__loc), buf, bufSize); }
-#endif
-
-/* Monetary */
-
-const char *_Locale_int_curr_symbol(struct _Locale_monetary *__loc)
-{
- return nl_langinfo_l(INT_CURR_SYMBOL, (locale_t)__loc);
-}
-
-const char *_Locale_currency_symbol(struct _Locale_monetary *__loc)
-{
- return nl_langinfo_l(CURRENCY_SYMBOL, (locale_t)__loc);
-}
-
-char _Locale_mon_decimal_point(struct _Locale_monetary * __loc)
-{
- return *(nl_langinfo_l(MON_DECIMAL_POINT,(locale_t)__loc));
-}
-
-char _Locale_mon_thousands_sep(struct _Locale_monetary *__loc)
-{
- return *(nl_langinfo_l(MON_THOUSANDS_SEP, (locale_t)__loc));
-}
-
-#ifndef _STLP_NO_WCHAR_T
-const wchar_t *_WLocale_int_curr_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_int_curr_symbol(__loc), buf, bufSize); }
-const wchar_t *_WLocale_currency_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_currency_symbol(__loc), buf, bufSize); }
-wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary * __loc)
-{ return (wchar_t)_Locale_mon_decimal_point(__loc); }
-wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary * __loc)
-{ return (wchar_t)_Locale_mon_thousands_sep(__loc); }
-const wchar_t *_WLocale_positive_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_positive_sign(__loc), buf, bufSize); }
-const wchar_t *_WLocale_negative_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_negative_sign(__loc), buf, bufSize); }
-#endif
-
-const char *_Locale_mon_grouping(struct _Locale_monetary *__loc)
-{
- return (_Locale_mon_thousands_sep( __loc ) != 0 ) ? nl_langinfo_l(MON_GROUPING, (locale_t)__loc) : _empty_str;
-}
-
-const char *_Locale_positive_sign(struct _Locale_monetary *__loc)
-{
- return nl_langinfo_l(POSITIVE_SIGN, (locale_t)__loc);
-}
-
-const char *_Locale_negative_sign(struct _Locale_monetary *__loc)
-{
- return nl_langinfo_l(NEGATIVE_SIGN, (locale_t)__loc);
-}
-
-char _Locale_int_frac_digits(struct _Locale_monetary *__loc)
-{
- /* We are forced to manually handled the "C" locale for consistency with
- * the default implementation in STLport. */
- const char* lname = ((locale_t)__loc)->__names[LC_MONETARY];
- if (lname[0] == 'C' && lname[1] == 0)
- return 0;
- return *(nl_langinfo_l(INT_FRAC_DIGITS, (locale_t)__loc));
-}
-
-char _Locale_frac_digits(struct _Locale_monetary *__loc)
-{
- /* We are forced to manually handled the "C" locale for consistency with
- * the default implementation in STLport. */
- const char* lname = ((locale_t)__loc)->__names[LC_MONETARY];
- if (lname[0] == 'C' && lname[1] == 0)
- return 0;
- return *(nl_langinfo_l(FRAC_DIGITS, (locale_t)__loc));
-}
-
-/* 1 if currency_symbol precedes a positive value, 0 if succeeds */
-int _Locale_p_cs_precedes(struct _Locale_monetary *__loc)
-{
- return *(nl_langinfo_l(P_CS_PRECEDES, (locale_t)__loc));
-}
-
-/* 1 if a space separates currency_symbol from a positive value. */
-int _Locale_p_sep_by_space(struct _Locale_monetary *__loc)
-{
- return *(nl_langinfo_l(P_SEP_BY_SPACE, (locale_t)__loc));
-}
-
-/*
- * 0 Parentheses surround the quantity and currency_symbol
- * 1 The sign string precedes the quantity and currency_symbol
- * 2 The sign string succeeds the quantity and currency_symbol.
- * 3 The sign string immediately precedes the currency_symbol.
- * 4 The sign string immediately succeeds the currency_symbol.
- */
-int _Locale_p_sign_posn(struct _Locale_monetary *__loc)
-{
- return *(nl_langinfo_l(P_SIGN_POSN, (locale_t)__loc));
-}
-
-/* 1 if currency_symbol precedes a negative value, 0 if succeeds */
-int _Locale_n_cs_precedes(struct _Locale_monetary *__loc)
-{
- return *(nl_langinfo_l(N_CS_PRECEDES, (locale_t)__loc));
-}
-
-/* 1 if a space separates currency_symbol from a negative value. */
-int _Locale_n_sep_by_space(struct _Locale_monetary *__loc)
-{
- return *(nl_langinfo_l(N_SEP_BY_SPACE, (locale_t)__loc));
-}
-
-/*
- * 0 Parentheses surround the quantity and currency_symbol
- * 1 The sign string precedes the quantity and currency_symbol
- * 2 The sign string succeeds the quantity and currency_symbol.
- * 3 The sign string immediately precedes the currency_symbol.
- * 4 The sign string immediately succeeds the currency_symbol.
- */
-int _Locale_n_sign_posn(struct _Locale_monetary *__loc)
-{
- return *(nl_langinfo_l(N_SIGN_POSN, (locale_t)__loc));
-}
-
-
-/* Time */
-const char *_Locale_full_monthname(struct _Locale_time *__loc, int _m )
-{
- return nl_langinfo_l(MON_1 + _m, (locale_t)__loc);
-}
-
-const char *_Locale_abbrev_monthname(struct _Locale_time *__loc, int _m )
-{
- return nl_langinfo_l(ABMON_1 + _m, (locale_t)__loc);
-}
-
-const char *_Locale_full_dayofweek(struct _Locale_time *__loc, int _d )
-{
- return nl_langinfo_l(DAY_1 + _d, (locale_t)__loc);
-}
-
-const char *_Locale_abbrev_dayofweek(struct _Locale_time *__loc, int _d )
-{
- return nl_langinfo_l(ABDAY_1 + _d, (locale_t)__loc);
-}
-
-const char *_Locale_d_t_fmt(struct _Locale_time *__loc)
-{
- return nl_langinfo_l(D_T_FMT, (locale_t)__loc);
-}
-
-const char *_Locale_d_fmt(struct _Locale_time *__loc )
-{
- return nl_langinfo_l(D_FMT, (locale_t)__loc);
-}
-
-const char *_Locale_t_fmt(struct _Locale_time *__loc )
-{
- return nl_langinfo_l(T_FMT, (locale_t)__loc);
-}
-
-const char *_Locale_long_d_t_fmt(struct _Locale_time *__loc )
-{
- return nl_langinfo_l(ERA_D_T_FMT, (locale_t)__loc);
-}
-
-const char *_Locale_long_d_fmt(struct _Locale_time *__loc )
-{
- return nl_langinfo_l(ERA_D_FMT, (locale_t)__loc);
-}
-
-const char *_Locale_am_str(struct _Locale_time *__loc )
-{
- return nl_langinfo_l(AM_STR, (locale_t)__loc);
-}
-
-const char *_Locale_pm_str(struct _Locale_time* __loc )
-{
- return nl_langinfo_l(PM_STR, (locale_t)__loc);
-}
-
-#ifndef _STLP_NO_WCHAR_T
-const wchar_t *_WLocale_full_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_full_monthname(__loc, _m), buf, bufSize); }
-const wchar_t *_WLocale_abbrev_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_abbrev_monthname(__loc, _m), buf, bufSize); }
-const wchar_t *_WLocale_full_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_full_dayofweek(__loc, _d), buf, bufSize); }
-const wchar_t *_WLocale_abbrev_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_abbrev_dayofweek(__loc, _d), buf, bufSize); }
-const wchar_t *_WLocale_am_str(struct _Locale_time *__loc, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_am_str(__loc), buf, bufSize); }
-const wchar_t *_WLocale_pm_str(struct _Locale_time* __loc, wchar_t *buf, size_t bufSize)
-{ return _ToWChar(_Locale_pm_str(__loc), buf, bufSize); }
-#endif
-
-/* Messages */
-
-nl_catd_type _Locale_catopen(struct _Locale_messages *__loc, const char *__cat_name )
-{
- return catopen( __cat_name, NL_CAT_LOCALE );
-}
-
-void _Locale_catclose(struct _Locale_messages *__loc, nl_catd_type __cat )
-{
- catclose( __cat );
-}
-
-const char *_Locale_catgets(struct _Locale_messages *__loc, nl_catd_type __cat,
- int __setid, int __msgid, const char *dfault)
-{
- return catgets( __cat, __setid, __msgid, dfault );
-}
diff --git a/src/c_locale_win32/c_locale_win32.c b/src/c_locale_win32/c_locale_win32.c
deleted file mode 100644
index dab958d..0000000
--- a/src/c_locale_win32/c_locale_win32.c
+++ /dev/null
@@ -1,1786 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * Written 2000
- * Anton Lapach
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include <limits.h>
-#if defined (_STLP_MSVC) || defined (__ICL)
-# include <memory.h>
-#endif
-#include <string.h>
-#include <locale.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
-# define _STLP_STRCPY(D, DS, S) strcpy_s(D, DS, S)
-# define _STLP_STRNCPY(D, DS, S, C) strncpy_s(D, DS, S, C)
-# define _STLP_STRCAT(D, DS, S) strcat_s(D, DS, S)
-#else
-# define _STLP_STRCPY(D, DS, S) strcpy(D, S)
-# define _STLP_STRNCPY(D, DS, S, C) strncpy(D, S, C)
-# define _STLP_STRCAT(D, DS, S) strcat(D, S)
-#endif
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-/* Framework functions */
-/*
- locale :: "lang[_country[.code_page]]"
- | ".code_page"
- | ""
- | NULL
-
-*/
-
-typedef struct _LOCALECONV {
- const char* name;
- const char* abbrev;
-} LOCALECONV;
-
-#define MAX_LANG_LEN 64 /* max language name length */
-#define MAX_CTRY_LEN 64 /* max country name length */
-#define MAX_MODIFIER_LEN 0 /* max modifier name length - n/a */
-#define MAX_LC_LEN (MAX_LANG_LEN+MAX_CTRY_LEN+MAX_MODIFIER_LEN+3)
- /* max entire locale string length */
-#define MAX_CP_LEN 5 /* max code page name length */
-
-#if !defined (LANG_INVARIANT)
-# define LANG_INVARIANT 0x7f
-# define _STLP_LANG_INVARIANT_DEFINED
-#endif
-
-#ifndef CP_UTF7
-# define CP_UTF7 65000
-#endif
-
-#ifndef CP_UTF8
-# define CP_UTF8 65001
-#endif
-
-#define INVARIANT_LCID MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT)
-
-static const char *_C_name = "C";
-
-/* non-NLS language string table */
-static LOCALECONV __rg_language[] = {
- {"american", "ENU"},
- {"american english", "ENU"},
- {"american-english", "ENU"},
- {"australian", "ENA"},
- {"belgian", "NLB"},
- {"canadian", "ENC"},
- {"chh", "ZHH"},
- {"chi", "ZHI"},
- {"chinese", "CHS"},
- {"chinese-hongkong", "ZHH"},
- {"chinese-simplified", "CHS"},
- {"chinese-singapore", "ZHI"},
- {"chinese-traditional", "CHT"},
- {"dutch-belgian", "NLB"},
- {"english-american", "ENU"},
- {"english-aus", "ENA"},
- {"english-belize", "ENL"},
- {"english-can", "ENC"},
- {"english-caribbean", "ENB"},
- {"english-ire", "ENI"},
- {"english-jamaica", "ENJ"},
- {"english-nz", "ENZ"},
- {"english-south africa", "ENS"},
- {"english-trinidad y tobago", "ENT"},
- {"english-uk", "ENG"},
- {"english-us", "ENU"},
- {"english-usa", "ENU"},
- {"french-belgian", "FRB"},
- {"french-canadian", "FRC"},
- {"french-luxembourg", "FRL"},
- {"french-swiss", "FRS"},
- {"german-austrian", "DEA"},
- {"german-lichtenstein", "DEC"},
- {"german-luxembourg", "DEL"},
- {"german-swiss", "DES"},
- {"irish-english", "ENI"},
- {"italian-swiss", "ITS"},
- {"norwegian", "NOR"},
- {"norwegian-bokmal", "NOR"},
- {"norwegian-nynorsk", "NON"},
- {"portuguese-brazilian", "PTB"},
- {"spanish-argentina", "ESS"},
- {"spanish-bolivia", "ESB"},
- {"spanish-chile", "ESL"},
- {"spanish-colombia", "ESO"},
- {"spanish-costa rica", "ESC"},
- {"spanish-dominican republic", "ESD"},
- {"spanish-ecuador", "ESF"},
- {"spanish-el salvador", "ESE"},
- {"spanish-guatemala", "ESG"},
- {"spanish-honduras", "ESH"},
- {"spanish-mexican", "ESM"},
- {"spanish-modern", "ESN"},
- {"spanish-nicaragua", "ESI"},
- {"spanish-panama", "ESA"},
- {"spanish-paraguay", "ESZ"},
- {"spanish-peru", "ESR"},
- {"spanish-puerto rico", "ESU"},
- {"spanish-uruguay", "ESY"},
- {"spanish-venezuela", "ESV"},
- {"swedish-finland", "SVF"},
- {"swiss", "DES"},
- {"uk", "ENG"},
- {"us", "ENU"},
- {"usa", "ENU"}
-};
-
-/* non-NLS country string table */
-static LOCALECONV __rg_country[] = {
- {"america", "USA"},
- {"britain", "GBR"},
- {"china", "CHN"},
- {"czech", "CZE"},
- {"england", "GBR"},
- {"great britain", "GBR"},
- {"holland", "NLD"},
- {"hong-kong", "HKG"},
- {"new-zealand", "NZL"},
- {"nz", "NZL"},
- {"pr china", "CHN"},
- {"pr-china", "CHN"},
- {"puerto-rico", "PRI"},
- {"slovak", "SVK"},
- {"south africa", "ZAF"},
- {"south korea", "KOR"},
- {"south-africa", "ZAF"},
- {"south-korea", "KOR"},
- {"trinidad & tobago", "TTO"},
- {"uk", "GBR"},
- {"united-kingdom", "GBR"},
- {"united-states", "USA"},
- {"us", "USA"},
-};
-
-typedef struct _Locale_name_hint {
- LCID id;
-} _Locale_lcid_t;
-
-typedef struct _Locale_ctype {
- _Locale_lcid_t lc;
- UINT cp;
- unsigned short ctable[256];
-} _Locale_ctype_t;
-
-typedef struct _Locale_numeric {
- _Locale_lcid_t lc;
- char cp[MAX_CP_LEN + 1];
- char decimal_point[4];
- char thousands_sep[4];
- char *grouping;
-} _Locale_numeric_t;
-
-typedef struct _Locale_time {
- _Locale_lcid_t lc;
- char cp[MAX_CP_LEN + 1];
- char *month[12];
- char *abbrev_month[12];
- char *dayofweek[7];
- char *abbrev_dayofweek[7];
- char *date_time_format;
- char *long_date_time_format;
- char *date_format;
- char *long_date_format;
- char *time_format;
- char am[9];
- char pm[9];
-} _Locale_time_t;
-
-typedef struct _Locale_collate {
- _Locale_lcid_t lc;
- char cp[MAX_CP_LEN + 1];
-} _Locale_collate_t;
-
-typedef struct _Locale_monetary {
- _Locale_lcid_t lc;
- char cp[MAX_CP_LEN + 1];
- char decimal_point[4];
- char thousands_sep[4];
- char *grouping;
- char int_curr_symbol[5]; /* 3 + 1 + 1 */
- char curr_symbol[6];
- char negative_sign[5];
- char positive_sign[5];
- int frac_digits;
- int int_frac_digits;
-} _Locale_monetary_t;
-
-/* Internal function */
-static void __FixGrouping(char *grouping);
-static const char* __ConvertName(const char* lname, LOCALECONV* ConvTable, int TableSize);
-static int __ParseLocaleString(const char* lname, char* lang, char* ctry, char* page);
-static int __GetLCID(const char* lang, const char* ctry, LCID* lcid);
-static int __GetLCIDFromName(const char* lname, LCID* lcid, char *cp, _Locale_lcid_t *hint);
-static char const* __GetLocaleName(LCID lcid, const char* cp, char* buf);
-static char const* __Extract_locale_name(const char* loc, const char* category, char* buf);
-static char const* __TranslateToSystem(const char* lname, char* buf, _Locale_lcid_t* hint, int *__err_code);
-static void __GetLocaleInfoUsingACP(LCID lcid, const char* cp, LCTYPE lctype, char* buf, int buf_size, wchar_t* wbuf, int wbuf_size);
-static int __intGetACP(LCID lcid);
-static int __intGetOCP(LCID lcid);
-static int __GetDefaultCP(LCID lcid);
-static char* __ConvertToCP(int from_cp, int to_cp, const char *from, size_t size, size_t *ret_buf_size);
-static void my_ltoa(long __x, char* buf);
-
-void my_ltoa(long __x, char* buf) {
- char rbuf[64];
- char* ptr = rbuf;
-
- if (__x == 0)
- *ptr++ = '0';
- else {
- for (; __x != 0; __x /= 10)
- *ptr++ = (char)(__x % 10) + '0';
- }
- while(ptr > rbuf) *buf++ = *--ptr;
- /* psw */
- *buf = '\0';
-}
-
-#if defined (__cplusplus)
-_STLP_BEGIN_NAMESPACE
-extern "C" {
-#endif
-
-_Locale_lcid_t* _Locale_get_ctype_hint(_Locale_ctype_t* ltype)
-{ return (ltype != 0) ? <ype->lc : 0; }
-_Locale_lcid_t* _Locale_get_numeric_hint(_Locale_numeric_t* lnumeric)
-{ return (lnumeric != 0) ? &lnumeric->lc : 0; }
-_Locale_lcid_t* _Locale_get_time_hint(_Locale_time_t* ltime)
-{ return (ltime != 0) ? <ime->lc : 0; }
-_Locale_lcid_t* _Locale_get_collate_hint(_Locale_collate_t* lcollate)
-{ return (lcollate != 0) ? &lcollate->lc : 0; }
-_Locale_lcid_t* _Locale_get_monetary_hint(_Locale_monetary_t* lmonetary)
-{ return (lmonetary != 0) ? &lmonetary->lc : 0; }
-_Locale_lcid_t* _Locale_get_messages_hint(struct _Locale_messages* lmessages) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lmessages)
- return 0;
-}
-
-#define MAP(x, y) if ((mask & x) != 0) ret |= (y)
-unsigned short MapCtypeMask(unsigned short mask) {
- unsigned short ret = 0;
- MAP(C1_UPPER, _Locale_UPPER | _Locale_PRINT);
- MAP(C1_LOWER, _Locale_LOWER | _Locale_PRINT);
- MAP(C1_DIGIT, _Locale_DIGIT | _Locale_PRINT);
- MAP(C1_SPACE, _Locale_SPACE | _Locale_PRINT);
- MAP(C1_PUNCT, _Locale_PUNCT | _Locale_PRINT);
- /* MAP(C1_BLANK, ?); */
- MAP(C1_XDIGIT, _Locale_XDIGIT | _Locale_PRINT);
- MAP(C1_ALPHA, _Locale_ALPHA | _Locale_PRINT);
- if ((mask & C1_CNTRL) != 0) { ret |= _Locale_CNTRL; ret &= ~_Locale_PRINT; }
- return ret;
-}
-
-static void MapCtypeMasks(unsigned short *cur, unsigned short *end) {
- for (; cur != end; ++cur) {
- *cur = MapCtypeMask(*cur);
- }
-}
-
-_Locale_ctype_t* _Locale_ctype_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
- char cp_name[MAX_CP_LEN + 1];
- int NativeCP;
- unsigned char Buffer[256];
- unsigned char *ptr;
- CPINFO CPInfo;
- int i;
- wchar_t *wbuffer;
- int BufferSize;
-
- _Locale_ctype_t *ltype = (_Locale_ctype_t*)malloc(sizeof(_Locale_ctype_t));
-
- if (!ltype) { *__err_code = _STLP_LOC_NO_MEMORY; return ltype; }
- memset(ltype, 0, sizeof(_Locale_ctype_t));
-
- if (__GetLCIDFromName(name, <ype->lc.id, cp_name, lc_hint) == -1)
- { free(ltype); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
-
-#if defined (__BORLANDC__)
- if ( ltype->lc.id == INVARIANT_LCID && name[0] == 'C' && name[1] == 0 )
- { ltype->lc.id = 0x409; }
-#endif
-
- ltype->cp = atoi(cp_name);
-
- NativeCP = __GetDefaultCP(ltype->lc.id);
-
- /* Make table with all characters. */
- for (i = 0; i < 256; ++i) Buffer[i] = (unsigned char)i;
-
- if (!GetCPInfo(NativeCP, &CPInfo)) { free(ltype); return NULL; }
-
- if (CPInfo.MaxCharSize > 1) {
- for (ptr = (unsigned char*)CPInfo.LeadByte; *ptr && *(ptr + 1); ptr+=2)
- for (i = *ptr; i <= *(ptr + 1); ++i) Buffer[i] = 0;
- }
-
- if ((UINT)NativeCP != ltype->cp) {
- OSVERSIONINFO ver_info;
- ver_info.dwOSVersionInfoSize = sizeof(ver_info);
- GetVersionEx(&ver_info);
- if (ver_info.dwPlatformId == VER_PLATFORM_WIN32_NT) {
- /* Convert character sequence to Unicode. */
- BufferSize = MultiByteToWideChar(ltype->cp, MB_PRECOMPOSED, (const char*)Buffer, 256, NULL, 0);
- if (!BufferSize) { free(ltype); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
- wbuffer = (wchar_t*)malloc(BufferSize * sizeof(wchar_t));
- if (!wbuffer) { free(ltype); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- MultiByteToWideChar(ltype->cp, MB_PRECOMPOSED, (const char*)Buffer, 256, wbuffer, BufferSize);
-
- GetStringTypeW(CT_CTYPE1, wbuffer, 256, ltype->ctable);
- MapCtypeMasks(ltype->ctable, ltype->ctable + 256);
- free(wbuffer);
- }
- else {
- unsigned short ctable[256];
- unsigned char TargetBuffer[256];
- GetStringTypeA(ltype->lc.id, CT_CTYPE1, (const char*)Buffer, 256, ctable);
-
- /* Convert character sequence to target code page. */
- BufferSize = MultiByteToWideChar(NativeCP, MB_PRECOMPOSED, (const char*)Buffer, 256, NULL, 0);
- if (!BufferSize) { free(ltype); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
- wbuffer = (wchar_t*)malloc(BufferSize * sizeof(wchar_t));
- if (!wbuffer) { free(ltype); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- MultiByteToWideChar(NativeCP, MB_PRECOMPOSED, (const char*)Buffer, 256, wbuffer, BufferSize);
- if (!WideCharToMultiByte(ltype->cp, WC_COMPOSITECHECK | WC_SEPCHARS, wbuffer, BufferSize, (char*)TargetBuffer, 256, NULL, FALSE))
- { free(wbuffer); free(ltype); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
-
- free(wbuffer);
-
- /* Translate ctype table. */
- for (i = 0; i < 256; ++i) {
- if (!TargetBuffer[i]) continue;
- ltype->ctable[TargetBuffer[i]] = MapCtypeMask(ctable[i]);
- }
- }
- }
- else {
- GetStringTypeA(ltype->lc.id, CT_CTYPE1, (const char*)Buffer, 256, ltype->ctable);
- MapCtypeMasks(ltype->ctable, ltype->ctable + 256);
- }
- return ltype;
-}
-
-_Locale_numeric_t* _Locale_numeric_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
- wchar_t wbuf[4];
- char *GroupingBuffer;
- int BufferSize;
-
- _Locale_numeric_t *lnum = (_Locale_numeric_t*)malloc(sizeof(_Locale_numeric_t));
- if (!lnum) { *__err_code = _STLP_LOC_NO_MEMORY; return lnum; }
- memset(lnum, 0, sizeof(_Locale_numeric_t));
-
- if (__GetLCIDFromName(name, &lnum->lc.id, lnum->cp, lc_hint) == -1)
- { free(lnum); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
-
-#if defined (__BORLANDC__)
- if (lnum->lc.id != INVARIANT_LCID) {
-#endif
- __GetLocaleInfoUsingACP(lnum->lc.id, lnum->cp, LOCALE_SDECIMAL, lnum->decimal_point, 4, wbuf, 4);
- __GetLocaleInfoUsingACP(lnum->lc.id, lnum->cp, LOCALE_STHOUSAND, lnum->thousands_sep, 4, wbuf, 4);
-#if defined (__BORLANDC__)
- }
- else
- lnum->decimal_point[0] = '.';
-#endif
-
- if (lnum->lc.id != INVARIANT_LCID) {
- BufferSize = GetLocaleInfoA(lnum->lc.id, LOCALE_SGROUPING, NULL, 0);
- GroupingBuffer = (char*)malloc(BufferSize);
- if (!GroupingBuffer) { free(lnum); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- GetLocaleInfoA(lnum->lc.id, LOCALE_SGROUPING, GroupingBuffer, BufferSize);
- __FixGrouping(GroupingBuffer);
- lnum->grouping = GroupingBuffer;
- }
- else {
- lnum->grouping = (char*)malloc(1);
- if (!lnum->grouping) { free(lnum); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- lnum->grouping[0] = 0;
- }
-
- return lnum;
-}
-
-static int __ConvertDate(const char *NTDate, char *buffer, int buf_size) {
- /* This function will return an incomplete buffer if buffer is not long enough */
- const char *cur_char;
- char *cur_output, *end_output;
-
- /* Correct time format. */
- cur_char = NTDate;
- cur_output = buffer;
- end_output = cur_output + buf_size;
- buf_size = 0;
- while (*cur_char) {
- if (cur_output && (cur_output == end_output)) break;
- switch (*cur_char) {
- case 'd':
- {
- if (*(cur_char + 1) == 'd') {
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (*(cur_char + 2) == 'd') {
- if (*(cur_char + 3) == 'd') {
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'A'; }
- buf_size += 2;
- cur_char += 3;
- }
- else {
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'a'; }
- buf_size += 2;
- cur_char += 2;
- }
- }
- else {
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'd'; }
- buf_size += 2;
- cur_char++;
- }
- }
- else {
- if (cur_output && (cur_output + 3 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'd'; }
- buf_size += 3;
- }
- }
- break;
- case 'M':
- {
- if (*(cur_char + 1) == 'M') {
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (*(cur_char + 2) == 'M') {
- if (*(cur_char + 3) == 'M') {
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'B'; }
- buf_size += 2;
- cur_char += 3;
- }
- else {
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'b'; }
- buf_size += 2;
- cur_char += 2;
- }
- }
- else {
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'm'; }
- buf_size += 2;
- cur_char++;
- }
- }
- else {
- if (cur_output && (cur_output + 3 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'm'; }
- buf_size += 3;
- }
- }
- break;
- case 'y':
- {
- if (*(cur_char + 1) == 'y') {
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (*(cur_char + 2) == 'y' && *(cur_char + 3) == 'y') {
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'Y'; }
- buf_size += 2;
- cur_char += 3;
- }
- else {
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'y'; }
- buf_size += 2;
- cur_char++;
- }
- }
- else {
- if (cur_output && (cur_output + 3 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'y'; }
- buf_size += 3;
- }
- }
- break;
- case '%':
- {
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '%'; }
- buf_size += 2;
- }
- break;
- case '\'':
- {
- ++cur_char;
- while (*cur_char != '\'' && *cur_char != 0 && (cur_output == NULL || cur_output != end_output)) {
- if (cur_output) { *cur_output++ = *cur_char; }
- ++cur_char;
- buf_size += 1;
- }
- }
- break;
- default:
- {
- if (cur_output) { *(cur_output++) = *cur_char; }
- buf_size += 1;
- }
- break;
- }
- if (*cur_char == 0) break;
- ++cur_char;
- }
-
- if (!cur_output || cur_output != end_output) {
- if (cur_output) *cur_output = 0;
- buf_size += 1;
- }
- else {
- /* We trunc result */
- *(--cur_output) = 0;
- }
-
- return buf_size;
-}
-
-static int __ConvertTime(const char *NTTime, char *buffer, int buf_size) {
- const char *cur_char;
- char *cur_output, *end_output;
- cur_char = NTTime;
- cur_output = buffer;
- end_output = cur_output + buf_size;
- buf_size = 0;
- while (*cur_char) {
- switch(*cur_char) {
- case 'h':
- if (*(cur_char + 1) == 'h') {
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'I'; }
- buf_size += 2;
- ++cur_char;
- }
- else {
- if (cur_output && (cur_output + 3 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'I'; }
- buf_size += 3;
- }
- break;
- case 'H':
- if (*(cur_char + 1) == 'H') {
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'H'; }
- buf_size += 2;
- ++cur_char;
- }
- else {
- if (cur_output && (cur_output + 3 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'H'; }
- buf_size += 3;
- }
- break;
- case 'm':
- if (*(cur_char + 1) == 'm') {
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'M'; }
- buf_size += 2;
- cur_char++;
- }
- else {
- if (cur_output && (cur_output + 3 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'M'; }
- buf_size += 3;
- }
- break;
- case 's':
- if (*(cur_char + 1) == 's') {
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'S'; }
- buf_size += 2;
- ++cur_char;
- }
- else {
- if (cur_output && (cur_output + 3 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = '#'; *(cur_output++) = 'S'; }
- buf_size += 3;
- }
- break;
- case 't':
- if (*(cur_char + 1) == 't')
- ++cur_char;
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++) = '%'; *(cur_output++) = 'p'; }
- buf_size += 2;
- break;
- case '%':
- if (cur_output && (cur_output + 2 > end_output)) {
- *cur_output = 0;
- return ++buf_size;
- }
- if (cur_output) { *(cur_output++)='%'; *(cur_output++)='%'; }
- buf_size += 2;
- break;
- case '\'':
- ++cur_char;
- while (*cur_char != '\'' && *cur_char != 0 && (!cur_output || (cur_output != end_output))) {
- if (cur_output) *cur_output++ = *cur_char;
- ++cur_char;
- buf_size += 1;
- }
- break;
- default:
- if (cur_output) { *(cur_output++) = *cur_char; }
- buf_size += 1;
- break;
- }
- if (*cur_char == 0) break;
- ++cur_char;
- }
-
- if (!cur_output || cur_output != end_output) {
- if (cur_output) *cur_output = 0;
- buf_size += 1;
- }
- else {
- /* We trunc result */
- *(--cur_output) = 0;
- }
-
- return buf_size;
-}
-
-_Locale_time_t* _Locale_time_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
- int size, month, dayofweek;
- size_t length;
- char fmt80[80];
- wchar_t wbuf80[80];
-
- _Locale_time_t *ltime = (_Locale_time_t*)malloc(sizeof(_Locale_time_t));
-
- if (!ltime) { *__err_code = _STLP_LOC_NO_MEMORY; return ltime; }
- memset(ltime, 0, sizeof(_Locale_time_t));
-
- if (__GetLCIDFromName(name, <ime->lc.id, ltime->cp, lc_hint) == -1)
- { free(ltime); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
-
-#if defined (__BORLANDC__)
- if ( ltime->lc.id == INVARIANT_LCID && name[0] == 'C' && name[1] == 0 )
- { ltime->lc.id = 0x409; }
-#endif
-
- for (month = LOCALE_SMONTHNAME1; month <= LOCALE_SMONTHNAME12; ++month) { /* Small hack :-) */
- size = GetLocaleInfoA(ltime->lc.id, month, NULL, 0);
- ltime->month[month - LOCALE_SMONTHNAME1] = (char*)malloc(size);
- if (!ltime->month[month - LOCALE_SMONTHNAME1])
- { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, month, ltime->month[month - LOCALE_SMONTHNAME1], size, wbuf80, 80);
- }
-
- for (month = LOCALE_SABBREVMONTHNAME1; month <= LOCALE_SABBREVMONTHNAME12; ++month) {
- size = GetLocaleInfoA(ltime->lc.id, month, NULL, 0);
- ltime->abbrev_month[month - LOCALE_SABBREVMONTHNAME1] = (char*)malloc(size);
- if (!ltime->abbrev_month[month - LOCALE_SABBREVMONTHNAME1])
- { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, month, ltime->abbrev_month[month - LOCALE_SABBREVMONTHNAME1], size, wbuf80, 80);
- }
-
- for (dayofweek = LOCALE_SDAYNAME1; dayofweek <= LOCALE_SDAYNAME7; ++dayofweek) {
- int dayindex = ( dayofweek != LOCALE_SDAYNAME7 ) ? dayofweek - LOCALE_SDAYNAME1 + 1 : 0;
- size = GetLocaleInfoA(ltime->lc.id, dayofweek, NULL, 0);
- ltime->dayofweek[dayindex] = (char*)malloc(size);
- if (!ltime->dayofweek[dayindex])
- { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, dayofweek, ltime->dayofweek[dayindex], size, wbuf80, 80);
- }
-
- for (dayofweek = LOCALE_SABBREVDAYNAME1; dayofweek <= LOCALE_SABBREVDAYNAME7; ++dayofweek) {
- int dayindex = ( dayofweek != LOCALE_SABBREVDAYNAME7 ) ? dayofweek - LOCALE_SABBREVDAYNAME1 + 1 : 0;
- size = GetLocaleInfoA(ltime->lc.id, dayofweek, NULL, 0);
- ltime->abbrev_dayofweek[dayindex] = (char*)malloc(size);
- if (!ltime->abbrev_dayofweek[dayindex])
- { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, dayofweek, ltime->abbrev_dayofweek[dayindex], size, wbuf80, 80);
- }
-
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_SSHORTDATE, fmt80, 80, wbuf80, 80);
- size = __ConvertDate(fmt80, NULL, 0);
- ltime->date_format = (char*)malloc(size);
- if (!ltime->date_format)
- { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- __ConvertDate(fmt80, ltime->date_format, size);
-
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_SLONGDATE, fmt80, 80, wbuf80, 80);
- size = __ConvertDate(fmt80, NULL, 0);
- ltime->long_date_format = (char*)malloc(size);
- if (!ltime->long_date_format)
- { _Locale_time_destroy(ltime);*__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- __ConvertDate(fmt80, ltime->long_date_format, size);
-
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_STIMEFORMAT, fmt80, 80, wbuf80, 80);
- size = __ConvertTime(fmt80, NULL, 0);
- ltime->time_format = (char*)malloc(size);
- if (!ltime->time_format)
- { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- __ConvertTime(fmt80, ltime->time_format, size);
-
- /* NT doesn't provide this information, we must simulate. */
- length = strlen(ltime->date_format) + strlen(ltime->time_format) + 1 /* space */ + 1 /* trailing 0 */;
- ltime->date_time_format = (char*)malloc(length);
- if (!ltime->date_time_format)
- { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- _STLP_STRCPY(ltime->date_time_format, length, ltime->date_format);
- _STLP_STRCAT(ltime->date_time_format, length, " ");
- _STLP_STRCAT(ltime->date_time_format, length, ltime->time_format);
-
- /* NT doesn't provide this information, we must simulate. */
- length = strlen(ltime->long_date_format) + strlen(ltime->time_format) + 1 /* space */ + 1 /* trailing 0 */;
- ltime->long_date_time_format = (char*)malloc(length);
- if (!ltime->long_date_time_format)
- { _Locale_time_destroy(ltime); *__err_code = _STLP_LOC_NO_MEMORY; return NULL; }
- _STLP_STRCPY(ltime->long_date_time_format, length, ltime->long_date_format);
- _STLP_STRCAT(ltime->long_date_time_format, length, " ");
- _STLP_STRCAT(ltime->long_date_time_format, length, ltime->time_format);
-
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_S1159, ltime->am, 9, wbuf80, 80);
- __GetLocaleInfoUsingACP(ltime->lc.id, ltime->cp, LOCALE_S2359, ltime->pm, 9, wbuf80, 80);
-
- return ltime;
-}
-
-_Locale_collate_t* _Locale_collate_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
- _Locale_collate_t *lcol = (_Locale_collate_t*)malloc(sizeof(_Locale_collate_t));
- if (!lcol) { *__err_code = _STLP_LOC_NO_MEMORY; return lcol; }
- memset(lcol, 0, sizeof(_Locale_collate_t));
-
- if (__GetLCIDFromName(name, &lcol->lc.id, lcol->cp, lc_hint) == -1)
- { free(lcol); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
-
-#if defined (__BORLANDC__)
- if ( lcol->lc.id == INVARIANT_LCID && name[0] == 'C' && name[1] == 0 )
- { lcol->lc.id = 0x409; }
-#endif
-
- return lcol;
-}
-
-_Locale_monetary_t* _Locale_monetary_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
- char *GroupingBuffer;
- int BufferSize;
- char FracDigits[3];
- wchar_t wbuf[6];
-
- _Locale_monetary_t *lmon = (_Locale_monetary_t*)malloc(sizeof(_Locale_monetary_t));
- if (!lmon) { *__err_code = _STLP_LOC_NO_MEMORY; return lmon; }
- memset(lmon, 0, sizeof(_Locale_monetary_t));
-
- if (__GetLCIDFromName(name, &lmon->lc.id, lmon->cp, lc_hint) == -1)
- { free(lmon); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
-
- if (lmon->lc.id != INVARIANT_LCID) {
- /* Extract information about monetary system */
- __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SDECIMAL, lmon->decimal_point, 4, wbuf, 6);
- __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_STHOUSAND, lmon->thousands_sep, 4, wbuf, 6);
-
- BufferSize = GetLocaleInfoA(lmon->lc.id, LOCALE_SGROUPING, NULL, 0);
- GroupingBuffer = (char*)malloc(BufferSize);
- if (!GroupingBuffer)
- { lmon->grouping = NULL; *__err_code = _STLP_LOC_NO_MEMORY; return lmon; }
- GetLocaleInfoA(lmon->lc.id, LOCALE_SGROUPING, GroupingBuffer, BufferSize);
- __FixGrouping(GroupingBuffer);
- lmon->grouping = GroupingBuffer;
-
- __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SCURRENCY, lmon->curr_symbol, 6, wbuf, 6);
- __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SNEGATIVESIGN, lmon->negative_sign, 5, wbuf, 6);
- __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SPOSITIVESIGN, lmon->positive_sign, 5, wbuf, 6);
-
- GetLocaleInfoA(lmon->lc.id, LOCALE_ICURRDIGITS, FracDigits, 3);
- lmon->frac_digits = atoi(FracDigits);
-
- GetLocaleInfoA(lmon->lc.id, LOCALE_IINTLCURRDIGITS, FracDigits, 3);
- lmon->int_frac_digits = atoi(FracDigits);
-
- __GetLocaleInfoUsingACP(lmon->lc.id, lmon->cp, LOCALE_SINTLSYMBOL, lmon->int_curr_symbol, 5, wbuf, 6);
- /* Even if Platform SDK documentation says that the returned symbol should
- * be a 3 letters symbol followed by a seperation character, experimentation
- * has shown that no seperation character is ever appended. We are adding it
- * ourself to conform to the POSIX specification.
- */
- if (lmon->int_curr_symbol[3] == 0) {
- lmon->int_curr_symbol[3] = ' ';
- lmon->int_curr_symbol[4] = 0;
- }
- }
- /* else it is already ok */
-
- return lmon;
-}
-
-struct _Locale_messages* _Locale_messages_create(const char *name, _Locale_lcid_t* lc_hint, int *__err_code) {
- /* The Win32 API has no support for messages facet */
- _STLP_MARK_PARAMETER_AS_UNUSED(name)
- _STLP_MARK_PARAMETER_AS_UNUSED(lc_hint)
- *__err_code = _STLP_LOC_UNSUPPORTED_FACET_CATEGORY;
- return NULL;
-}
-
-static const char* _Locale_common_default(char* buf) {
- char cp[MAX_CP_LEN + 1];
- int CodePage = __GetDefaultCP(LOCALE_USER_DEFAULT);
- my_ltoa(CodePage, cp);
- return __GetLocaleName(LOCALE_USER_DEFAULT, cp, buf);
-}
-
-const char* _Locale_ctype_default(char* buf)
-{ return _Locale_common_default(buf); }
-
-const char* _Locale_numeric_default(char * buf)
-{ return _Locale_common_default(buf); }
-
-const char* _Locale_time_default(char* buf)
-{ return _Locale_common_default(buf); }
-
-const char* _Locale_collate_default(char* buf)
-{ return _Locale_common_default(buf); }
-
-const char* _Locale_monetary_default(char* buf)
-{ return _Locale_common_default(buf); }
-
-const char* _Locale_messages_default(char* buf)
-{ return _Locale_common_default(buf); }
-
-char const* _Locale_ctype_name(const _Locale_ctype_t* ltype, char* buf) {
- char cp_buf[MAX_CP_LEN + 1];
- my_ltoa(ltype->cp, cp_buf);
- return __GetLocaleName(ltype->lc.id, cp_buf, buf);
-}
-
-char const* _Locale_numeric_name(const _Locale_numeric_t* lnum, char* buf)
-{ return __GetLocaleName(lnum->lc.id, lnum->cp, buf); }
-
-char const* _Locale_time_name(const _Locale_time_t* ltime, char* buf)
-{ return __GetLocaleName(ltime->lc.id, ltime->cp, buf); }
-
-char const* _Locale_collate_name(const _Locale_collate_t* lcol, char* buf)
-{ return __GetLocaleName(lcol->lc.id, lcol->cp, buf); }
-
-char const* _Locale_monetary_name(const _Locale_monetary_t* lmon, char* buf)
-{ return __GetLocaleName(lmon->lc.id, lmon->cp, buf); }
-
-char const* _Locale_messages_name(const struct _Locale_messages* lmes, char* buf) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lmes)
- _STLP_MARK_PARAMETER_AS_UNUSED(buf)
- return NULL;
-}
-
-void _Locale_ctype_destroy(_Locale_ctype_t* ltype) {
- if (!ltype) return;
-
- free(ltype);
-}
-
-void _Locale_numeric_destroy(_Locale_numeric_t* lnum) {
- if (!lnum) return;
-
- if (lnum->grouping) free(lnum->grouping);
- free(lnum);
-}
-
-void _Locale_time_destroy(_Locale_time_t* ltime) {
- int i;
- if (!ltime) return;
-
- for (i = 0; i < 12; ++i) {
- if (ltime->month[i]) free(ltime->month[i]);
- if (ltime->abbrev_month[i]) free(ltime->abbrev_month[i]);
- }
-
- for (i = 0; i < 7; ++i) {
- if (ltime->dayofweek[i]) free(ltime->dayofweek[i]);
- if (ltime->abbrev_dayofweek[i]) free(ltime->abbrev_dayofweek[i]);
- }
-
- if (ltime->date_format) free(ltime->date_format);
- if (ltime->long_date_format) free(ltime->long_date_format);
- if (ltime->time_format) free(ltime->time_format);
- if (ltime->date_time_format) free(ltime->date_time_format);
- if (ltime->long_date_time_format) free(ltime->long_date_time_format);
-
- free(ltime);
-}
-
-void _Locale_collate_destroy(_Locale_collate_t* lcol) {
- if (!lcol) return;
-
- free(lcol);
-}
-
-void _Locale_monetary_destroy(_Locale_monetary_t* lmon) {
- if (!lmon) return;
-
- if (lmon->grouping) free(lmon->grouping);
- free(lmon);
-}
-
-void _Locale_messages_destroy(struct _Locale_messages* lmes)
-{ _STLP_MARK_PARAMETER_AS_UNUSED(lmes) }
-
-static char const* _Locale_extract_category_name(const char* name, const char* category, char* buf,
- _Locale_lcid_t* hint, int *__err_code) {
- const char* cname = __Extract_locale_name(name, category, buf);
- if (cname == 0 || (cname[0] == 'C' && cname[1] == 0)) {
- return cname;
- }
- return __TranslateToSystem(cname, buf, hint, __err_code);
-}
-
-char const* _Locale_extract_ctype_name(const char* cname, char* buf,
- _Locale_lcid_t* hint, int *__err_code)
-{ return _Locale_extract_category_name(cname, "LC_CTYPE", buf, hint, __err_code); }
-
-char const* _Locale_extract_numeric_name(const char* cname, char* buf,
- _Locale_lcid_t* hint, int *__err_code)
-{ return _Locale_extract_category_name(cname, "LC_NUMERIC", buf, hint, __err_code); }
-
-char const* _Locale_extract_time_name(const char* cname, char* buf,
- _Locale_lcid_t* hint, int *__err_code)
-{ return _Locale_extract_category_name(cname, "LC_TIME", buf, hint, __err_code); }
-
-char const* _Locale_extract_collate_name(const char* cname, char* buf,
- _Locale_lcid_t* hint, int *__err_code)
-{ return _Locale_extract_category_name(cname, "LC_COLLATE", buf, hint, __err_code); }
-
-char const* _Locale_extract_monetary_name(const char* cname, char* buf,
- _Locale_lcid_t* hint, int *__err_code)
-{ return _Locale_extract_category_name(cname, "LC_MONETARY", buf, hint, __err_code); }
-
-char const* _Locale_extract_messages_name(const char* cname, char* buf,
- _Locale_lcid_t* hint, int *__err_code) {
- if (cname[0] == 'L' && cname[1] == 'C' && cname[2] == '_') {
- return _C_name;
- }
- if (cname[0] == 'C' && cname[1] == 0) {
- return _C_name;
- }
- return __TranslateToSystem(cname, buf, hint, __err_code);
-}
-
-/* ctype */
-
-const _Locale_mask_t* _Locale_ctype_table(_Locale_ctype_t* ltype) {
- _STLP_STATIC_ASSERT(sizeof(_Locale_mask_t) == sizeof(ltype->ctable[0]))
- return (const _Locale_mask_t*)ltype->ctable;
-}
-
-int _Locale_toupper(_Locale_ctype_t* ltype, int c) {
- char buf[2], out_buf[2];
- buf[0] = (char)c; buf[1] = 0;
- if ((UINT)__GetDefaultCP(ltype->lc.id) == ltype->cp) {
- LCMapStringA(ltype->lc.id, LCMAP_LINGUISTIC_CASING | LCMAP_UPPERCASE, buf, 2, out_buf, 2);
- return out_buf[0];
- }
- else {
- wchar_t wbuf[2];
- MultiByteToWideChar(ltype->cp, MB_PRECOMPOSED, buf, 2, wbuf, 2);
- WideCharToMultiByte(__GetDefaultCP(ltype->lc.id), WC_COMPOSITECHECK | WC_SEPCHARS, wbuf, 2, buf, 2, NULL, FALSE);
-
- LCMapStringA(ltype->lc.id, LCMAP_LINGUISTIC_CASING | LCMAP_UPPERCASE, buf, 2, out_buf, 2);
-
- MultiByteToWideChar(__GetDefaultCP(ltype->lc.id), MB_PRECOMPOSED, out_buf, 2, wbuf, 2);
- WideCharToMultiByte(ltype->cp, WC_COMPOSITECHECK | WC_SEPCHARS, wbuf, 2, out_buf, 2, NULL, FALSE);
- return out_buf[0];
- }
-}
-
-int _Locale_tolower(_Locale_ctype_t* ltype, int c) {
- char buf[2], out_buf[2];
- buf[0] = (char)c; buf[1] = 0;
- if ((UINT)__GetDefaultCP(ltype->lc.id) == ltype->cp) {
- LCMapStringA(ltype->lc.id, LCMAP_LINGUISTIC_CASING | LCMAP_LOWERCASE, buf, 2, out_buf, 2);
- return out_buf[0];
- }
- else {
- wchar_t wbuf[2];
- MultiByteToWideChar(ltype->cp, MB_PRECOMPOSED, buf, 2, wbuf, 2);
- WideCharToMultiByte(__GetDefaultCP(ltype->lc.id), WC_COMPOSITECHECK | WC_SEPCHARS, wbuf, 2, buf, 2, NULL, FALSE);
-
- LCMapStringA(ltype->lc.id, LCMAP_LINGUISTIC_CASING | LCMAP_LOWERCASE, buf, 2, out_buf, 2);
-
- MultiByteToWideChar(__GetDefaultCP(ltype->lc.id), MB_PRECOMPOSED, out_buf, 2, wbuf, 2);
- WideCharToMultiByte(ltype->cp, WC_COMPOSITECHECK | WC_SEPCHARS, wbuf, 2, out_buf, 2, NULL, FALSE);
- return out_buf[0];
- }
-}
-
-#ifndef CSTR_EQUAL /* VC5SP3*/
-# define CSTR_EQUAL 2
-#endif
-#ifndef CSTR_LESS_THAN /* VC5SP3 */
-# define CSTR_LESS_THAN 1
-#endif
-
-static DWORD max_DWORD = 0xffffffff;
-static DWORD trim_size_t_to_DWORD(size_t n) { return n < (size_t)max_DWORD ? (DWORD)n : max_DWORD; }
-
-/* Collate */
-/* This function takes care of the potential size_t DWORD different size. */
-static int _Locale_strcmp_auxA(_Locale_collate_t* lcol,
- const char* s1, size_t n1,
- const char* s2, size_t n2) {
- int result = CSTR_EQUAL;
- while (n1 > 0 || n2 > 0) {
- DWORD size1 = trim_size_t_to_DWORD(n1);
- DWORD size2 = trim_size_t_to_DWORD(n2);
- result = CompareStringA(lcol->lc.id, 0, s1, size1, s2, size2);
- if (result != CSTR_EQUAL)
- break;
- n1 -= size1;
- n2 -= size2;
- }
- return result;
-}
-
-int _Locale_strcmp(_Locale_collate_t* lcol,
- const char* s1, size_t n1,
- const char* s2, size_t n2) {
- int result;
- if (__GetDefaultCP(lcol->lc.id) == atoi(lcol->cp)) {
- result = _Locale_strcmp_auxA(lcol, s1, n1, s2, n2);
- }
- else {
- char *buf1, *buf2;
- size_t size1, size2;
- buf1 = __ConvertToCP(atoi(lcol->cp), __GetDefaultCP(lcol->lc.id), s1, n1, &size1);
- buf2 = __ConvertToCP(atoi(lcol->cp), __GetDefaultCP(lcol->lc.id), s2, n2, &size2);
-
- result = _Locale_strcmp_auxA(lcol, buf1, size1, buf2, size2);
- free(buf1); free(buf2);
- }
- return (result == CSTR_EQUAL) ? 0 : (result == CSTR_LESS_THAN) ? -1 : 1;
-}
-
-size_t _Locale_strxfrm(_Locale_collate_t* lcol,
- char* dst, size_t dst_size,
- const char* src, size_t src_size) {
- int result;
-
- /* The Windows API do not support transformation of very long strings (src_size > INT_MAX)
- * In this case the result will just be the input string:
- */
- if (src_size > INT_MAX) {
- if (dst != 0) {
- _STLP_STRNCPY(dst, dst_size, src, src_size);
- }
- return src_size;
- }
- if (dst_size > INT_MAX) {
- /* now that we know that src_size <= INT_MAX we can safely decrease dst_size to INT_MAX. */
- dst_size = INT_MAX;
- }
-
- if (__GetDefaultCP(lcol->lc.id) == atoi(lcol->cp))
- result = LCMapStringA(lcol->lc.id, LCMAP_SORTKEY, src, (int)src_size, dst, (int)dst_size);
- else {
- char *buf;
- size_t size;
- buf = __ConvertToCP(atoi(lcol->cp), __GetDefaultCP(lcol->lc.id), src, src_size, &size);
-
- result = LCMapStringA(lcol->lc.id, LCMAP_SORTKEY, buf, (int)size, dst, (int)dst_size);
- free(buf);
- }
- return result != 0 ? result - 1 : 0;
-}
-
-/* Numeric */
-static const char* __true_name = "true";
-static const char* __false_name = "false";
-
-char _Locale_decimal_point(_Locale_numeric_t* lnum)
-{ return lnum->decimal_point[0]; }
-
-char _Locale_thousands_sep(_Locale_numeric_t* lnum)
-{ return lnum->thousands_sep[0]; }
-
-const char* _Locale_grouping(_Locale_numeric_t * lnum) {
- if (!lnum->grouping) return "";
- else return lnum->grouping;
-}
-
-const char * _Locale_true(_Locale_numeric_t * lnum) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lnum)
- return __true_name; /* NT does't provide information about this */
-}
-
-const char * _Locale_false(_Locale_numeric_t * lnum) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lnum)
- return __false_name; /* NT does't provide information about this */
-}
-
-/* Monetary */
-const char* _Locale_int_curr_symbol(_Locale_monetary_t * lmon)
-{ return lmon->int_curr_symbol; }
-
-const char* _Locale_currency_symbol(_Locale_monetary_t * lmon)
-{ return lmon->curr_symbol; }
-
-char _Locale_mon_decimal_point(_Locale_monetary_t * lmon)
-{ return lmon->decimal_point[0]; }
-
-char _Locale_mon_thousands_sep(_Locale_monetary_t * lmon)
-{ return lmon->thousands_sep[0]; }
-
-const char* _Locale_mon_grouping(_Locale_monetary_t * lmon) {
- if (!lmon->grouping) return "";
- else return lmon->grouping;
-}
-
-const char* _Locale_positive_sign(_Locale_monetary_t * lmon)
-{ return lmon->positive_sign; }
-
-const char* _Locale_negative_sign(_Locale_monetary_t * lmon)
-{ return lmon->negative_sign; }
-
-char _Locale_int_frac_digits(_Locale_monetary_t * lmon)
-{ return (char)lmon->int_frac_digits; }
-
-char _Locale_frac_digits(_Locale_monetary_t * lmon)
-{ return (char)lmon->frac_digits; }
-
-int _Locale_p_cs_precedes(_Locale_monetary_t * lmon) {
- char loc_data[2];
- GetLocaleInfoA(lmon->lc.id, LOCALE_IPOSSYMPRECEDES, loc_data, 2);
- if (loc_data[0] == '0') return 0;
- else if (loc_data[0] == '1') return 1;
- else return -1;
-}
-
-int _Locale_p_sep_by_space(_Locale_monetary_t * lmon) {
- char loc_data[2];
- GetLocaleInfoA(lmon->lc.id, LOCALE_IPOSSEPBYSPACE, loc_data, 2);
- if (loc_data[0] == '0') return 0;
- else if (loc_data[0] == '1') return 1;
- else return -1;
-}
-
-int _Locale_p_sign_posn(_Locale_monetary_t * lmon) {
- char loc_data[2];
- if (lmon->lc.id != INVARIANT_LCID) {
- GetLocaleInfoA(lmon->lc.id, LOCALE_IPOSSIGNPOSN, loc_data, 2);
- return atoi(loc_data);
- }
- else {
- return CHAR_MAX;
- }
-}
-
-int _Locale_n_cs_precedes(_Locale_monetary_t * lmon) {
- char loc_data[2];
- GetLocaleInfoA(lmon->lc.id, LOCALE_INEGSYMPRECEDES, loc_data, 2);
- if (loc_data[0] == '0') return 0;
- else if (loc_data[0] == '1') return 1;
- else return -1;
-}
-
-int _Locale_n_sep_by_space(_Locale_monetary_t * lmon) {
- char loc_data[2];
- GetLocaleInfoA(lmon->lc.id, LOCALE_INEGSEPBYSPACE, loc_data, 2);
- if (loc_data[0] == '0') return 0;
- else if (loc_data[0] == '1') return 1;
- else return -1;
-}
-
-int _Locale_n_sign_posn(_Locale_monetary_t * lmon) {
- char loc_data[2];
- if (lmon->lc.id != INVARIANT_LCID) {
- GetLocaleInfoA(lmon->lc.id, LOCALE_INEGSIGNPOSN, loc_data, 2);
- return atoi(loc_data);
- }
- else {
- return CHAR_MAX;
- }
-}
-
-/* Time */
-const char * _Locale_full_monthname(_Locale_time_t * ltime, int month) {
- const char **names = (const char**)ltime->month;
- return names[month];
-}
-
-const char * _Locale_abbrev_monthname(_Locale_time_t * ltime, int month) {
- const char **names = (const char**)ltime->abbrev_month;
- return names[month];
-}
-
-const char * _Locale_full_dayofweek(_Locale_time_t * ltime, int day) {
- const char **names = (const char**)ltime->dayofweek;
- return names[day];
-}
-
-const char * _Locale_abbrev_dayofweek(_Locale_time_t * ltime, int day) {
- const char **names = (const char**)ltime->abbrev_dayofweek;
- return names[day];
-}
-
-const char* _Locale_d_t_fmt(_Locale_time_t* ltime)
-{ return ltime->date_time_format; }
-
-const char* _Locale_long_d_t_fmt(_Locale_time_t* ltime)
-{ return ltime->long_date_time_format; }
-
-const char* _Locale_d_fmt(_Locale_time_t* ltime)
-{ return ltime->date_format; }
-
-const char* _Locale_long_d_fmt(_Locale_time_t* ltime)
-{ return ltime->long_date_format; }
-
-const char* _Locale_t_fmt(_Locale_time_t* ltime)
-{ return ltime->time_format; }
-
-const char* _Locale_am_str(_Locale_time_t* ltime)
-{ return ltime->am; }
-
-const char* _Locale_pm_str(_Locale_time_t* ltime)
-{ return ltime->pm; }
-
-/* Messages */
-nl_catd_type _Locale_catopen(struct _Locale_messages* lmes, const char* cat_name) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lmes)
- _STLP_MARK_PARAMETER_AS_UNUSED(cat_name)
- return -1;
-}
-void _Locale_catclose(struct _Locale_messages* lmes, nl_catd_type cat) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lmes)
- _STLP_MARK_PARAMETER_AS_UNUSED(&cat)
-}
-const char* _Locale_catgets(struct _Locale_messages* lmes, nl_catd_type cat,
- int setid, int msgid, const char *dfault) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lmes)
- _STLP_MARK_PARAMETER_AS_UNUSED(&cat)
- _STLP_MARK_PARAMETER_AS_UNUSED(&setid)
- _STLP_MARK_PARAMETER_AS_UNUSED(&msgid)
- return dfault;
-}
-
-#ifdef __cplusplus
-} /* extern C */
-_STLP_END_NAMESPACE
-#endif
-
-void __FixGrouping(char *grouping) {
- /* This converts NT version which uses '0' instead of 0, etc ; to ANSI */
- char *g = grouping;
- char building_group = 0;
- char repeat_last = 0;
- /* Check there is a grouping info otherwise we would add a useless CHAR_MAX */
- if (*g) {
- for (; *g; ++g) {
- if (*g > '0' && *g <= '9') {
- if (!building_group) {
- *grouping = *g - '0';
- building_group = 1;
- }
- else {
- /* Known issue: grouping might roll. */
- *grouping = *grouping * 10 + *g - '0';
- }
- }
- else if (*g == '0') {
- if (!building_group) {
- repeat_last = 1;
- }
- else
- /* Known issue: grouping might roll. */
- *grouping *= 10;
- }
- else if (*g == ';') {
- /* Stop adding to the current group */
- building_group = 0;
- ++grouping;
- }
- /* else we ignore the character */
- }
-
- if (!repeat_last)
- *grouping++ = CHAR_MAX;
- *grouping = 0;
- }
-}
-
-const char* __ConvertName(const char* lname, LOCALECONV* ConvTable, int TableSize) {
- int i;
- int cmp;
- int low = 0;
- int high = TableSize - 1;
-
- /* typical binary search - do until no more to search or match */
- while (low <= high) {
- i = (low + high) / 2;
-
- if ((cmp = lstrcmpiA(lname, (*(ConvTable + i)).name)) == 0)
- return (*(ConvTable + i)).abbrev;
- else if (cmp < 0)
- high = i - 1;
- else
- low = i + 1;
- }
- return lname;
-}
-
-int __ParseLocaleString(const char* lname,
- char* lang, char* ctry, char* page) {
- int param = 0;
- size_t len;
- size_t tmpLen;
-
- if (lname[0] == 0)
- return 0;
-
- /* We look for the first country separator '_' */
- len = strcspn(lname, "_");
- if (lname[len] == '_') {
- if (len == 0 || len > MAX_LANG_LEN) return -1; /* empty lang is invalid*/
- _STLP_STRNCPY(lang, MAX_LANG_LEN + 1, lname, len);
- lname += len + 1;
- ++param;
- }
-
- /* We look for the last code page separator '.' */
- len = -1;
- tmpLen = strcspn(lname, ".");
- while (lname[tmpLen] == '.') {
- len = tmpLen; ++tmpLen;
- tmpLen += strcspn(lname + tmpLen, ".");
- }
- if (len != -1) { /* Means that we found a '.' */
- if (param == 0) {
- /* We have no lang yet so we have to fill it first, no country */
- if (len > MAX_LANG_LEN) return -1;
- if (len == 0) {
- /* No language nor country, only code page */
- ++param;
- }
- else
- { _STLP_STRNCPY(lang, MAX_LANG_LEN + 1, lname, len); }
- ++param;
- }
- else {
- /* We already have a lang so we are now looking for the country: */
- if (len == 0) return -1; /* We forbid locale name with the "_." motif in it */
- if (len > MAX_CTRY_LEN) return -1;
- _STLP_STRNCPY(ctry, MAX_CTRY_LEN + 1, lname, len);
- }
- ++param;
- lname += len + 1;
- }
-
- /* We look for ',' for compatibility with POSIX */
- len = strcspn(lname, ",");
- switch (param) {
- case 0:
- if (len > MAX_LANG_LEN) return -1;
- _STLP_STRNCPY(lang, MAX_LANG_LEN + 1, lname, len);
- break;
- case 1:
- if (len > MAX_CTRY_LEN) return -1;
- _STLP_STRNCPY(ctry, MAX_CTRY_LEN + 1, lname, len);
- break;
- default:
- if (len > MAX_CP_LEN) return -1;
- _STLP_STRNCPY(page, MAX_CP_LEN + 1, lname, len);
- break;
- }
-
- /* ',' POSIX modifier is not used in NT */
- return 0;
-}
-
-/* Data necessary for find LCID*/
-static CRITICAL_SECTION __criticalSection;
-static int __FindFlag;
-static LCID __FndLCID;
-static const char* __FndLang;
-static const char* __FndCtry;
-
-void _Locale_init()
-{ InitializeCriticalSection(&__criticalSection); }
-
-void _Locale_final()
-{ DeleteCriticalSection(&__criticalSection); }
-
-static LCID LocaleFromHex(const char* locale) {
- unsigned long result = 0;
- int digit;
- while (*locale) {
- result <<= 4;
- digit = (*locale >= '0' && *locale <= '9') ? *locale - '0':
- (*locale >= 'A' && *locale <= 'F') ? (*locale - 'A') + 10
- : (*locale - 'a') + 10;
- result += digit;
- ++locale;
- }
- return (LCID)result;
-}
-
-static BOOL CALLBACK EnumLocalesProcA(LPSTR locale) {
- LCID lcid = LocaleFromHex(locale);
- int LangFlag = 0, CtryFlag = !__FndCtry;
- static char Lang[MAX_LANG_LEN], Ctry[MAX_CTRY_LEN];
-
- GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE, Lang, MAX_LANG_LEN);
- if (lstrcmpiA(Lang, __FndLang) != 0) {
- GetLocaleInfoA(lcid, LOCALE_SABBREVLANGNAME, Lang, MAX_LANG_LEN);
- if (lstrcmpiA(Lang, __FndLang) != 0) {
- GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME, Lang, MAX_LANG_LEN);
- if (lstrcmpiA(Lang, __FndLang) == 0) LangFlag = 1;
- }
- else LangFlag = 1;
- }
- else LangFlag = 1;
-
- if (__FndCtry) {
- GetLocaleInfoA(lcid, LOCALE_SENGCOUNTRY, Ctry, MAX_CTRY_LEN);
- if (lstrcmpiA(Ctry, __FndCtry) != 0) {
- GetLocaleInfoA(lcid, LOCALE_SABBREVCTRYNAME, Ctry, MAX_CTRY_LEN);
- if (lstrcmpiA(Ctry, __FndCtry) != 0) {
- GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, Ctry, MAX_CTRY_LEN);
- if (lstrcmpiA(Ctry, __FndCtry) == 0) CtryFlag = 1;
- }
- else CtryFlag = 1;
- }
- else
- CtryFlag = 1;
- }
-
- if (LangFlag && CtryFlag) {
- __FindFlag = 1;
- __FndLCID = lcid;
- return FALSE;
- }
-
- return TRUE;
-}
-
-int __GetLCID(const char* lang, const char* ctry, LCID* lcid) {
- int ret;
- EnterCriticalSection(&__criticalSection);
-
- __FindFlag = 0;
- __FndLang = lang;
- __FndCtry = ctry;
- EnumSystemLocalesA(EnumLocalesProcA, LCID_INSTALLED);
-
- if (__FindFlag != 0) *lcid = __FndLCID;
- ret = __FindFlag != 0 ? 0 : -1;
-
- LeaveCriticalSection(&__criticalSection);
- return ret;
-}
-
-int __GetLCIDFromName(const char* lname, LCID* lcid, char* cp, _Locale_lcid_t *hint) {
- char lang[MAX_LANG_LEN + 1], ctry[MAX_CTRY_LEN + 1], page[MAX_CP_LEN + 1];
- int result = 0;
- if (lname == NULL || lname[0] == 0) {
- *lcid = LOCALE_USER_DEFAULT;
- return 0;
- }
-
- memset(lang, 0, MAX_LANG_LEN + 1);
- memset(ctry, 0, MAX_CTRY_LEN + 1);
- memset(page, 0, MAX_CP_LEN + 1);
- if (__ParseLocaleString(lname, lang, ctry, page) == -1) return -1;
-
- if (hint != 0) {
- *lcid = hint->id;
- }
- else {
- if (lang[0] == 0 && ctry[0] == 0)
- *lcid = LOCALE_USER_DEFAULT; /* Only code page given. */
- else {
- if (ctry[0] == 0) {
- result = __GetLCID(__ConvertName(lang, __rg_language, sizeof(__rg_language) / sizeof(LOCALECONV)), NULL, lcid);
- if (result != 0) {
- /* Check 'C' special case. Check is done after call to __GetLCID because normal programs do not
- * generate facet from 'C' name, they use the locale::classic() facets. */
- if (lang[0] == 'C' && lang[1] == 0) {
- *lcid = INVARIANT_LCID;
- result = 0;
- }
- }
- }
- else {
- result = __GetLCID(__ConvertName(lang, __rg_language, sizeof(__rg_language) / sizeof(LOCALECONV)),
- __ConvertName(ctry, __rg_country, sizeof(__rg_country) / sizeof(LOCALECONV)),
- lcid);
- if (result != 0) {
- /* Non NLS mapping might introduce problem with some locales when only one entry is mapped,
- * the lang or the country (example: chinese locales like 'chinese_taiwan' gives 'CHS_taiwan'
- * that do not exists in system). This is why we are giving this locale an other chance by
- * calling __GetLCID without the mapping. */
- result = __GetLCID(lang, ctry, lcid);
- }
- }
- }
- }
-
- if (result == 0) {
- /* Handling code page */
- if (lstrcmpiA(page, "ACP") == 0 || page[0] == 0)
- my_ltoa(__intGetACP(*lcid), cp);
- else if (lstrcmpiA(page, "OCP") == 0)
- my_ltoa(__intGetOCP(*lcid), cp);
- else if (lstrcmpiA(page, "UTF7") == 0)
- my_ltoa(CP_UTF7, cp);
- else if (lstrcmpiA(page, "UTF8") == 0)
- my_ltoa(CP_UTF8, cp);
- else
- _STLP_STRNCPY(cp, MAX_CP_LEN + 1, page, 5);
-
- /* Code page must be an integer value,
- * 0 returned by __intGetACP and 1 returned by __intGetOCP are invalid
- * values.
- */
- if (cp[1] == 0 && (cp[0] == '0' || cp[1] == '1'))
- return -1;
- else if (atoi(cp) == 0)
- return -1;
- }
-
- return result;
-}
-
-char const* __GetLocaleName(LCID lcid, const char* cp, char* buf) {
- if (lcid == INVARIANT_LCID) {
- return _C_name;
- }
- else {
- char lang[MAX_LANG_LEN + 1], ctry[MAX_CTRY_LEN + 1];
- GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE, lang, MAX_LANG_LEN);
- GetLocaleInfoA(lcid, LOCALE_SENGCOUNTRY, ctry, MAX_CTRY_LEN);
- _STLP_STRCPY(buf, _Locale_MAX_SIMPLE_NAME, lang);
- _STLP_STRCAT(buf, _Locale_MAX_SIMPLE_NAME, "_");
- _STLP_STRCAT(buf, _Locale_MAX_SIMPLE_NAME, ctry);
- _STLP_STRCAT(buf, _Locale_MAX_SIMPLE_NAME, ".");
- _STLP_STRCAT(buf, _Locale_MAX_SIMPLE_NAME, cp);
- return buf;
- }
-}
-
-char const* __Extract_locale_name(const char* loc, const char* category, char* buf) {
- char *expr;
- size_t len_name;
-
- if (loc[0] == 'L' && loc[1] == 'C' && loc[2] == '_') {
- expr = strstr((char*)loc, category);
- if (expr == NULL) return NULL; /* Category not found. */
- expr = strchr(expr, '=');
- if (expr == NULL) return NULL;
- ++expr;
- len_name = strcspn(expr, ";");
- len_name = len_name >= _Locale_MAX_SIMPLE_NAME ? _Locale_MAX_SIMPLE_NAME - 1
- : len_name;
- _STLP_STRNCPY(buf, _Locale_MAX_SIMPLE_NAME, expr, len_name); buf[len_name] = 0;
- return buf;
- }
- else {
- return loc;
- }
-}
-
-char const* __TranslateToSystem(const char* lname, char* buf, _Locale_lcid_t* hint,
- int *__err_code) {
- LCID lcid;
- char cp[MAX_CP_LEN + 1];
- if (__GetLCIDFromName(lname, &lcid, cp, hint) != 0)
- { *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
-
- return __GetLocaleName(lcid, cp, buf);
-}
-
-void __GetLocaleInfoUsingACP(LCID lcid, const char* cp, LCTYPE lctype, char* buf, int buf_size, wchar_t* wbuf, int wbuf_size) {
- wchar_t *Buffer;
- int BufferSize;
- int icp;
-
- GetLocaleInfoA(lcid, lctype, buf, buf_size);
-
- icp = atoi(cp);
- if (icp != CP_ACP && buf[0] != 0) {
- BufferSize = MultiByteToWideChar(CP_ACP, 0, buf, -1, NULL, 0);
- if (BufferSize > wbuf_size)
- {
- Buffer = (wchar_t*)malloc(sizeof(wchar_t) * BufferSize);
- }
- else
- {
- Buffer = wbuf;
- }
- MultiByteToWideChar(CP_ACP, 0, buf, -1, Buffer, BufferSize);
- WideCharToMultiByte(icp, 0, Buffer, -1, buf, buf_size, NULL, NULL);
- if (Buffer != wbuf)
- {
- free(Buffer);
- }
- }
-}
-
-/* Return 0 if ANSI code page not used */
-int __intGetACP(LCID lcid) {
- char cp[6];
- if (!GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE, cp, 6)) {
-#if defined (_STLP_LANG_INVARIANT_DEFINED)
- if (lcid == INVARIANT_LCID) {
- /* We are using a limited PSDK, we rely on the most common code page */
- return 1252;
- }
-#endif
- return 0;
- }
- return atoi(cp);
-}
-
-/* Return 1 if OEM code page not used */
-int __intGetOCP(LCID lcid) {
- char cp[6];
- if (!GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE, cp, 6))
- return 0;
- return atoi(cp);
-}
-
-int __GetDefaultCP(LCID lcid) {
- int cp = __intGetACP(lcid);
- if (cp == 0) return __intGetOCP(lcid);
- else return cp;
-}
-
-static int trim_size_t_to_int(size_t n) { return n < (size_t)INT_MAX ? (int)n : INT_MAX; }
-
-char* __ConvertToCP(int from_cp, int to_cp, const char *from, size_t size, size_t *ret_buf_size) {
- size_t wbuffer_size, buffer_size, from_offset, wbuf_offset;
- int from_size, to_size, wbuf_size;
- wchar_t *wbuffer;
- char* buffer;
-
- size_t orig_size = size;
-
- wbuffer_size = 0;
- from_offset = 0;
- while (size > 0) {
- from_size = trim_size_t_to_int(size);
- wbuffer_size += MultiByteToWideChar(from_cp, MB_PRECOMPOSED,
- from + from_offset, from_size, NULL, 0);
- from_offset += from_size;
- size -= from_size;
- }
-
- wbuffer = (wchar_t*)malloc(sizeof(wchar_t)*wbuffer_size);
-
- size = orig_size;
- wbuf_offset = 0;
- from_offset = 0;
- while (size > 0) {
- from_size = trim_size_t_to_int(size);
- wbuf_size = trim_size_t_to_int(wbuffer_size - wbuf_offset);
- wbuf_offset += MultiByteToWideChar(from_cp, MB_PRECOMPOSED,
- from + from_offset, from_size, wbuffer + wbuf_offset, wbuf_size);
- from_offset += from_size;
- size -= from_size;
- }
-
- buffer_size = 0;
- wbuf_offset = 0;
- size = wbuffer_size;
- while (size > 0) {
- wbuf_size = trim_size_t_to_int(size);
- buffer_size += WideCharToMultiByte(to_cp, WC_COMPOSITECHECK | WC_SEPCHARS,
- wbuffer + wbuf_offset, wbuf_size,
- NULL, 0, NULL, FALSE);
- wbuf_offset += wbuf_size;
- size -= wbuf_size;
- }
-
- buffer = (char*)malloc(buffer_size);
- *ret_buf_size = buffer_size;
-
- size = wbuffer_size;
- wbuf_offset = 0;
- while (size > 0) {
- wbuf_size = trim_size_t_to_int(size);
- to_size = trim_size_t_to_int(buffer_size);
- buffer_size -= WideCharToMultiByte(to_cp, WC_COMPOSITECHECK | WC_SEPCHARS,
- wbuffer + wbuf_offset, wbuf_size,
- buffer, to_size, NULL, FALSE);
- wbuf_offset += wbuf_size;
- size -= wbuf_size;
- }
-
- free(wbuffer);
- return buffer;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifndef _STLP_NO_WCHAR_T
-# include "c_wlocale_win32.c"
-#endif
diff --git a/src/c_locale_win32/c_wlocale_win32.c b/src/c_locale_win32/c_wlocale_win32.c
deleted file mode 100644
index a12659b..0000000
--- a/src/c_locale_win32/c_wlocale_win32.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (c) 2007 2008
- * Francois Dumont
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
-# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy_s(D, DS, S, C)
-#else
-# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy(D, S, C)
-#endif
-
-static const wchar_t* __wtrue_name = L"true";
-static const wchar_t* __wfalse_name = L"false";
-
-typedef struct _Locale_codecvt {
- _Locale_lcid_t lc;
- UINT cp;
- unsigned char cleads[256 / CHAR_BIT];
- unsigned char max_char_size;
- DWORD mbtowc_flags;
- DWORD wctomb_flags;
-} _Locale_codecvt_t;
-
-/* Ctype */
-_Locale_mask_t _WLocale_ctype(_Locale_ctype_t* ltype, wint_t c,
- _Locale_mask_t which_bits) {
- wchar_t buf[2];
- WORD out[2];
- buf[0] = c; buf[1] = 0;
- GetStringTypeW(CT_CTYPE1, buf, -1, out);
- _STLP_MARK_PARAMETER_AS_UNUSED(ltype)
- return (_Locale_mask_t)(MapCtypeMask(out[0]) & which_bits);
-}
-
-wint_t _WLocale_tolower(_Locale_ctype_t* ltype, wint_t c) {
- wchar_t in_c = c;
- wchar_t res;
-
- LCMapStringW(ltype->lc.id, LCMAP_LOWERCASE, &in_c, 1, &res, 1);
- return res;
-}
-
-wint_t _WLocale_toupper(_Locale_ctype_t* ltype, wint_t c) {
- wchar_t in_c = c;
- wchar_t res;
-
- LCMapStringW(ltype->lc.id, LCMAP_UPPERCASE, &in_c, 1, &res, 1);
- return res;
-}
-
-_Locale_codecvt_t* _Locale_codecvt_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
- char cp_name[MAX_CP_LEN + 1];
- unsigned char *ptr;
- CPINFO CPInfo;
- int i;
-
- _Locale_codecvt_t *lcodecvt = (_Locale_codecvt_t*)malloc(sizeof(_Locale_codecvt_t));
-
- if (!lcodecvt) { *__err_code = _STLP_LOC_NO_MEMORY; return lcodecvt; }
- memset(lcodecvt, 0, sizeof(_Locale_codecvt_t));
-
- if (__GetLCIDFromName(name, &lcodecvt->lc.id, cp_name, lc_hint) == -1)
- { free(lcodecvt); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
-
- lcodecvt->cp = atoi(cp_name);
- if (!GetCPInfo(lcodecvt->cp, &CPInfo)) { free(lcodecvt); return NULL; }
-
- if (lcodecvt->cp != CP_UTF7 && lcodecvt->cp != CP_UTF8) {
- lcodecvt->mbtowc_flags = MB_PRECOMPOSED;
- lcodecvt->wctomb_flags = WC_COMPOSITECHECK | WC_SEPCHARS;
- }
- lcodecvt->max_char_size = CPInfo.MaxCharSize;
-
- if (CPInfo.MaxCharSize > 1) {
- for (ptr = (unsigned char*)CPInfo.LeadByte; *ptr && *(ptr + 1); ptr += 2)
- for (i = *ptr; i <= *(ptr + 1); ++i) lcodecvt->cleads[i / CHAR_BIT] |= (0x01 << i % CHAR_BIT);
- }
-
- return lcodecvt;
-}
-
-char const* _Locale_codecvt_name(const _Locale_codecvt_t* lcodecvt, char* buf) {
- char cp_buf[MAX_CP_LEN + 1];
- my_ltoa(lcodecvt->cp, cp_buf);
- return __GetLocaleName(lcodecvt->lc.id, cp_buf, buf);
-}
-
-void _Locale_codecvt_destroy(_Locale_codecvt_t* lcodecvt) {
- if (!lcodecvt) return;
-
- free(lcodecvt);
-}
-
-int _WLocale_mb_cur_max (_Locale_codecvt_t * lcodecvt)
-{ return lcodecvt->max_char_size; }
-
-int _WLocale_mb_cur_min (_Locale_codecvt_t *lcodecvt) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lcodecvt)
- return 1;
-}
-
-int _WLocale_is_stateless (_Locale_codecvt_t * lcodecvt)
-{ return (lcodecvt->max_char_size == 1) ? 1 : 0; }
-
-static int __isleadbyte(int i, unsigned char *ctable) {
- unsigned char c = (unsigned char)i;
- return (ctable[c / CHAR_BIT] & (0x01 << c % CHAR_BIT));
-}
-
-static int __mbtowc(_Locale_codecvt_t *l, wchar_t *dst, const char *from, unsigned int count) {
- int result;
-
- if (l->cp == CP_UTF7 || l->cp == CP_UTF8) {
- result = MultiByteToWideChar(l->cp, l->mbtowc_flags, from, count, dst, 1);
- if (result == 0) {
- switch (GetLastError()) {
- case ERROR_NO_UNICODE_TRANSLATION:
- return -2;
- default:
- return -1;
- }
- }
- }
- else {
- if (count == 1 && __isleadbyte(*from, l->cleads)) return (size_t)-2;
- result = MultiByteToWideChar(l->cp, l->mbtowc_flags, from, count, dst, 1);
- if (result == 0) return -1;
- }
-
- return result;
-}
-
-size_t _WLocale_mbtowc(_Locale_codecvt_t *lcodecvt, wchar_t *to,
- const char *from, size_t n, mbstate_t *shift_state) {
- int result;
- _STLP_MARK_PARAMETER_AS_UNUSED(shift_state)
- if (lcodecvt->max_char_size == 1) { /* Single byte encoding. */
- result = MultiByteToWideChar(lcodecvt->cp, lcodecvt->mbtowc_flags, from, 1, to, 1);
- if (result == 0) return (size_t)-1;
- return result;
- }
- else { /* Multi byte encoding. */
- int retval;
- unsigned int count = 1;
- while (n--) {
- retval = __mbtowc(lcodecvt, to, from, count);
- if (retval == -2)
- { if (++count > ((unsigned int)lcodecvt->max_char_size)) return (size_t)-1; }
- else if (retval == -1)
- { return (size_t)-1; }
- else
- { return count; }
- }
- return (size_t)-2;
- }
-}
-
-size_t _WLocale_wctomb(_Locale_codecvt_t *lcodecvt, char *to, size_t n,
- const wchar_t c, mbstate_t *shift_state) {
- int size = WideCharToMultiByte(lcodecvt->cp, lcodecvt->wctomb_flags, &c, 1, NULL, 0, NULL, NULL);
-
- if (!size) return (size_t)-1;
- if ((size_t)size > n) return (size_t)-2;
-
- if (n > INT_MAX)
- /* Limiting the output buf size to INT_MAX seems like reasonable to transform a single wchar_t. */
- n = INT_MAX;
-
- WideCharToMultiByte(lcodecvt->cp, lcodecvt->wctomb_flags, &c, 1, to, (int)n, NULL, NULL);
-
- _STLP_MARK_PARAMETER_AS_UNUSED(shift_state)
- return (size_t)size;
-}
-
-size_t _WLocale_unshift(_Locale_codecvt_t *lcodecvt, mbstate_t *st,
- char *buf, size_t n, char **next) {
- /* _WLocale_wctomb do not even touch to st, there is nothing to unshift in this localization implementation. */
- _STLP_MARK_PARAMETER_AS_UNUSED(lcodecvt)
- _STLP_MARK_PARAMETER_AS_UNUSED(st)
- _STLP_MARK_PARAMETER_AS_UNUSED(&n)
- *next = buf;
- return 0;
-}
-
-/* Collate */
-/* This function takes care of the potential size_t DWORD different size. */
-static int _WLocale_strcmp_aux(_Locale_collate_t* lcol,
- const wchar_t* s1, size_t n1,
- const wchar_t* s2, size_t n2) {
- int result = CSTR_EQUAL;
- while (n1 > 0 || n2 > 0) {
- DWORD size1 = trim_size_t_to_DWORD(n1);
- DWORD size2 = trim_size_t_to_DWORD(n2);
- result = CompareStringW(lcol->lc.id, 0, s1, size1, s2, size2);
- if (result != CSTR_EQUAL)
- break;
- n1 -= size1;
- n2 -= size2;
- }
- return result;
-}
-
-int _WLocale_strcmp(_Locale_collate_t* lcol,
- const wchar_t* s1, size_t n1,
- const wchar_t* s2, size_t n2) {
- int result;
- result = _WLocale_strcmp_aux(lcol, s1, n1, s2, n2);
- return (result == CSTR_EQUAL) ? 0 : (result == CSTR_LESS_THAN) ? -1 : 1;
-}
-
-size_t _WLocale_strxfrm(_Locale_collate_t* lcol,
- wchar_t* dst, size_t dst_size,
- const wchar_t* src, size_t src_size) {
- int result, i;
-
- /* see _Locale_strxfrm: */
- if (src_size > INT_MAX) {
- if (dst != 0) {
- _STLP_WCSNCPY(dst, dst_size, src, src_size);
- }
- return src_size;
- }
- if (dst_size > INT_MAX) {
- dst_size = INT_MAX;
- }
- result = LCMapStringW(lcol->lc.id, LCMAP_SORTKEY, src, (int)src_size, dst, (int)dst_size);
- if (result != 0 && dst != 0) {
- for (i = result - 1; i >= 0; --i) {
- dst[i] = ((unsigned char*)dst)[i];
- }
- }
- return result != 0 ? result - 1 : 0;
-}
-
-/* Numeric */
-wchar_t _WLocale_decimal_point(_Locale_numeric_t* lnum) {
- wchar_t buf[4];
- GetLocaleInfoW(lnum->lc.id, LOCALE_SDECIMAL, buf, 4);
- return buf[0];
-}
-
-wchar_t _WLocale_thousands_sep(_Locale_numeric_t* lnum) {
- wchar_t buf[4];
- GetLocaleInfoW(lnum->lc.id, LOCALE_STHOUSAND, buf, 4);
- return buf[0];
-}
-
-const wchar_t * _WLocale_true(_Locale_numeric_t* lnum, wchar_t* buf, size_t bufSize) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lnum)
- _STLP_MARK_PARAMETER_AS_UNUSED(buf)
- _STLP_MARK_PARAMETER_AS_UNUSED(&bufSize)
- return __wtrue_name;
-}
-
-const wchar_t * _WLocale_false(_Locale_numeric_t* lnum, wchar_t* buf, size_t bufSize) {
- _STLP_MARK_PARAMETER_AS_UNUSED(lnum)
- _STLP_MARK_PARAMETER_AS_UNUSED(buf)
- _STLP_MARK_PARAMETER_AS_UNUSED(&bufSize)
- return __wfalse_name;
-}
-
-/* Monetary */
-const wchar_t* _WLocale_int_curr_symbol(_Locale_monetary_t * lmon, wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(lmon->lc.id, LOCALE_SINTLSYMBOL, buf, (int)bufSize); return buf; }
-
-const wchar_t* _WLocale_currency_symbol(_Locale_monetary_t * lmon, wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(lmon->lc.id, LOCALE_SCURRENCY, buf, (int)bufSize); return buf; }
-
-wchar_t _WLocale_mon_decimal_point(_Locale_monetary_t * lmon)
-{ return lmon->decimal_point[0]; }
-
-wchar_t _WLocale_mon_thousands_sep(_Locale_monetary_t * lmon)
-{ return lmon->thousands_sep[0]; }
-
-const wchar_t* _WLocale_positive_sign(_Locale_monetary_t * lmon, wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(lmon->lc.id, LOCALE_SPOSITIVESIGN, buf, (int)bufSize); return buf; }
-
-const wchar_t* _WLocale_negative_sign(_Locale_monetary_t * lmon, wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(lmon->lc.id, LOCALE_SNEGATIVESIGN, buf, (int)bufSize); return buf; }
-
-/* Time */
-const wchar_t * _WLocale_full_monthname(_Locale_time_t * ltime, int month,
- wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(ltime->lc.id, LOCALE_SMONTHNAME1 + month, buf, (int)bufSize); return buf; }
-
-const wchar_t * _WLocale_abbrev_monthname(_Locale_time_t * ltime, int month,
- wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(ltime->lc.id, LOCALE_SABBREVMONTHNAME1 + month, buf, (int)bufSize); return buf; }
-
-const wchar_t * _WLocale_full_dayofweek(_Locale_time_t * ltime, int day,
- wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(ltime->lc.id, LOCALE_SDAYNAME1 + day, buf, (int)bufSize); return buf; }
-
-const wchar_t * _WLocale_abbrev_dayofweek(_Locale_time_t * ltime, int day,
- wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(ltime->lc.id, LOCALE_SABBREVDAYNAME1 + day, buf, (int)bufSize); return buf; }
-
-const wchar_t* _WLocale_am_str(_Locale_time_t* ltime,
- wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(ltime->lc.id, LOCALE_S1159, buf, (int)bufSize); return buf; }
-
-const wchar_t* _WLocale_pm_str(_Locale_time_t* ltime,
- wchar_t* buf, size_t bufSize)
-{ GetLocaleInfoW(ltime->lc.id, LOCALE_S2359, buf, (int)bufSize); return buf; }
diff --git a/src/codecvt.cpp b/src/codecvt.cpp
deleted file mode 100644
index 113a262..0000000
--- a/src/codecvt.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <locale>
-#include <algorithm>
-
-_STLP_BEGIN_NAMESPACE
-
-//----------------------------------------------------------------------
-// codecvt<char, char, mbstate_t>
-
-codecvt<char, char, mbstate_t>::~codecvt() {}
-
-int codecvt<char, char, mbstate_t>::do_length(state_type&,
- const char* from,
- const char* end,
- size_t mx) const
-{ return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); }
-
-int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
-{ return 1; }
-
-bool
-codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
-{ return true; }
-
-int
-codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
-{ return 1; }
-
-codecvt_base::result
-codecvt<char, char, mbstate_t>::do_unshift(state_type& /* __state */,
- char* __to,
- char* /* __to_limit */,
- char*& __to_next) const
-{ __to_next = __to; return noconv; }
-
-codecvt_base::result
-codecvt<char, char, mbstate_t>::do_in (state_type& /* __state */ ,
- const char* __from,
- const char* /* __from_end */,
- const char*& __from_next,
- char* __to,
- char* /* __to_end */,
- char*& __to_next) const
-{ __from_next = __from; __to_next = __to; return noconv; }
-
-codecvt_base::result
-codecvt<char, char, mbstate_t>::do_out(state_type& /* __state */,
- const char* __from,
- const char* /* __from_end */,
- const char*& __from_next,
- char* __to,
- char* /* __to_limit */,
- char*& __to_next) const
-{ __from_next = __from; __to_next = __to; return noconv; }
-
-
-#if !defined (_STLP_NO_WCHAR_T)
-//----------------------------------------------------------------------
-// codecvt<wchar_t, char, mbstate_t>
-
-codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
-
-
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt<wchar_t, char, mbstate_t>::do_out(state_type& /* state */,
- const intern_type* from,
- const intern_type* from_end,
- const intern_type*& from_next,
- extern_type* to,
- extern_type* to_limit,
- extern_type*& to_next) const {
- ptrdiff_t len = (min) (from_end - from, to_limit - to);
- copy(from, from + len, to);
- from_next = from + len;
- to_next = to + len;
- return ok;
-}
-
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt<wchar_t, char, mbstate_t>::do_in (state_type& /* state */,
- const extern_type* from,
- const extern_type* from_end,
- const extern_type*& from_next,
- intern_type* to,
- intern_type* to_limit,
- intern_type*& to_next) const {
- ptrdiff_t len = (min) (from_end - from, to_limit - to);
- copy(__REINTERPRET_CAST(const unsigned char*, from),
- __REINTERPRET_CAST(const unsigned char*, from) + len, to);
- from_next = from + len;
- to_next = to + len;
- return ok;
-}
-
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& /* state */,
- extern_type* to,
- extern_type* ,
- extern_type*& to_next) const {
- to_next = to;
- return noconv;
-}
-
-int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
-{ return 1; }
-
-bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
-{ return true; }
-
-int codecvt<wchar_t, char, mbstate_t>::do_length(state_type&,
- const extern_type* from,
- const extern_type* end,
- size_t mx) const
-{ return (int)(min) ((size_t) (end - from), mx); }
-
-int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
-{ return 1; }
-#endif /* wchar_t */
-
-_STLP_END_NAMESPACE
-
-// Local Variables:
-// mode:C++
-// End:
-
diff --git a/src/collate.cpp b/src/collate.cpp
deleted file mode 100644
index ee5540d..0000000
--- a/src/collate.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <locale>
-
-_STLP_BEGIN_NAMESPACE
-
-// collate<char>
-
-collate<char>::~collate() {}
-
-int collate<char>::do_compare(const char* low1, const char* high1,
- const char* low2, const char* high2) const
-{ return _STLP_PRIV __lexicographical_compare_3way(low1, high1, low2, high2); }
-
-string collate<char>::do_transform(const char* low, const char* high) const
-{ return string(low, high); }
-
-long collate<char>::do_hash(const char* low, const char* high) const {
- unsigned long result = 0;
- for ( ; low < high; ++low)
- result = 5 * result + *low;
- return result;
-}
-
-#if !defined (_STLP_NO_WCHAR_T)
-// collate<wchar_t>
-
-collate<wchar_t>::~collate() {}
-
-int
-collate<wchar_t>::do_compare(const wchar_t* low1, const wchar_t* high1,
- const wchar_t* low2, const wchar_t* high2) const
-{ return _STLP_PRIV __lexicographical_compare_3way(low1, high1, low2, high2); }
-
-wstring collate<wchar_t>::do_transform(const wchar_t* low, const wchar_t* high) const
-{ return wstring(low, high); }
-
-long collate<wchar_t>::do_hash(const wchar_t* low, const wchar_t* high) const {
- unsigned long result = 0;
- for ( ; low < high; ++low)
- result = 5 * result + *low;
- return result;
-}
-#endif
-
-_STLP_END_NAMESPACE
-
-
-// Local Variables:
-// mode:C++
-// End:
-
diff --git a/src/complex.cpp b/src/complex.cpp
deleted file mode 100644
index 6da5bc1..0000000
--- a/src/complex.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include <numeric>
-#include <cmath>
-#include <complex>
-
-#if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB >= 1400)
-// hypot is deprecated.
-# if defined (_STLP_MSVC)
-# pragma warning (disable : 4996)
-# elif defined (__ICL)
-# pragma warning (disable : 1478)
-# endif
-#endif
-
-_STLP_BEGIN_NAMESPACE
-
-// Complex division and square roots.
-
-// Absolute value
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC float _STLP_CALL abs(const complex<float>& __z)
-{ return ::hypot(__z._M_re, __z._M_im); }
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC double _STLP_CALL abs(const complex<double>& __z)
-{ return ::hypot(__z._M_re, __z._M_im); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC long double _STLP_CALL abs(const complex<long double>& __z)
-{ return ::hypot(__z._M_re, __z._M_im); }
-#endif
-
-// Phase
-
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC float _STLP_CALL arg(const complex<float>& __z)
-{ return ::atan2(__z._M_im, __z._M_re); }
-
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC double _STLP_CALL arg(const complex<double>& __z)
-{ return ::atan2(__z._M_im, __z._M_re); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC long double _STLP_CALL arg(const complex<long double>& __z)
-{ return ::atan2(__z._M_im, __z._M_re); }
-#endif
-
-// Construct a complex number from polar representation
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC complex<float> _STLP_CALL polar(const float& __rho, const float& __phi)
-{ return complex<float>(__rho * ::cos(__phi), __rho * ::sin(__phi)); }
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC complex<double> _STLP_CALL polar(const double& __rho, const double& __phi)
-{ return complex<double>(__rho * ::cos(__phi), __rho * ::sin(__phi)); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_TEMPLATE_NULL
-_STLP_DECLSPEC complex<long double> _STLP_CALL polar(const long double& __rho, const long double& __phi)
-{ return complex<long double>(__rho * ::cos(__phi), __rho * ::sin(__phi)); }
-#endif
-
-// Division
-template <class _Tp>
-static void _divT(const _Tp& __z1_r, const _Tp& __z1_i,
- const _Tp& __z2_r, const _Tp& __z2_i,
- _Tp& __res_r, _Tp& __res_i) {
- _Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r;
- _Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i;
-
- if (__ar <= __ai) {
- _Tp __ratio = __z2_r / __z2_i;
- _Tp __denom = __z2_i * (1 + __ratio * __ratio);
- __res_r = (__z1_r * __ratio + __z1_i) / __denom;
- __res_i = (__z1_i * __ratio - __z1_r) / __denom;
- }
- else {
- _Tp __ratio = __z2_i / __z2_r;
- _Tp __denom = __z2_r * (1 + __ratio * __ratio);
- __res_r = (__z1_r + __z1_i * __ratio) / __denom;
- __res_i = (__z1_i - __z1_r * __ratio) / __denom;
- }
-}
-
-template <class _Tp>
-static void _divT(const _Tp& __z1_r,
- const _Tp& __z2_r, const _Tp& __z2_i,
- _Tp& __res_r, _Tp& __res_i) {
- _Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r;
- _Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i;
-
- if (__ar <= __ai) {
- _Tp __ratio = __z2_r / __z2_i;
- _Tp __denom = __z2_i * (1 + __ratio * __ratio);
- __res_r = (__z1_r * __ratio) / __denom;
- __res_i = - __z1_r / __denom;
- }
- else {
- _Tp __ratio = __z2_i / __z2_r;
- _Tp __denom = __z2_r * (1 + __ratio * __ratio);
- __res_r = __z1_r / __denom;
- __res_i = - (__z1_r * __ratio) / __denom;
- }
-}
-
-void _STLP_CALL
-complex<float>::_div(const float& __z1_r, const float& __z1_i,
- const float& __z2_r, const float& __z2_i,
- float& __res_r, float& __res_i)
-{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); }
-
-void _STLP_CALL
-complex<float>::_div(const float& __z1_r,
- const float& __z2_r, const float& __z2_i,
- float& __res_r, float& __res_i)
-{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); }
-
-
-void _STLP_CALL
-complex<double>::_div(const double& __z1_r, const double& __z1_i,
- const double& __z2_r, const double& __z2_i,
- double& __res_r, double& __res_i)
-{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); }
-
-void _STLP_CALL
-complex<double>::_div(const double& __z1_r,
- const double& __z2_r, const double& __z2_i,
- double& __res_r, double& __res_i)
-{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-void _STLP_CALL
-complex<long double>::_div(const long double& __z1_r, const long double& __z1_i,
- const long double& __z2_r, const long double& __z2_i,
- long double& __res_r, long double& __res_i)
-{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); }
-
-void _STLP_CALL
-complex<long double>::_div(const long double& __z1_r,
- const long double& __z2_r, const long double& __z2_i,
- long double& __res_r, long double& __res_i)
-{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); }
-#endif
-
-//----------------------------------------------------------------------
-// Square root
-template <class _Tp>
-static complex<_Tp> sqrtT(const complex<_Tp>& z) {
- _Tp re = z._M_re;
- _Tp im = z._M_im;
- _Tp mag = ::hypot(re, im);
- complex<_Tp> result;
-
- if (mag == 0.f) {
- result._M_re = result._M_im = 0.f;
- } else if (re > 0.f) {
- result._M_re = ::sqrt(0.5f * (mag + re));
- result._M_im = im/result._M_re/2.f;
- } else {
- result._M_im = ::sqrt(0.5f * (mag - re));
- if (im < 0.f)
- result._M_im = - result._M_im;
- result._M_re = im/result._M_im/2.f;
- }
- return result;
-}
-
-complex<float> _STLP_CALL
-sqrt(const complex<float>& z) { return sqrtT(z); }
-
-complex<double> _STLP_CALL
-sqrt(const complex<double>& z) { return sqrtT(z); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-complex<long double> _STLP_CALL
-sqrt(const complex<long double>& z) { return sqrtT(z); }
-#endif
-
-// exp, log, pow for complex<float>, complex<double>, and complex<long double>
-//----------------------------------------------------------------------
-// exp
-template <class _Tp>
-static complex<_Tp> expT(const complex<_Tp>& z) {
- _Tp expx = ::exp(z._M_re);
- return complex<_Tp>(expx * ::cos(z._M_im),
- expx * ::sin(z._M_im));
-}
-_STLP_DECLSPEC complex<float> _STLP_CALL exp(const complex<float>& z)
-{ return expT(z); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL exp(const complex<double>& z)
-{ return expT(z); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL exp(const complex<long double>& z)
-{ return expT(z); }
-#endif
-
-//----------------------------------------------------------------------
-// log10
-template <class _Tp>
-static complex<_Tp> log10T(const complex<_Tp>& z, const _Tp& ln10_inv) {
- complex<_Tp> r;
-
- r._M_im = ::atan2(z._M_im, z._M_re) * ln10_inv;
- r._M_re = ::log10(::hypot(z._M_re, z._M_im));
- return r;
-}
-
-_STLP_DECLSPEC complex<float> _STLP_CALL log10(const complex<float>& z)
-{
- const float LN10_INVF = 1.f / ::log(10.f);
- return log10T(z, LN10_INVF);
-}
-
-_STLP_DECLSPEC complex<double> _STLP_CALL log10(const complex<double>& z)
-{
- const double LN10_INV = 1. / ::log10(10.);
- return log10T(z, LN10_INV);
-}
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL log10(const complex<long double>& z)
-{
- const long double LN10_INVL = 1.l / ::log(10.l);
- return log10T(z, LN10_INVL);
-}
-#endif
-
-//----------------------------------------------------------------------
-// log
-template <class _Tp>
-static complex<_Tp> logT(const complex<_Tp>& z) {
- complex<_Tp> r;
-
- r._M_im = ::atan2(z._M_im, z._M_re);
- r._M_re = ::log(::hypot(z._M_re, z._M_im));
- return r;
-}
-_STLP_DECLSPEC complex<float> _STLP_CALL log(const complex<float>& z)
-{ return logT(z); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL log(const complex<double>& z)
-{ return logT(z); }
-
-#ifndef _STLP_NO_LONG_DOUBLE
-_STLP_DECLSPEC complex<long double> _STLP_CALL log(const complex<long double>& z)
-{ return logT(z); }
-# endif
-
-//----------------------------------------------------------------------
-// pow
-template <class _Tp>
-static complex<_Tp> powT(const _Tp& a, const complex<_Tp>& b) {
- _Tp logr = ::log(a);
- _Tp x = ::exp(logr * b._M_re);
- _Tp y = logr * b._M_im;
-
- return complex<_Tp>(x * ::cos(y), x * ::sin(y));
-}
-
-template <class _Tp>
-static complex<_Tp> powT(const complex<_Tp>& z_in, int n) {
- complex<_Tp> z = z_in;
- z = _STLP_PRIV __power(z, (n < 0 ? -n : n), multiplies< complex<_Tp> >());
- if (n < 0)
- return _Tp(1.0) / z;
- else
- return z;
-}
-
-template <class _Tp>
-static complex<_Tp> powT(const complex<_Tp>& a, const _Tp& b) {
- _Tp logr = ::log(::hypot(a._M_re,a._M_im));
- _Tp logi = ::atan2(a._M_im, a._M_re);
- _Tp x = ::exp(logr * b);
- _Tp y = logi * b;
-
- return complex<_Tp>(x * ::cos(y), x * ::sin(y));
-}
-
-template <class _Tp>
-static complex<_Tp> powT(const complex<_Tp>& a, const complex<_Tp>& b) {
- _Tp logr = ::log(::hypot(a._M_re,a._M_im));
- _Tp logi = ::atan2(a._M_im, a._M_re);
- _Tp x = ::exp(logr * b._M_re - logi * b._M_im);
- _Tp y = logr * b._M_im + logi * b._M_re;
-
- return complex<_Tp>(x * ::cos(y), x * ::sin(y));
-}
-
-_STLP_DECLSPEC complex<float> _STLP_CALL pow(const float& a, const complex<float>& b)
-{ return powT(a, b); }
-
-_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>& z_in, int n)
-{ return powT(z_in, n); }
-
-_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>& a, const float& b)
-{ return powT(a, b); }
-
-_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>& a, const complex<float>& b)
-{ return powT(a, b); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL pow(const double& a, const complex<double>& b)
-{ return powT(a, b); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>& z_in, int n)
-{ return powT(z_in, n); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>& a, const double& b)
-{ return powT(a, b); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>& a, const complex<double>& b)
-{ return powT(a, b); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const long double& a,
- const complex<long double>& b)
-{ return powT(a, b); }
-
-
-_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>& z_in, int n)
-{ return powT(z_in, n); }
-
-_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>& a,
- const long double& b)
-{ return powT(a, b); }
-
-_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>& a,
- const complex<long double>& b)
-{ return powT(a, b); }
-#endif
-
-_STLP_END_NAMESPACE
diff --git a/src/complex_io.cpp b/src/complex_io.cpp
deleted file mode 100644
index 4cb6636..0000000
--- a/src/complex_io.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include <complex>
-#include <istream>
-
-_STLP_BEGIN_NAMESPACE
-
-// Specializations for narrow characters; lets us avoid the nuisance of
-// widening.
-_STLP_OPERATOR_SPEC
-basic_ostream<char, char_traits<char> >& _STLP_CALL
-operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<float>& __z)
-{ return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; }
-
-_STLP_OPERATOR_SPEC
-basic_ostream<char, char_traits<char> >& _STLP_CALL
-operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<double>& __z)
-{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; }
-
-#ifndef _STLP_NO_LONG_DOUBLE
-_STLP_OPERATOR_SPEC
-basic_ostream<char, char_traits<char> >& _STLP_CALL
-operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<long double>& __z)
-{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; }
-#endif
-
-// Specialization for narrow characters; lets us avoid widen.
-_STLP_OPERATOR_SPEC
-basic_istream<char, char_traits<char> >& _STLP_CALL
-operator>>(basic_istream<char, char_traits<char> >& __is, complex<float>& __z) {
- float __re = 0;
- float __im = 0;
-
- char __c;
-
- __is >> __c;
- if (__c == '(') {
- __is >> __re >> __c;
- if (__c == ',')
- __is >> __im >> __c;
- if (__c != ')')
- __is.setstate(ios_base::failbit);
- }
- else {
- __is.putback(__c);
- __is >> __re;
- }
-
- if (__is)
- __z = complex<float>(__re, __im);
- return __is;
-}
-
-_STLP_OPERATOR_SPEC
-basic_istream<char, char_traits<char> >& _STLP_CALL
-operator>>(basic_istream<char, char_traits<char> >& __is, complex<double>& __z) {
- double __re = 0;
- double __im = 0;
-
- char __c;
-
- __is >> __c;
- if (__c == '(') {
- __is >> __re >> __c;
- if (__c == ',')
- __is >> __im >> __c;
- if (__c != ')')
- __is.setstate(ios_base::failbit);
- }
- else {
- __is.putback(__c);
- __is >> __re;
- }
-
- if (__is)
- __z = complex<double>(__re, __im);
- return __is;
-}
-
-#ifndef _STLP_NO_LONG_DOUBLE
-_STLP_OPERATOR_SPEC
-basic_istream<char, char_traits<char> >& _STLP_CALL
-operator>>(basic_istream<char, char_traits<char> >& __is, complex<long double>& __z) {
- long double __re = 0;
- long double __im = 0;
-
- char __c;
-
- __is >> __c;
- if (__c == '(') {
- __is >> __re >> __c;
- if (__c == ',')
- __is >> __im >> __c;
- if (__c != ')')
- __is.setstate(ios_base::failbit);
- }
- else {
- __is.putback(__c);
- __is >> __re;
- }
-
- if (__is)
- __z = complex<long double>(__re, __im);
- return __is;
-}
-#endif
-
-// Force instantiation of complex I/O functions
-#if !(defined (_STLP_NO_FORCE_INSTANTIATE) || defined (_STLP_NO_WCHAR_T))
-
-_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
-operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<float>&);
-
-_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
-operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<double>&);
-
-#ifndef _STLP_NO_LONG_DOUBLE
-_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
-operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<long double>&);
-
-_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
-operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<long double>&);
-#endif
-
-_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
-operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<float>&);
-
-_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
-operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<double>&);
-
-#endif /* _STLP_NO_WCHAR_T */
-
-_STLP_END_NAMESPACE
-
-
-// Local Variables:
-// mode:C++
-// End:
-
diff --git a/src/complex_trig.cpp b/src/complex_trig.cpp
deleted file mode 100644
index 62d6be7..0000000
--- a/src/complex_trig.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-
-// Trigonometric and hyperbolic functions for complex<float>,
-// complex<double>, and complex<long double>
-#include <complex>
-#include <cfloat>
-#include <cmath>
-
-_STLP_BEGIN_NAMESPACE
-
-
-//----------------------------------------------------------------------
-// helpers
-#if defined (__sgi)
- static const union { unsigned int i; float f; } float_ulimit = { 0x42b2d4fc };
- static const float float_limit = float_ulimit.f;
- static union {
- struct { unsigned int h; unsigned int l; } w;
- double d;
- } double_ulimit = { 0x408633ce, 0x8fb9f87d };
- static const double double_limit = double_ulimit.d;
- static union {
- struct { unsigned int h[2]; unsigned int l[2]; } w;
- long double ld;
- } ldouble_ulimit = {0x408633ce, 0x8fb9f87e, 0xbd23b659, 0x4e9bd8b1};
-# if !defined (_STLP_NO_LONG_DOUBLE)
-# define ldouble_limit ldouble_ulimit.ld
-# endif
-#else
-# if defined (M_LN2) && defined (FLT_MAX_EXP)
- static const float float_limit = float(M_LN2 * FLT_MAX_EXP);
- static const double double_limit = M_LN2 * DBL_MAX_EXP;
-# else
- static const float float_limit = ::log(FLT_MAX);
- static const double double_limit = ::log(DBL_MAX);
-# endif
-# if !defined (_STLP_NO_LONG_DOUBLE)
-# if defined (M_LN2l)
-# define ldouble_limit (M_LN2l * LDBL_MAX_EXP)
-# else
-# define ldouble_limit ::log(LDBL_MAX)
-# endif
-# endif
-#endif
-
-
-//----------------------------------------------------------------------
-// sin
-template <class _Tp>
-static complex<_Tp> sinT(const complex<_Tp>& z) {
- return complex<_Tp>(::sin(z._M_re) * ::cosh(z._M_im),
- ::cos(z._M_re) * ::sinh(z._M_im));
-}
-
-_STLP_DECLSPEC complex<float> _STLP_CALL sin(const complex<float>& z)
-{ return sinT(z); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL sin(const complex<double>& z)
-{ return sinT(z); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL sin(const complex<long double>& z)
-{ return sinT(z); }
-#endif
-
-//----------------------------------------------------------------------
-// cos
-template <class _Tp>
-static complex<_Tp> cosT(const complex<_Tp>& z) {
- return complex<_Tp>(::cos(z._M_re) * ::cosh(z._M_im),
- -::sin(z._M_re) * ::sinh(z._M_im));
-}
-
-_STLP_DECLSPEC complex<float> _STLP_CALL cos(const complex<float>& z)
-{ return cosT(z); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL cos(const complex<double>& z)
-{ return cosT(z); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL cos(const complex<long double>& z)
-{ return cosT(z); }
-#endif
-
-//----------------------------------------------------------------------
-// tan
-template <class _Tp>
-static complex<_Tp> tanT(const complex<_Tp>& z, const _Tp& Tp_limit) {
- _Tp re2 = 2.f * z._M_re;
- _Tp im2 = 2.f * z._M_im;
-
- if (::abs(im2) > Tp_limit)
- return complex<_Tp>(0.f, (im2 > 0 ? 1.f : -1.f));
- else {
- _Tp den = ::cos(re2) + ::cosh(im2);
- return complex<_Tp>(::sin(re2) / den, ::sinh(im2) / den);
- }
-}
-
-_STLP_DECLSPEC complex<float> _STLP_CALL tan(const complex<float>& z)
-{ return tanT(z, float_limit); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL tan(const complex<double>& z)
-{ return tanT(z, double_limit); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL tan(const complex<long double>& z)
-{ return tanT(z, ldouble_limit); }
-#endif
-
-//----------------------------------------------------------------------
-// sinh
-template <class _Tp>
-static complex<_Tp> sinhT(const complex<_Tp>& z) {
- return complex<_Tp>(::sinh(z._M_re) * ::cos(z._M_im),
- ::cosh(z._M_re) * ::sin(z._M_im));
-}
-
-_STLP_DECLSPEC complex<float> _STLP_CALL sinh(const complex<float>& z)
-{ return sinhT(z); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL sinh(const complex<double>& z)
-{ return sinhT(z); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL sinh(const complex<long double>& z)
-{ return sinhT(z); }
-#endif
-
-//----------------------------------------------------------------------
-// cosh
-template <class _Tp>
-static complex<_Tp> coshT(const complex<_Tp>& z) {
- return complex<_Tp>(::cosh(z._M_re) * ::cos(z._M_im),
- ::sinh(z._M_re) * ::sin(z._M_im));
-}
-
-_STLP_DECLSPEC complex<float> _STLP_CALL cosh(const complex<float>& z)
-{ return coshT(z); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL cosh(const complex<double>& z)
-{ return coshT(z); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL cosh(const complex<long double>& z)
-{ return coshT(z); }
-#endif
-
-//----------------------------------------------------------------------
-// tanh
-template <class _Tp>
-static complex<_Tp> tanhT(const complex<_Tp>& z, const _Tp& Tp_limit) {
- _Tp re2 = 2.f * z._M_re;
- _Tp im2 = 2.f * z._M_im;
- if (::abs(re2) > Tp_limit)
- return complex<_Tp>((re2 > 0 ? 1.f : -1.f), 0.f);
- else {
- _Tp den = ::cosh(re2) + ::cos(im2);
- return complex<_Tp>(::sinh(re2) / den, ::sin(im2) / den);
- }
-}
-
-_STLP_DECLSPEC complex<float> _STLP_CALL tanh(const complex<float>& z)
-{ return tanhT(z, float_limit); }
-
-_STLP_DECLSPEC complex<double> _STLP_CALL tanh(const complex<double>& z)
-{ return tanhT(z, double_limit); }
-
-#if !defined (_STLP_NO_LONG_DOUBLE)
-_STLP_DECLSPEC complex<long double> _STLP_CALL tanh(const complex<long double>& z)
-{ return tanhT(z, ldouble_limit); }
-#endif
-
-_STLP_END_NAMESPACE
diff --git a/src/ctype.cpp b/src/ctype.cpp
deleted file mode 100644
index b1e84b1..0000000
--- a/src/ctype.cpp
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include <algorithm>
-#include <locale>
-#include <functional>
-
-#include "c_locale.h"
-
-_STLP_BEGIN_NAMESPACE
-
-//----------------------------------------------------------------------
-// ctype<char>
-
-// The classic table: static data members.
-
-#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
-//*TY 02/25/2000 - added workaround for MPW compilers; they confuse on in-class static const
-const size_t ctype<char>::table_size;
-#endif
-
-// This macro is specifically for platforms where isprint() relies
-// on separate flag
-
-const ctype_base::mask*
-ctype<char>::classic_table() _STLP_NOTHROW {
- /* Ctype table for the ASCII character set. */
- static const ctype_base::mask _S_classic_table[table_size] = {
- cntrl /* null */,
- cntrl /* ^A */,
- cntrl /* ^B */,
- cntrl /* ^C */,
- cntrl /* ^D */,
- cntrl /* ^E */,
- cntrl /* ^F */,
- cntrl /* ^G */,
- cntrl /* ^H */,
- ctype_base::mask(space | cntrl) /* tab */,
- ctype_base::mask(space | cntrl) /* LF */,
- ctype_base::mask(space | cntrl) /* ^K */,
- ctype_base::mask(space | cntrl) /* FF */,
- ctype_base::mask(space | cntrl) /* ^M */,
- cntrl /* ^N */,
- cntrl /* ^O */,
- cntrl /* ^P */,
- cntrl /* ^Q */,
- cntrl /* ^R */,
- cntrl /* ^S */,
- cntrl /* ^T */,
- cntrl /* ^U */,
- cntrl /* ^V */,
- cntrl /* ^W */,
- cntrl /* ^X */,
- cntrl /* ^Y */,
- cntrl /* ^Z */,
- cntrl /* esc */,
- cntrl /* ^\ */,
- cntrl /* ^] */,
- cntrl /* ^^ */,
- cntrl /* ^_ */,
- ctype_base::mask(space | print) /* */,
- ctype_base::mask(punct | print) /* ! */,
- ctype_base::mask(punct | print) /* " */,
- ctype_base::mask(punct | print) /* # */,
- ctype_base::mask(punct | print) /* $ */,
- ctype_base::mask(punct | print) /* % */,
- ctype_base::mask(punct | print) /* & */,
- ctype_base::mask(punct | print) /* ' */,
- ctype_base::mask(punct | print) /* ( */,
- ctype_base::mask(punct | print) /* ) */,
- ctype_base::mask(punct | print) /* * */,
- ctype_base::mask(punct | print) /* + */,
- ctype_base::mask(punct | print) /* , */,
- ctype_base::mask(punct | print) /* - */,
- ctype_base::mask(punct | print) /* . */,
- ctype_base::mask(punct | print) /* / */,
- ctype_base::mask(digit | print | xdigit) /* 0 */,
- ctype_base::mask(digit | print | xdigit) /* 1 */,
- ctype_base::mask(digit | print | xdigit) /* 2 */,
- ctype_base::mask(digit | print | xdigit) /* 3 */,
- ctype_base::mask(digit | print | xdigit) /* 4 */,
- ctype_base::mask(digit | print | xdigit) /* 5 */,
- ctype_base::mask(digit | print | xdigit) /* 6 */,
- ctype_base::mask(digit | print | xdigit) /* 7 */,
- ctype_base::mask(digit | print | xdigit) /* 8 */,
- ctype_base::mask(digit | print | xdigit) /* 9 */,
- ctype_base::mask(punct | print) /* : */,
- ctype_base::mask(punct | print) /* ; */,
- ctype_base::mask(punct | print) /* < */,
- ctype_base::mask(punct | print) /* = */,
- ctype_base::mask(punct | print) /* > */,
- ctype_base::mask(punct | print) /* ? */,
- ctype_base::mask(punct | print) /* ! */,
- ctype_base::mask(alpha | print | upper | xdigit) /* A */,
- ctype_base::mask(alpha | print | upper | xdigit) /* B */,
- ctype_base::mask(alpha | print | upper | xdigit) /* C */,
- ctype_base::mask(alpha | print | upper | xdigit) /* D */,
- ctype_base::mask(alpha | print | upper | xdigit) /* E */,
- ctype_base::mask(alpha | print | upper | xdigit) /* F */,
- ctype_base::mask(alpha | print | upper) /* G */,
- ctype_base::mask(alpha | print | upper) /* H */,
- ctype_base::mask(alpha | print | upper) /* I */,
- ctype_base::mask(alpha | print | upper) /* J */,
- ctype_base::mask(alpha | print | upper) /* K */,
- ctype_base::mask(alpha | print | upper) /* L */,
- ctype_base::mask(alpha | print | upper) /* M */,
- ctype_base::mask(alpha | print | upper) /* N */,
- ctype_base::mask(alpha | print | upper) /* O */,
- ctype_base::mask(alpha | print | upper) /* P */,
- ctype_base::mask(alpha | print | upper) /* Q */,
- ctype_base::mask(alpha | print | upper) /* R */,
- ctype_base::mask(alpha | print | upper) /* S */,
- ctype_base::mask(alpha | print | upper) /* T */,
- ctype_base::mask(alpha | print | upper) /* U */,
- ctype_base::mask(alpha | print | upper) /* V */,
- ctype_base::mask(alpha | print | upper) /* W */,
- ctype_base::mask(alpha | print | upper) /* X */,
- ctype_base::mask(alpha | print | upper) /* Y */,
- ctype_base::mask(alpha | print | upper) /* Z */,
- ctype_base::mask(punct | print) /* [ */,
- ctype_base::mask(punct | print) /* \ */,
- ctype_base::mask(punct | print) /* ] */,
- ctype_base::mask(punct | print) /* ^ */,
- ctype_base::mask(punct | print) /* _ */,
- ctype_base::mask(punct | print) /* ` */,
- ctype_base::mask(alpha | print | lower | xdigit) /* a */,
- ctype_base::mask(alpha | print | lower | xdigit) /* b */,
- ctype_base::mask(alpha | print | lower | xdigit) /* c */,
- ctype_base::mask(alpha | print | lower | xdigit) /* d */,
- ctype_base::mask(alpha | print | lower | xdigit) /* e */,
- ctype_base::mask(alpha | print | lower | xdigit) /* f */,
- ctype_base::mask(alpha | print | lower) /* g */,
- ctype_base::mask(alpha | print | lower) /* h */,
- ctype_base::mask(alpha | print | lower) /* i */,
- ctype_base::mask(alpha | print | lower) /* j */,
- ctype_base::mask(alpha | print | lower) /* k */,
- ctype_base::mask(alpha | print | lower) /* l */,
- ctype_base::mask(alpha | print | lower) /* m */,
- ctype_base::mask(alpha | print | lower) /* n */,
- ctype_base::mask(alpha | print | lower) /* o */,
- ctype_base::mask(alpha | print | lower) /* p */,
- ctype_base::mask(alpha | print | lower) /* q */,
- ctype_base::mask(alpha | print | lower) /* r */,
- ctype_base::mask(alpha | print | lower) /* s */,
- ctype_base::mask(alpha | print | lower) /* t */,
- ctype_base::mask(alpha | print | lower) /* u */,
- ctype_base::mask(alpha | print | lower) /* v */,
- ctype_base::mask(alpha | print | lower) /* w */,
- ctype_base::mask(alpha | print | lower) /* x */,
- ctype_base::mask(alpha | print | lower) /* y */,
- ctype_base::mask(alpha | print | lower) /* z */,
- ctype_base::mask(punct | print) /* { */,
- ctype_base::mask(punct | print) /* | */,
- ctype_base::mask(punct | print) /* } */,
- ctype_base::mask(punct | print) /* ~ */,
- cntrl /* del (0x7f)*/,
- /* ASCII is a 7-bit code, so everything else is non-ASCII */
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
- ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0)
- };
- return _S_classic_table;
-}
-
-// For every c in the range 0 <= c < 256, _S_upper[c] is the
-// uppercased version of c and _S_lower[c] is the lowercased
-// version. As before, these two tables assume the ASCII character
-// set.
-
-const unsigned char _S_upper[ctype<char>::table_size] =
-{
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
- 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
- 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
- 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
- 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
- 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
- 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
-};
-
-const unsigned char _S_lower[ctype<char>::table_size] =
-{
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
- 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
- 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
- 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
- 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
-};
-
-//An helper struct to check wchar_t index without generating warnings
-//under some compilers (gcc) because of a limited range of value
-//(when wchar_t is unsigned)
-template <bool _IsSigned>
-struct _WCharIndexT;
-
-#if !(defined (__BORLANDC__) && !defined(__linux__)) && \
- !(defined (__GNUC__) && (defined (__MINGW32__) || defined (__CYGWIN__))) && \
- !defined (__ICL)
-_STLP_TEMPLATE_NULL
-struct _WCharIndexT<true> {
- static bool in_range(wchar_t c, size_t upperBound) {
- return c >= 0 && size_t(c) < upperBound;
- }
-};
-#endif
-
-_STLP_TEMPLATE_NULL
-struct _WCharIndexT<false> {
- static bool in_range(wchar_t c, size_t upperBound) {
- return size_t(c) < upperBound;
- }
-};
-
-typedef _WCharIndexT<wchar_t(-1) < 0> _WCharIndex;
-
-// Some helper functions used in ctype<>::scan_is and scan_is_not.
-
-struct _Ctype_is_mask : public unary_function<char, bool> {
- ctype_base::mask _Mask;
- const ctype_base::mask* _M_table;
-
- _Ctype_is_mask(ctype_base::mask __m, const ctype_base::mask* __t) : _Mask(__m), _M_table(__t) {}
- bool operator()(char __c) const { return (_M_table[(unsigned char) __c] & _Mask) != 0; }
-};
-
-struct _Ctype_not_mask : public unary_function<char, bool> {
- ctype_base::mask _Mask;
- const ctype_base::mask* _M_table;
-
- _Ctype_not_mask(ctype_base::mask __m, const ctype_base::mask* __t) : _Mask(__m), _M_table(__t) {}
- bool operator()(char __c) const { return (_M_table[(unsigned char) __c] & _Mask) == 0; }
-};
-
-ctype<char>::ctype(const ctype_base::mask * __tab, bool __del, size_t __refs) :
- locale::facet(__refs),
- _M_ctype_table(__tab ? __tab : classic_table()),
- _M_delete(__tab && __del)
-{}
-
-ctype<char>::~ctype() {
- if (_M_delete)
- delete[] __CONST_CAST(ctype_base::mask *, _M_ctype_table);
-}
-
-const char*
-#if defined (__DMC__)
-_STLP_DECLSPEC
-#endif
-ctype<char>::scan_is(ctype_base::mask __m, const char* __low, const char* __high) const
-{ return _STLP_STD::find_if(__low, __high, _Ctype_is_mask(__m, _M_ctype_table)); }
-
-const char*
-#if defined (__DMC__)
-_STLP_DECLSPEC
-#endif
-ctype<char>::scan_not(ctype_base::mask __m, const char* __low, const char* __high) const
-{ return _STLP_STD::find_if(__low, __high, _Ctype_not_mask(__m, _M_ctype_table)); }
-
-char ctype<char>::do_toupper(char __c) const
-{ return (char) _S_upper[(unsigned char) __c]; }
-char ctype<char>::do_tolower(char __c) const
-{ return (char) _S_lower[(unsigned char) __c]; }
-
-const char* ctype<char>::do_toupper(char* __low, const char* __high) const {
- for ( ; __low < __high; ++__low)
- *__low = (char) _S_upper[(unsigned char) *__low];
- return __high;
-}
-const char* ctype<char>::do_tolower(char* __low, const char* __high) const {
- for ( ; __low < __high; ++__low)
- *__low = (char) _S_lower[(unsigned char) *__low];
- return __high;
-}
-
-char
-ctype<char>::do_widen(char __c) const { return __c; }
-
-const char*
-ctype<char>::do_widen(const char* __low, const char* __high,
- char* __to) const {
- _STLP_PRIV __copy_trivial(__low, __high, __to);
- return __high;
-}
-char
-ctype<char>::do_narrow(char __c, char /* dfault */ ) const { return __c; }
-const char*
-ctype<char>::do_narrow(const char* __low, const char* __high,
- char /* dfault */, char* __to) const {
- _STLP_PRIV __copy_trivial(__low, __high, __to);
- return __high;
-}
-
-
-#if !defined (_STLP_NO_WCHAR_T)
-
-struct _Ctype_w_is_mask : public unary_function<wchar_t, bool> {
- ctype_base::mask M;
- const ctype_base::mask* table;
-
- _Ctype_w_is_mask(ctype_base::mask m, const ctype_base::mask* t)
- : M(m), table(t) {}
- bool operator()(wchar_t c) const
- { return _WCharIndex::in_range(c, ctype<char>::table_size) && (table[c] & M); }
-};
-
-//----------------------------------------------------------------------
-// ctype<wchar_t>
-
-ctype<wchar_t>::~ctype() {}
-
-
-bool ctype<wchar_t>::do_is(ctype_base::mask m, wchar_t c) const {
- const ctype_base::mask * table = ctype<char>::classic_table();
- return _WCharIndex::in_range(c, ctype<char>::table_size) && (m & table[c]);
-}
-
-const wchar_t* ctype<wchar_t>::do_is(const wchar_t* low, const wchar_t* high,
- ctype_base::mask * vec) const {
- // boris : not clear if this is the right thing to do...
- const ctype_base::mask * table = ctype<char>::classic_table();
- wchar_t c;
- for ( ; low < high; ++low, ++vec) {
- c = *low;
- *vec = _WCharIndex::in_range(c, ctype<char>::table_size) ? table[c] : ctype_base::mask(0);
- }
- return high;
-}
-
-const wchar_t*
-ctype<wchar_t>::do_scan_is(ctype_base::mask m,
- const wchar_t* low, const wchar_t* high) const {
- return find_if(low, high, _Ctype_w_is_mask(m, ctype<char>::classic_table()));
-}
-
-
-const wchar_t*
-ctype<wchar_t>::do_scan_not(ctype_base::mask m,
- const wchar_t* low, const wchar_t* high) const {
- return find_if(low, high, not1(_Ctype_w_is_mask(m, ctype<char>::classic_table())));
-}
-
-wchar_t ctype<wchar_t>::do_toupper(wchar_t c) const {
- return _WCharIndex::in_range(c, ctype<char>::table_size) ? (wchar_t)_S_upper[c]
- : c;
-}
-
-const wchar_t*
-ctype<wchar_t>::do_toupper(wchar_t* low, const wchar_t* high) const {
- for ( ; low < high; ++low) {
- wchar_t c = *low;
- *low = _WCharIndex::in_range(c, ctype<char>::table_size) ? (wchar_t)_S_upper[c]
- : c;
- }
- return high;
-}
-
-wchar_t ctype<wchar_t>::do_tolower(wchar_t c) const {
- return _WCharIndex::in_range(c, ctype<char>::table_size) ? (wchar_t)_S_lower[c]
- : c;
-}
-
-const wchar_t*
-ctype<wchar_t>::do_tolower(wchar_t* low, const wchar_t* high) const {
- for ( ; low < high; ++low) {
- wchar_t c = *low;
- *low = _WCharIndex::in_range(c, ctype<char>::table_size) ? (wchar_t)_S_lower[c]
- : c;
- }
- return high;
-}
-
-wchar_t ctype<wchar_t>::do_widen(char c) const {
- return (wchar_t)(unsigned char)c;
-}
-
-const char*
-ctype<wchar_t>::do_widen(const char* low, const char* high,
- wchar_t* dest) const {
- while (low != high)
- *dest++ = (wchar_t)(unsigned char)*low++;
- return high;
-}
-
-char ctype<wchar_t>::do_narrow(wchar_t c, char dfault) const
-{ return (unsigned char)c == c ? (char)c : dfault; }
-
-const wchar_t* ctype<wchar_t>::do_narrow(const wchar_t* low,
- const wchar_t* high,
- char dfault, char* dest) const {
- while (low != high) {
- wchar_t c = *low++;
- *dest++ = (unsigned char)c == c ? (char)c : dfault;
- }
-
- return high;
-}
-
-# endif
-_STLP_END_NAMESPACE
-
-// Local Variables:
-// mode:C++
-// End:
-
diff --git a/src/cxa.c b/src/cxa.c
deleted file mode 100644
index 998170e..0000000
--- a/src/cxa.c
+++ /dev/null
@@ -1,198 +0,0 @@
-#include "stlport_prefix.h"
-
-#if defined(__unix) && defined(__GNUC__)
-
-#ifdef __FreeBSD__
-# include <osreldate.h>
-#endif
-
-#if (defined(__FreeBSD__) && (__FreeBSD_version < 503001)) || defined(__sun) || defined (__hpux)
-/* Note: __cxa_finalize and __cxa_atexit present in libc in FreeBSD 5.3 */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <pthread.h>
-
-/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@" "STLPORT_5_0_0"); */
-/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@@" "STLPORT_5_0_0"); */
-
-/* Not atomic! */
-/* But we can use static mutexes here: I hope that performance issue isn't very
- significant on unloading (for only few calls, ~10) - ptr */
-
-/*
-#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
- ({ __typeof (mem) __gmemp = (mem); \
- __typeof (*mem) __gnewval = (newval); \
- \
- *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; })
-*/
-
-enum {
- ef_free, /* `ef_free' MUST be zero! */
- ef_us,
- ef_on,
- ef_at,
- ef_cxa
-};
-
-struct exit_function
-{
- /* `flavour' should be of type of the `enum' above but since we need
- this element in an atomic operation we have to use `long int'. */
- long int flavor;
- union {
- void (*at)(void);
- struct {
- void (*fn)(int status, void *arg);
- void *arg;
- } on;
- struct {
- void (*fn)(void *arg, int status);
- void *arg;
- void *dso_handle;
- } cxa;
- } func;
-};
-
-struct exit_function_list
-{
- struct exit_function_list *next;
- size_t idx;
- struct exit_function fns[32];
-};
-
-struct exit_function *__new_exitfn (void);
-
-/* Register a function to be called by exit or when a shared library
- is unloaded. This function is only called from code generated by
- the C++ compiler. */
-int __cxa_atexit(void (*func)(void *), void *arg, void *d)
-{
- struct exit_function *new = __new_exitfn ();
-
- if ( new == NULL )
- return -1;
-
- new->flavor = ef_cxa;
- new->func.cxa.fn = (void (*) (void *, int)) func;
- new->func.cxa.arg = arg;
- new->func.cxa.dso_handle = d;
- return 0;
-}
-
-
-/* We change global data, so we need locking. */
-#ifdef __linux__
-static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-#endif
-/* #ifdef __FreeBSD__ */
-#if 0
-static pthread_mutex_t lock =
- { PTHREAD_MUTEX_RECURSIVE /* PTHREAD_MUTEX_DEFAULT */, PTHREAD_PRIO_NONE, {NULL,NULL},
- NULL, { NULL }, /* MUTEX_FLAGS_PRIVATE */ 0x1, 0, 0, 0, {NULL, NULL},
- { 0, 0, 0, 0 } };
-#endif
-#ifdef __sun
-static pthread_mutex_t lock =
- {{0, 0, 0, PTHREAD_MUTEX_RECURSIVE, _MUTEX_MAGIC}, {{{0}}}, 0};
-#endif
-#ifdef __hpux
-static pthread_mutex_t lock = PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP;
-# ifdef __ia64
-void *__dso_handle = (void *) &__dso_handle;
-# endif
-#endif
-
-
-static struct exit_function_list initial;
-struct exit_function_list *__exit_funcs = &initial;
-
-struct exit_function *__new_exitfn(void)
-{
- struct exit_function_list *l;
- size_t i = 0;
-
-#ifndef __FreeBSD__
- pthread_mutex_lock( &lock );
-#endif
-
- for (l = __exit_funcs; l != NULL; l = l->next) {
- for (i = 0; i < l->idx; ++i)
- if (l->fns[i].flavor == ef_free)
- break;
- if ( i < l->idx )
- break;
-
- if (l->idx < sizeof (l->fns) / sizeof (l->fns[0])) {
- i = l->idx++;
- break;
- }
- }
-
- if (l == NULL) {
- l = (struct exit_function_list *)malloc( sizeof(struct exit_function_list) );
- if (l != NULL) {
- l->next = __exit_funcs;
- __exit_funcs = l;
-
- l->idx = 1;
- i = 0;
- }
- }
-
- /* Mark entry as used, but we don't know the flavor now. */
- if ( l != NULL )
- l->fns[i].flavor = ef_us;
-
-#ifndef __FreeBSD__
- pthread_mutex_unlock( &lock );
-#endif
-
- return l == NULL ? NULL : &l->fns[i];
-}
-
-/* If D is non-NULL, call all functions registered with `__cxa_atexit'
- with the same dso handle. Otherwise, if D is NULL, call all of the
- registered handlers. */
-
-/*
- * Note, that original __cxa_finalize don't use lock, but use __exit_funcs
- * i.e. global data.
- */
-void __cxa_finalize(void *d)
-{
- struct exit_function_list *funcs;
-
-#ifndef __FreeBSD__
- pthread_mutex_lock( &lock );
-#endif
-
- for (funcs = __exit_funcs; funcs; funcs = funcs->next) {
- struct exit_function *f;
-
- for (f = &funcs->fns[funcs->idx - 1]; f >= &funcs->fns[0]; --f) {
- if ( (d == NULL || d == f->func.cxa.dso_handle) && (f->flavor == ef_cxa) ) {
- f->flavor = ef_free;
- (*f->func.cxa.fn) (f->func.cxa.arg, 0);
- }
- }
- }
-
- /* Remove the registered fork handlers. We do not have to
- unregister anything if the program is going to terminate anyway. */
-#ifdef UNREGISTER_ATFORK
- if (d != NULL)
- UNREGISTER_ATFORK (d);
-#endif
-#ifndef __FreeBSD__
- pthread_mutex_unlock( &lock );
-#endif
-}
-
-/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@@" "STLPORT_5_0_0"); */
-/* void __cxa_finalize(void *d) __attribute__ ((weak)); */
-
-#endif /* OS name */
-#endif /* __unix */
-
diff --git a/src/details/fstream_stdio.cpp b/src/details/fstream_stdio.cpp
deleted file mode 100644
index 8392ffd..0000000
--- a/src/details/fstream_stdio.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#if defined (__SUNPPRO_CC) && !defined (_STLP_NO_NEW_C_HEADERS)
-# include <time.h>
-// For sunpro, it chokes if time.h is included through stat.h
-#endif
-
-#include <fstream>
-
-#ifdef __CYGWIN__
-# define __int64 long long
-#endif
-
-#include <cstdio>
-#if !defined(__ISCPP__)
-extern "C" {
-# include <sys/stat.h>
-}
-#endif
-
-#if defined( __MSL__ )
-# include <unix.h>
-#endif
-
-#if defined(__ISCPP__)
-# include <c_locale_is/filestat.h>
-#endif
-
-#if defined(__BEOS__) && defined(__INTEL__)
-# include <fcntl.h>
-# include <sys/stat.h> // For _fstat
-#endif
-
-#if defined (_STLP_MSVC) || defined (__MINGW32__)
-# include <fcntl.h>
-# define S_IREAD _S_IREAD
-# define S_IWRITE _S_IWRITE
-# define S_IFREG _S_IFREG
- // map permission masks
-# ifndef S_IRUSR
-# define S_IRUSR _S_IREAD
-# define S_IWUSR _S_IWRITE
-# endif
-# ifndef S_IRGRP
-# define S_IRGRP _S_IREAD
-# define S_IWGRP _S_IWRITE
-# endif
-# ifndef S_IROTH
-# define S_IROTH _S_IREAD
-# define S_IWOTH _S_IWRITE
-# endif
-
-# ifndef O_RDONLY
-# define O_RDONLY _O_RDONLY
-# define O_WRONLY _O_WRONLY
-# define O_RDWR _O_RDWR
-# define O_APPEND _O_APPEND
-# define O_CREAT _O_CREAT
-# define O_TRUNC _O_TRUNC
-# define O_TEXT _O_TEXT
-# define O_BINARY _O_BINARY
-# endif
-
-# ifndef O_ACCMODE
-# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-# endif
-#endif
-
-const _STLP_fd INVALID_STLP_FD = -1;
-
-
-# ifdef __MSL__
-# define _O_TEXT 0x0
-# if !defined( O_TEXT )
-# define O_TEXT _O_TEXT
-# endif
-# define _S_IFREG S_IFREG
-# define S_IREAD S_IRUSR
-# define S_IWRITE S_IWUSR
-# define S_IEXEC S_IXUSR
-# define _S_IWRITE S_IWRITE
-# define _S_IREAD S_IREAD
-# define _open open
-# define _close close
-# define _read read
-# define _write write
-# endif
-
-_STLP_BEGIN_NAMESPACE
-
-// Compare with streamoff definition in stl/char_traits.h!
-
-#if defined (_STLP_USE_DEFAULT_FILE_OFFSET) || \
- (!defined(_LARGEFILE_SOURCE) && !defined(_LARGEFILE64_SOURCE))
-# define FOPEN fopen
-# define FSEEK fseek
-# define FSTAT fstat
-# define STAT stat
-# define FTELL ftell
-#else
-# define FOPEN fopen64
-# define FSEEK fseeko64
-# define FSTAT fstat64
-# define STAT stat64
-# define FTELL ftello64
-#endif
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// Helper functions for _Filebuf_base.
-
-static bool __is_regular_file(_STLP_fd fd) {
- struct STAT buf;
- return FSTAT(fd, &buf) == 0 && (buf.st_mode & S_IFREG) != 0 ;
-}
-
-// Number of characters in the file.
-static streamoff __file_size(_STLP_fd fd) {
- streamoff ret = 0;
-
- struct STAT buf;
- if (FSTAT(fd, &buf) == 0 && (buf.st_mode & S_IFREG) != 0)
- ret = buf.st_size > 0 ? buf.st_size : 0;
-
- return ret;
-}
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-// All version of Unix have mmap and lseek system calls. Some also have
-// longer versions of those system calls to accommodate 64-bit offsets.
-// If we're on a Unix system, define some macros to encapsulate those
-// differences.
-
-size_t _Filebuf_base::_M_page_size = 4096;
-
-_Filebuf_base::_Filebuf_base()
- : _M_file_id(INVALID_STLP_FD),
- _M_openmode(0),
- _M_is_open(false),
- _M_should_close(false)
-{}
-
-void _Filebuf_base::_S_initialize()
-{
-
-}
-
-// Return the size of the file. This is a wrapper for stat.
-// Returns zero if the size cannot be determined or is ill-defined.
-streamoff _Filebuf_base::_M_file_size()
-{
- return _STLP_PRIV __file_size(_M_file_id);
-}
-
-bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode,
- long permission)
-{
- _STLP_fd file_no;
-
- if (_M_is_open)
- return false;
-
- // use FILE-based i/o
- const char* flags;
-
- switch (openmode & (~ios_base::ate)) {
- case ios_base::out:
- case ios_base::out | ios_base::trunc:
- flags = "w";
- break;
-
- case ios_base::out | ios_base::binary:
- case ios_base::out | ios_base::trunc | ios_base::binary:
- flags = "wb";
- break;
-
- case ios_base::out | ios_base::app:
- flags = "a";
- break;
-
- case ios_base::out | ios_base::app | ios_base::binary:
- flags = "ab";
- break;
-
- case ios_base::in:
- flags = "r";
- break;
-
- case ios_base::in | ios_base::binary:
- flags = "rb";
- break;
-
- case ios_base::in | ios_base::out:
- flags = "r+";
- break;
-
- case ios_base::in | ios_base::out | ios_base::binary:
- flags = "r+b";
- break;
-
- case ios_base::in | ios_base::out | ios_base::trunc:
- flags = "w+";
- break;
-
- case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
- flags = "w+b";
- break;
-
- default: // The above are the only combinations of
- return false; // flags allowed by the C++ standard.
- }
-
- // fbp : TODO : set permissions !
- (void)permission; // currently unused //*TY 02/26/2000 - added to suppress warning message
- _M_file = FOPEN(name, flags);
-
- if (_M_file) {
- file_no = fileno(_M_file);
- } else {
- return false;
- }
-
- // unset buffering immediately
- setbuf(_M_file, 0);
-
- _M_is_open = true;
-
- if (openmode & ios_base::ate) {
- if (FSEEK(_M_file, 0, SEEK_END) != 0)
- _M_is_open = false;
- }
-
- _M_file_id = file_no;
- _M_should_close = _M_is_open;
- _M_openmode = openmode;
-
- if (_M_is_open)
- _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
-
- return (_M_is_open != 0);
-}
-
-
-bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode)
-{
- // This doesn't really grant everyone in the world read/write
- // access. On Unix, file-creation system calls always clear
- // bits that are set in the umask from the permissions flag.
- return this->_M_open(name, openmode, S_IRUSR | S_IWUSR | S_IRGRP |
- S_IWGRP | S_IROTH | S_IWOTH);
-}
-
-// Associated the filebuf with a file descriptor pointing to an already-
-// open file. Mode is set to be consistent with the way that the file
-// was opened.
-bool _Filebuf_base::_M_open( int file_no, ios_base::openmode )
-{
- if (_M_is_open || file_no < 0)
- return false;
-
- struct STAT buf;
- if (FSTAT(file_no, &buf) != 0)
- return false;
- int mode = buf.st_mode;
-
- switch ( mode & (S_IWRITE | S_IREAD) ) {
- case S_IREAD:
- _M_openmode = ios_base::in;
- break;
- case S_IWRITE:
- _M_openmode = ios_base::out;
- break;
- case (S_IWRITE | S_IREAD):
- _M_openmode = ios_base::in | ios_base::out;
- break;
- default:
- return false;
- }
- _M_file_id = file_no;
- _M_is_open = true;
- _M_should_close = false;
- _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
- return true;
-}
-
-bool _Filebuf_base::_M_close()
-{
- if (!_M_is_open)
- return false;
-
- bool ok = _M_should_close ? (fclose(_M_file) == 0) : true;
-
- _M_is_open = _M_should_close = false;
- _M_openmode = 0;
- return ok;
-}
-
-// Read up to n characters into a buffer. Return value is number of
-// characters read.
-ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n) {
- return fread(buf, 1, n, _M_file);
-}
-
-// Write n characters from a buffer. Return value: true if we managed
-// to write the entire buffer, false if we didn't.
-bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n)
-{
- for (;;) {
- ptrdiff_t written = fwrite(buf, 1, n, _M_file);
-
- if (n == written) {
- return true;
- }
-
- if (written > 0 && written < n) {
- n -= written;
- buf += written;
- } else {
- return false;
- }
- }
-}
-
-// Wrapper for lseek or the like.
-streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir)
-{
- int whence;
-
- switch ( dir ) {
- case ios_base::beg:
- if (offset < 0 /* || offset > _M_file_size() */ )
- return streamoff(-1);
- whence = SEEK_SET;
- break;
- case ios_base::cur:
- whence = SEEK_CUR;
- break;
- case ios_base::end:
- if (/* offset > 0 || */ -offset > _M_file_size() )
- return streamoff(-1);
- whence = SEEK_END;
- break;
- default:
- return streamoff(-1);
- }
-
- if ( FSEEK(_M_file, offset, whence) == 0 ) {
- return FTELL(_M_file);
- }
-
- return streamoff(-1);
-}
-
-
-// Attempts to memory-map len bytes of the current file, starting
-// at position offset. Precondition: offset is a multiple of the
-// page size. Postcondition: return value is a null pointer if the
-// memory mapping failed. Otherwise the return value is a pointer to
-// the memory-mapped file and the file position is set to offset.
-void *_Filebuf_base::_M_mmap(streamoff, streamoff )
-{
- return 0;
-}
-
-void _Filebuf_base::_M_unmap(void*, streamoff)
-{
- // precondition : there is a valid mapping at the moment
-}
-
-_STLP_END_NAMESPACE
diff --git a/src/details/fstream_unistd.cpp b/src/details/fstream_unistd.cpp
deleted file mode 100644
index 7440883..0000000
--- a/src/details/fstream_unistd.cpp
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#if defined (__SUNPPRO_CC) && !defined (_STLP_NO_NEW_C_HEADERS)
-# include <time.h>
-// For sunpro, it chokes if time.h is included through stat.h
-#endif
-
-#include <fstream>
-
-#ifdef __CYGWIN__
-# define __int64 long long
-#endif
-
-extern "C" {
-// open/close/read/write
-#include <sys/stat.h> // For stat
-#if !defined (_CRAY) && ! defined (__EMX__)
-# include <sys/mman.h> // For mmap
-#endif
-
-// on HP-UX 11, this one contradicts with pthread.h on pthread_atfork, unless we unset this
-#if defined (__hpux) && defined (__GNUC__)
-# undef _INCLUDE_POSIX1C_SOURCE
-#endif
-
-#include <unistd.h>
-#include <fcntl.h>
-}
-
-#ifdef __APPLE__
-# include <sys/sysctl.h>
-#endif
-
-const _STLP_fd INVALID_STLP_FD = -1;
-
-#ifndef O_ACCMODE
-# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-#endif
-
-// Compare with streamoff definition in stl/char_traits.h!
-#if defined (_STLP_USE_DEFAULT_FILE_OFFSET) || \
- (!defined(_LARGEFILE_SOURCE) && !defined (_LARGEFILE64_SOURCE))
-# define FSTAT fstat
-# define STAT stat
-# define LSEEK lseek
-# define MMAP mmap
-# define OPEN open
-#else
-# define FSTAT fstat64
-# define STAT stat64
-# define LSEEK lseek64
-# define MMAP mmap64
-# define OPEN open64
-#endif
-
-#ifndef MAP_FAILED /* MMAP failure return code */
-# define MAP_FAILED -1
-#endif
-
-_STLP_BEGIN_NAMESPACE
-
-static ios_base::openmode flag_to_openmode(int mode)
-{
- ios_base::openmode ret = ios_base::__default_mode;
-
- switch ( mode & O_ACCMODE ) {
- case O_RDONLY:
- ret = ios_base::in;
- break;
- case O_WRONLY:
- ret = ios_base::out;
- break;
- case O_RDWR:
- ret = ios_base::in | ios_base::out;
- break;
- }
-
- if ( mode & O_APPEND )
- ret |= ios_base::app;
-
- return ret;
-}
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// Helper functions for _Filebuf_base.
-
-static bool __is_regular_file(_STLP_fd fd) {
- struct STAT buf;
- return FSTAT(fd, &buf) == 0 && S_ISREG(buf.st_mode);
-}
-
-// Number of characters in the file.
-static streamoff __file_size(_STLP_fd fd) {
- streamoff ret = 0;
-
- struct STAT buf;
- if (FSTAT(fd, &buf) == 0 && S_ISREG(buf.st_mode))
- ret = buf.st_size > 0 ? buf.st_size : 0;
-
- return ret;
-}
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-size_t _Filebuf_base::_M_page_size = 4096;
-
-_Filebuf_base::_Filebuf_base()
- : _M_file_id(INVALID_STLP_FD),
- _M_openmode(0),
- _M_is_open(false),
- _M_should_close(false)
-{}
-
-void _Filebuf_base::_S_initialize()
-{
-#if defined (__APPLE__)
- int mib[2];
- size_t pagesize, len;
- mib[0] = CTL_HW;
- mib[1] = HW_PAGESIZE;
- len = sizeof(pagesize);
- sysctl(mib, 2, &pagesize, &len, NULL, 0);
- _M_page_size = pagesize;
-#elif defined (__DJGPP) && defined (_CRAY)
- _M_page_size = BUFSIZ;
-#else
- _M_page_size = sysconf(_SC_PAGESIZE);
-#endif
-}
-
-// Return the size of the file. This is a wrapper for stat.
-// Returns zero if the size cannot be determined or is ill-defined.
-streamoff _Filebuf_base::_M_file_size()
-{
- return _STLP_PRIV __file_size(_M_file_id);
-}
-
-bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode,
- long permission)
-{
- _STLP_fd file_no;
-
- if (_M_is_open)
- return false;
-
- int flags = 0;
-
- // Unix makes no distinction between text and binary files.
- switch ( openmode & (~ios_base::ate & ~ios_base::binary) ) {
- case ios_base::out:
- case ios_base::out | ios_base::trunc:
- flags = O_WRONLY | O_CREAT | O_TRUNC;
- break;
- case ios_base::app:
- case ios_base::out | ios_base::app:
- flags = O_WRONLY | O_CREAT | O_APPEND;
- break;
- case ios_base::in:
- flags = O_RDONLY;
- permission = 0; // Irrelevant unless we're writing.
- break;
- case ios_base::in | ios_base::out:
- flags = O_RDWR;
- break;
- case ios_base::in | ios_base::out | ios_base::trunc:
- flags = O_RDWR | O_CREAT | O_TRUNC;
- break;
- case ios_base::in | ios_base::app:
- case ios_base::in | ios_base::out | ios_base::app:
- flags = O_RDWR | O_CREAT | O_APPEND;
- break;
- default: // The above are the only combinations of
- return false; // flags allowed by the C++ standard.
- }
-
- file_no = OPEN(name, flags, permission);
-
- if (file_no < 0)
- return false;
-
- _M_is_open = true;
-
- if ((openmode & (ios_base::ate | ios_base::app)) && (LSEEK(file_no, 0, SEEK_END) == -1)) {
- _M_is_open = false;
- }
-
- _M_file_id = file_no;
- _M_should_close = _M_is_open;
- _M_openmode = openmode;
-
- if (_M_is_open)
- _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
-
- return (_M_is_open != 0);
-}
-
-
-bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode)
-{
- // This doesn't really grant everyone in the world read/write
- // access. On Unix, file-creation system calls always clear
- // bits that are set in the umask from the permissions flag.
- return this->_M_open(name, openmode, S_IRUSR | S_IWUSR | S_IRGRP |
- S_IWGRP | S_IROTH | S_IWOTH);
-}
-
-// Associated the filebuf with a file descriptor pointing to an already-
-// open file. Mode is set to be consistent with the way that the file
-// was opened.
-bool _Filebuf_base::_M_open(int file_no, ios_base::openmode)
-{
- if (_M_is_open || file_no < 0)
- return false;
-
- int mode = fcntl(file_no, F_GETFL);
-
- if (mode == -1)
- return false;
-
- _M_openmode = flag_to_openmode(mode);
- _M_file_id = file_no;
-
- _M_is_open = true;
- _M_should_close = false;
- _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
- return true;
-}
-
-bool _Filebuf_base::_M_close()
-{
- if (!_M_is_open)
- return false;
-
- bool ok = _M_should_close ? (close(_M_file_id) == 0) : true;
-
- _M_is_open = _M_should_close = false;
- _M_openmode = 0;
- return ok;
-}
-
-// Read up to n characters into a buffer. Return value is number of
-// characters read.
-ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n)
-{
- return read(_M_file_id, buf, n);
-}
-
-// Write n characters from a buffer. Return value: true if we managed
-// to write the entire buffer, false if we didn't.
-bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n)
-{
- for (;;) {
- ptrdiff_t written = write(_M_file_id, buf, n);
-
- if (n == written) {
- return true;
- }
-
- if (written > 0 && written < n) {
- n -= written;
- buf += written;
- } else {
- return false;
- }
- }
-}
-
-// Wrapper for lseek or the like.
-streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir)
-{
- int whence;
-
- switch ( dir ) {
- case ios_base::beg:
- if (offset < 0 /* || offset > _M_file_size() */ )
- return streamoff(-1);
- whence = SEEK_SET;
- break;
- case ios_base::cur:
- whence = SEEK_CUR;
- break;
- case ios_base::end:
- if (/* offset > 0 || */ -offset > _M_file_size() )
- return streamoff(-1);
- whence = SEEK_END;
- break;
- default:
- return streamoff(-1);
- }
-
- return LSEEK(_M_file_id, offset, whence);
-}
-
-// Attempts to memory-map len bytes of the current file, starting
-// at position offset. Precondition: offset is a multiple of the
-// page size. Postcondition: return value is a null pointer if the
-// memory mapping failed. Otherwise the return value is a pointer to
-// the memory-mapped file and the file position is set to offset.
-void* _Filebuf_base::_M_mmap(streamoff offset, streamoff len)
-{
- void* base;
-#if !defined (__DJGPP) && !defined (_CRAY)
- base = MMAP(0, len, PROT_READ, MAP_PRIVATE, _M_file_id, offset);
- if (base != (void*)MAP_FAILED) {
- if (LSEEK(_M_file_id, offset + len, SEEK_SET) < 0) {
- this->_M_unmap(base, len);
- base = 0;
- }
- } else
- base =0;
-#else
- _STLP_MARK_PARAMETER_AS_UNUSED(&offset)
- _STLP_MARK_PARAMETER_AS_UNUSED(&len)
- base = 0;
-#endif
- return base;
-}
-
-void _Filebuf_base::_M_unmap(void* base, streamoff len)
-{
- // precondition : there is a valid mapping at the moment
-#if !defined (__DJGPP) && !defined (_CRAY)
- munmap((char*)base, len);
-#else
- _STLP_MARK_PARAMETER_AS_UNUSED(&len)
- _STLP_MARK_PARAMETER_AS_UNUSED(base)
-#endif
-}
-
-_STLP_END_NAMESPACE
diff --git a/src/details/fstream_win32io.cpp b/src/details/fstream_win32io.cpp
deleted file mode 100644
index 673f367..0000000
--- a/src/details/fstream_win32io.cpp
+++ /dev/null
@@ -1,629 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include <fstream>
-
-#if !defined (_STLP_WCE)
-# ifdef __BORLANDC__
-# include <cfcntl.h> // For _O_RDONLY, etc
-# else
-# include <io.h> // For _get_osfhandle
-# include <fcntl.h> // For _O_RDONLY, etc
-# endif
-# include <sys/stat.h> // For _fstat
-#endif
-
-#define _TEXTBUF_SIZE 0x1000
-
-const _STLP_fd INVALID_STLP_FD = INVALID_HANDLE_VALUE;
-
-#if !defined (INVALID_SET_FILE_POINTER)
-# define INVALID_SET_FILE_POINTER 0xffffffff
-#endif
-
-#ifndef O_ACCMODE
-# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-#endif
-
-_STLP_BEGIN_NAMESPACE
-
-#if !defined(__MSL__) && !defined(_STLP_WCE)
-static ios_base::openmode flag_to_openmode(int mode) {
- ios_base::openmode ret = ios_base::__default_mode;
-
- switch (mode & O_ACCMODE) {
- case O_RDONLY:
- ret = ios_base::in; break;
- case O_WRONLY:
- ret = ios_base::out; break;
- case O_RDWR:
- ret = ios_base::in | ios_base::out; break;
- }
-
- if (mode & O_APPEND)
- ret |= ios_base::app;
-
- if (mode & O_BINARY)
- ret |= ios_base::binary;
-
- return ret;
-}
-#endif
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// Helper functions for _Filebuf_base.
-
-static bool __is_regular_file(_STLP_fd fd) {
- BY_HANDLE_FILE_INFORMATION info;
-
- // Return true if the file handle isn't a directory.
- return GetFileInformationByHandle(fd, &info) &&
- ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
-}
-
-// Number of characters in the file.
-static streamoff __file_size(_STLP_fd fd) {
- streamoff ret = 0;
-
- LARGE_INTEGER li;
- li.LowPart = GetFileSize(fd, (unsigned long*) &li.HighPart);
- if (li.LowPart != INVALID_FILE_SIZE || GetLastError() == NO_ERROR)
- ret = li.QuadPart;
-
- return ret;
-}
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-// Visual C++ and Intel use this, but not Metrowerks
-// Also MinGW, msvcrt.dll (but not crtdll.dll) dependent version
-#if (defined (_STLP_MSVC_LIB) && !defined (_STLP_WCE)) || \
- (defined (__MINGW32__) && defined (__MSVCRT__))
-
-// fcntl(fileno, F_GETFL) for Microsoft library
-// 'semi-documented' defines:
-# define IOINFO_L2E 5
-# define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
-# define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + \
- ((i) & (IOINFO_ARRAY_ELTS - 1)) )
-# define FAPPEND 0x20 // O_APPEND flag
-# define FTEXT 0x80 // O_TEXT flag
-// end of 'semi-documented' defines
-
-// 'semi-documented' internal structure
-extern "C" {
- struct ioinfo {
- long osfhnd; // the real os HANDLE
- char osfile; // file handle flags
- char pipech; // pipe buffer
-# if defined (_MT)
- // multi-threaded locking
- int lockinitflag;
- CRITICAL_SECTION lock;
-# endif
- };
-# if defined (__MINGW32__)
- __MINGW_IMPORT ioinfo * __pioinfo[];
-# else
- extern _CRTIMP ioinfo * __pioinfo[];
-# endif
-} // extern "C"
-// end of 'semi-documented' declarations
-
-static ios_base::openmode _get_osfflags(int fd, HANDLE oshandle) {
- char dosflags = 0;
- if (fd >= 0)
- dosflags = _pioinfo(fd)->osfile;
- //else
- //the file will be considered as open in binary mode with no append attribute
- // end of 'semi-documented' stuff
-
- int mode = 0;
- if (dosflags & FAPPEND)
- mode |= O_APPEND;
-
- if (dosflags & FTEXT)
- mode |= O_TEXT;
- else
- mode |= O_BINARY;
-
- // For Read/Write access we have to guess
- DWORD dummy, dummy2;
- BOOL writeOk = WriteFile(oshandle, &dummy2, 0, &dummy, 0);
- BOOL readOk = ReadFile(oshandle, &dummy2, 0, &dummy, NULL);
- if (writeOk && readOk)
- mode |= O_RDWR;
- else if (readOk)
- mode |= O_RDONLY;
- else
- mode |= O_WRONLY;
-
- return flag_to_openmode(mode);
-}
-
-#elif defined (__DMC__)
-
-# define FHND_APPEND 0x04
-# define FHND_DEVICE 0x08
-# define FHND_TEXT 0x10
-
-extern "C" unsigned char __fhnd_info[_NFILE];
-
-static ios_base::openmode _get_osfflags(int fd, HANDLE oshandle) {
- int mode = 0;
-
- if (__fhnd_info[fd] & FHND_APPEND)
- mode |= O_APPEND;
-
- if (__fhnd_info[fd] & FHND_TEXT == 0)
- mode |= O_BINARY;
-
- for (FILE *fp = &_iob[0]; fp < &_iob[_NFILE]; fp++) {
- if ((fileno(fp) == fd) && (fp->_flag & (_IOREAD | _IOWRT | _IORW))) {
- const int osflags = fp->_flag;
-
- if ((osflags & _IOREAD) && !(osflags & _IOWRT) && !(osflags & _IORW))
- mode |= O_RDONLY;
- else if ((osflags & _IOWRT) && !(osflags & _IOREAD) && !(osflags & _IORW))
- mode |= O_WRONLY;
- else
- mode |= O_RDWR;
- break;
- }
- }
-
- return flag_to_openmode(mode);
-}
-#endif
-
-size_t _Filebuf_base::_M_page_size = 4096;
-
-_Filebuf_base::_Filebuf_base()
- : _M_file_id(INVALID_STLP_FD),
- _M_openmode(0),
- _M_is_open(false),
- _M_should_close(false),
- _M_view_id(0)
-{}
-
-void _Filebuf_base::_S_initialize() {
- SYSTEM_INFO SystemInfo;
- GetSystemInfo(&SystemInfo);
- _M_page_size = SystemInfo.dwPageSize;
- // might be .dwAllocationGranularity
-}
-
-// Return the size of the file. This is a wrapper for stat.
-// Returns zero if the size cannot be determined or is ill-defined.
-streamoff _Filebuf_base::_M_file_size() {
- return _STLP_PRIV __file_size(_M_file_id);
-}
-
-bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode,
- long permission) {
- _STLP_fd file_no;
-
- if (_M_is_open)
- return false;
-
- DWORD dwDesiredAccess, dwCreationDisposition;
- bool doTruncate = false;
-
- switch (openmode & (~ios_base::ate & ~ios_base::binary)) {
- case ios_base::out:
- case ios_base::out | ios_base::trunc:
- dwDesiredAccess = GENERIC_WRITE;
- dwCreationDisposition = OPEN_ALWAYS;
- // boris : even though it is very non-intuitive, standard
- // requires them both to behave same.
- doTruncate = true;
- break;
- case ios_base::out | ios_base::app:
- dwDesiredAccess = GENERIC_WRITE;
- dwCreationDisposition = OPEN_ALWAYS;
- break;
- case ios_base::in:
- dwDesiredAccess = GENERIC_READ;
- dwCreationDisposition = OPEN_EXISTING;
- permission = 0; // Irrelevant unless we're writing.
- break;
- case ios_base::in | ios_base::out:
- dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
- dwCreationDisposition = OPEN_EXISTING;
- break;
- case ios_base::in | ios_base::out | ios_base::trunc:
- dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
- dwCreationDisposition = OPEN_ALWAYS;
- doTruncate = true;
- break;
- default: // The above are the only combinations of
- return false; // flags allowed by the C++ standard.
- }
-
- DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
-
-#if defined(_STLP_USE_WIDE_INTERFACE)
- file_no = CreateFile (_STLP_PRIV __ASCIIToWide(name).c_str(),
-#else
- file_no = CreateFileA(name,
-#endif
- dwDesiredAccess, dwShareMode, 0,
- dwCreationDisposition, permission, 0);
-
- if (file_no == INVALID_STLP_FD)
- return false;
-
- if (
-#if !defined (_STLP_WCE)
- GetFileType(file_no) == FILE_TYPE_DISK &&
-#endif
- ((doTruncate && SetEndOfFile(file_no) == 0) ||
- (((openmode & ios_base::ate) != 0) &&
- (SetFilePointer(file_no, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)))) {
- CloseHandle(file_no);
- return false;
- }
-
- _M_is_open = true;
- _M_file_id = file_no;
- _M_should_close = _M_is_open;
- _M_openmode = openmode;
-
- if (_M_is_open)
- _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
-
- return (_M_is_open != 0);
-}
-
-bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode) {
- // This doesn't really grant everyone in the world read/write
- // access. On Unix, file-creation system calls always clear
- // bits that are set in the umask from the permissions flag.
- return this->_M_open(name, openmode, FILE_ATTRIBUTE_NORMAL);
-}
-
-bool _Filebuf_base::_M_open(_STLP_fd __id, ios_base::openmode init_mode) {
-#if (defined (_STLP_MSVC_LIB) && !defined (_STLP_WCE)) || \
- (defined (__MINGW32__) && defined (__MSVCRT__)) || defined (__DMC__)
-
- if (_M_is_open || __id == INVALID_STLP_FD)
- return false;
-
- if (init_mode != ios_base::__default_mode)
- _M_openmode = init_mode;
- else
- _M_openmode = _get_osfflags(-1, __id);
-
- _M_is_open = true;
- _M_file_id = __id;
- _M_should_close = false;
- _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
-
- return true;
-#else
- (void)__id;
- (void)init_mode; // dwa 4/27/00 - suppress unused parameter warning
-
- // not available for the API
- return false;
-
-#endif
-}
-
-// Associated the filebuf with a file descriptor pointing to an already-
-// open file. Mode is set to be consistent with the way that the file
-// was opened.
-bool _Filebuf_base::_M_open(int file_no, ios_base::openmode init_mode) {
- if (_M_is_open || file_no < 0)
- return false;
-
-#if (defined (_STLP_MSVC_LIB) && !defined (_STLP_WCE)) || \
- (defined (__MINGW32__) && defined (__MSVCRT__)) || defined (__DMC__)
-
- HANDLE oshandle = (HANDLE)_get_osfhandle(file_no);
- if (oshandle == INVALID_STLP_FD)
- return false;
-
- if (init_mode != ios_base::__default_mode)
- _M_openmode = init_mode;
- else
- _M_openmode = _get_osfflags(file_no, oshandle);
-
- _M_file_id = oshandle;
- _M_is_open = true;
- _M_should_close = false;
- _M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
- return true;
-#else
- _STLP_MARK_PARAMETER_AS_UNUSED(&init_mode)
- // not available for the API
- return false;
-#endif
-}
-
-bool _Filebuf_base::_M_close() {
- if (!_M_is_open)
- return false;
-
- bool ok;
-
- if (!_M_should_close)
- ok = true;
- else {
- if (_M_file_id != INVALID_STLP_FD) {
- ok = (CloseHandle(_M_file_id) != 0);
- }
- else {
- ok = false;
- }
- }
-
- _M_is_open = _M_should_close = false;
- _M_openmode = 0;
- return ok;
-}
-
-
-#define _STLP_LF 10
-#define _STLP_CR 13
-#define _STLP_CTRLZ 26
-
-// Read up to n characters into a buffer. Return value is number of
-// characters read.
-ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n) {
- ptrdiff_t readen = 0;
- //Here cast to size_t is safe as n cannot be negative.
- size_t chunkSize = (min)(size_t(0xffffffff), __STATIC_CAST(size_t, n));
- // The following, while validating that we are still able to extract chunkSize
- // charaters to the buffer, avoids extraction of too small chunk of datas
- // which would be counter performant.
- while (__STATIC_CAST(size_t, (n - readen)) >= chunkSize) {
- DWORD numberOfBytesRead;
- ReadFile(_M_file_id, buf + readen, __STATIC_CAST(DWORD, chunkSize), &numberOfBytesRead, 0);
-
- if (numberOfBytesRead == 0)
- break;
-
- if (!(_M_openmode & ios_base::binary)) {
- // translate CR-LFs to LFs in the buffer
- char *to = buf + readen;
- char *from = to;
- char *last = from + numberOfBytesRead - 1;
- for (; from <= last && *from != _STLP_CTRLZ; ++from) {
- if (*from != _STLP_CR)
- *to++ = *from;
- else { // found CR
- if (from < last) { // not at buffer end
- if (*(from + 1) != _STLP_LF)
- *to++ = _STLP_CR;
- }
- else { // last char is CR, peek for LF
- char peek = ' ';
- DWORD NumberOfBytesPeeked;
- ReadFile(_M_file_id, (LPVOID)&peek, 1, &NumberOfBytesPeeked, 0);
- if (NumberOfBytesPeeked != 0) {
- if (peek != _STLP_LF) { //not a <CR><LF> combination
- *to++ = _STLP_CR;
- if ((to < buf + n) && (peek != _STLP_CR))
- //We have enough place to store peek and it is no a special
- //_STLP_CR character, we can store it.
- *to++ = peek;
- else
- SetFilePointer(_M_file_id, (LONG)-1, 0, FILE_CURRENT);
- }
- else {
- // A <CR><LF> combination, we keep the <LF>:
- *to++ = _STLP_LF;
- }
- }
- else {
- /* This case is tedious, we could
- * - put peek back in the file but this would then generate an infinite loop
- * - report an error as we don't know if in a future call to ReadFile we won't then
- * get a <LF>. Doing so would make all files with a <CR> last an invalid file
- * for STLport, a hard solution for STLport clients.
- * - store the <CR> in the returned buffer, the chosen solution, even if in this
- * case we could miss a <CR><LF> combination.
- */
- *to++ = _STLP_CR;
- }
- }
- } // found CR
- } // for
- readen = to - buf;
- // seek back to TEXT end of file if hit CTRL-Z
- if (from <= last) { // terminated due to CTRLZ
- SetFilePointer(_M_file_id, -(LONG)((last + 1) - from), 0, FILE_CURRENT);
- break;
- }
- }
- else
- readen += numberOfBytesRead;
- }
- return readen;
-}
-
-// Write n characters from a buffer. Return value: true if we managed
-// to write the entire buffer, false if we didn't.
-bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n) {
- for (;;) {
- ptrdiff_t written;
-
- //In the following implementation we are going to cast most of the ptrdiff_t
- //values in size_t to work with coherent unsigned values. Doing so make code
- //more simple especially in the min function call.
-
- // In append mode, every write does an implicit seek to the end
- // of the file.
- if (_M_openmode & ios_base::app)
- _M_seek(0, ios_base::end);
-
- if (_M_openmode & ios_base::binary) {
- // binary mode
- size_t bytes_to_write = (size_t)n;
- DWORD NumberOfBytesWritten;
- written = 0;
- for (; bytes_to_write != 0;) {
- WriteFile(_M_file_id, buf + written,
- __STATIC_CAST(DWORD, (min)(size_t(0xffffffff), bytes_to_write)),
- &NumberOfBytesWritten, 0);
- if (NumberOfBytesWritten == 0)
- return false;
- bytes_to_write -= NumberOfBytesWritten;
- written += NumberOfBytesWritten;
- }
- }
- else {
- char textbuf[_TEXTBUF_SIZE + 1]; // extra 1 in case LF at end
- char * nextblock = buf, * ptrtextbuf = textbuf;
- char * endtextbuf = textbuf + _TEXTBUF_SIZE;
- char * endblock = buf + n;
- ptrdiff_t nextblocksize = (min) (n, (ptrdiff_t)_TEXTBUF_SIZE);
- char * nextlf;
-
- while ( (nextblocksize > 0) &&
- (nextlf = (char *)memchr(nextblock, _STLP_LF, nextblocksize)) != 0) {
- ptrdiff_t linelength = nextlf - nextblock;
- memcpy(ptrtextbuf, nextblock, linelength);
- ptrtextbuf += linelength;
- nextblock += (linelength + 1);
- * ptrtextbuf ++ = _STLP_CR;
- * ptrtextbuf ++ = _STLP_LF;
- nextblocksize = (min) (ptrdiff_t(endblock - nextblock),
- (max) (ptrdiff_t(0), ptrdiff_t(endtextbuf - ptrtextbuf)));
- }
- // write out what's left, > condition is here since for LF at the end ,
- // endtextbuf may get < ptrtextbuf ...
- if (nextblocksize > 0) {
- memcpy(ptrtextbuf, nextblock, nextblocksize);
- ptrtextbuf += nextblocksize;
- nextblock += nextblocksize;
- }
- // now write out the translated buffer
- char * writetextbuf = textbuf;
- for (size_t NumberOfBytesToWrite = (size_t)(ptrtextbuf - textbuf);
- NumberOfBytesToWrite;) {
- DWORD NumberOfBytesWritten;
- WriteFile((HANDLE)_M_file_id, writetextbuf,
- __STATIC_CAST(DWORD, (min)(size_t(0xffffffff), NumberOfBytesToWrite)),
- &NumberOfBytesWritten, 0);
- if (!NumberOfBytesWritten) // write shortfall
- return false;
- writetextbuf += NumberOfBytesWritten;
- NumberOfBytesToWrite -= NumberOfBytesWritten;
- }
- // count non-translated characters
- written = (nextblock - buf);
- }
-
- if (n == written)
- return true;
- else if (written > 0 && written < n) {
- n -= written;
- buf += written;
- }
- else
- return false;
- }
-}
-
-// Wrapper for lseek or the like.
-streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir) {
- streamoff result = -1;
- int whence;
-
- switch(dir) {
- case ios_base::beg:
- if (offset < 0 /* || offset > _M_file_size() */ )
- return streamoff(-1);
- whence = FILE_BEGIN;
- break;
- case ios_base::cur:
- whence = FILE_CURRENT;
- break;
- case ios_base::end:
- if (/* offset > 0 || */ -offset > _M_file_size() )
- return streamoff(-1);
- whence = FILE_END;
- break;
- default:
- return streamoff(-1);
- }
-
- LARGE_INTEGER li;
- li.QuadPart = offset;
- li.LowPart = SetFilePointer(_M_file_id, li.LowPart, &li.HighPart, whence);
- if (li.LowPart != INVALID_SET_FILE_POINTER || GetLastError() == NO_ERROR)
- result = li.QuadPart;
-
- return result;
-}
-
-
-// Attempts to memory-map len bytes of the current file, starting
-// at position offset. Precondition: offset is a multiple of the
-// page size. Postcondition: return value is a null pointer if the
-// memory mapping failed. Otherwise the return value is a pointer to
-// the memory-mapped file and the file position is set to offset.
-void* _Filebuf_base::_M_mmap(streamoff offset, streamoff len) {
- void* base;
- _M_view_id = CreateFileMapping(_M_file_id, (PSECURITY_ATTRIBUTES)0 ,
- PAGE_READONLY, 0 /* len >> 32 */ ,
- 0 /* len & 0xFFFFFFFF */ , // low-order DWORD of size
- 0);
-
- if (_M_view_id) {
-#if 0
-/*
- printf("view %x created from file %x, error = %d, size = %d, map_offset = %d map_len = %d\n",
- _M_view_id, _M_file_id, GetLastError(),
- (int)cur_filesize, ULL(offset) & 0xffffffff, len);
-*/
-#endif
- LARGE_INTEGER li;
- li.QuadPart = offset;
- base = MapViewOfFile(_M_view_id, FILE_MAP_READ, li.HighPart, li.LowPart,
-#if !defined (__DMC__)
- __STATIC_CAST(SIZE_T, len));
-#else
- __STATIC_CAST(DWORD, len));
-#endif
- // check if mapping succeded and is usable
- if (base == 0 || _M_seek(offset + len, ios_base::beg) < 0) {
- this->_M_unmap(base, len);
- base = 0;
- }
- } else
- base = 0;
-
- return base;
-}
-
-void _Filebuf_base::_M_unmap(void* base, streamoff len) {
- // precondition : there is a valid mapping at the moment
- if (base != NULL)
- UnmapViewOfFile(base);
- // destroy view handle as well
- if (_M_view_id != NULL)
- CloseHandle(_M_view_id);
- _M_view_id = NULL;
- (void)len; //unused variable
-}
-
-_STLP_END_NAMESPACE
diff --git a/src/dll_main.cpp b/src/dll_main.cpp
deleted file mode 100644
index faaa721..0000000
--- a/src/dll_main.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
- /*
- *
- * Copyright (c) 1994
- * Hewlett-Packard Company
- *
- * Copyright (c) 1996,1997
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1997
- * Moscow Center for SPARC Technology
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION
-
-#include "stlport_prefix.h"
-
-#if !defined (_STLP_DEBUG) && ! defined (_STLP_ASSERTIONS)
-# if !defined (__APPLE__) || !defined (__GNUC__) || (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3))
-/* dums: Please if the following code was being uncommented please explain why
- * as for the moment it only looks like a source of inconsistency in the way
- * STLport different translation units are compiled.
- */
-//# define _STLP_ASSERTIONS 1
-# endif
-#endif
-
-#include <utility>
-#include <memory>
-#include <vector>
-#include <set>
-#include <list>
-#include <slist>
-#include <deque>
-#include <hash_map>
-#include <limits>
-#include <string>
-#include <stdexcept>
-#include <bitset>
-#include <locale>
-
-#if defined (__DMC__)
-// for rope static members
-# include <rope>
-#endif
-
-#include <stl/_range_errors.c>
-
-_STLP_BEGIN_NAMESPACE
-
-#if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS)
-exception::exception() _STLP_NOTHROW {}
-exception::~exception() _STLP_NOTHROW {}
-bad_exception::bad_exception() _STLP_NOTHROW {}
-bad_exception::~bad_exception() _STLP_NOTHROW {}
-const char* exception::what() const _STLP_NOTHROW { return "class exception"; }
-const char* bad_exception::what() const _STLP_NOTHROW { return "class bad_exception"; }
-#endif
-
-#if defined (_STLP_OWN_STDEXCEPT)
-# include <stl/_stdexcept_base.c>
-
-// boris : those are needed to force typeinfo nodes to be created in here only
-logic_error::~logic_error() _STLP_NOTHROW_INHERENTLY {}
-runtime_error::~runtime_error() _STLP_NOTHROW_INHERENTLY {}
-domain_error::~domain_error() _STLP_NOTHROW_INHERENTLY {}
-invalid_argument::~invalid_argument() _STLP_NOTHROW_INHERENTLY {}
-length_error::~length_error() _STLP_NOTHROW_INHERENTLY {}
-out_of_range::~out_of_range() _STLP_NOTHROW_INHERENTLY {}
-range_error::~range_error() _STLP_NOTHROW_INHERENTLY {}
-overflow_error::~overflow_error() _STLP_NOTHROW_INHERENTLY {}
-underflow_error::~underflow_error() _STLP_NOTHROW_INHERENTLY {}
-
-#endif
-
-#if !defined(_STLP_WCE_EVC3)
-# if defined (_STLP_NO_BAD_ALLOC)
-const nothrow_t nothrow /* = {} */;
-# endif
-#endif
-
-#if !defined (_STLP_NO_FORCE_INSTANTIATE)
-
-# if defined (_STLP_DEBUG) || defined (_STLP_ASSERTIONS)
-_STLP_MOVE_TO_PRIV_NAMESPACE
-template class _STLP_CLASS_DECLSPEC __stl_debug_engine<bool>;
-_STLP_MOVE_TO_STD_NAMESPACE
-# endif
-
-template class _STLP_CLASS_DECLSPEC __debug_alloc<__node_alloc>;
-template class _STLP_CLASS_DECLSPEC __debug_alloc<__new_alloc>;
-
-//Export of the types used to represent buckets in the hashtable implementation.
-/*
- * For the vector class we do not use any MSVC6 workaround even if we export it from
- * the STLport dynamic libraries because we know what methods are called and none is
- * a template method. Moreover the exported class is an instanciation of vector with
- * _Slist_node_base struct that is an internal STLport class that no user should ever
- * use.
- */
-# if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
-template class _STLP_CLASS_DECLSPEC allocator<_STLP_PRIV _Slist_node_base*>;
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base**, _Slist_node_base*,
- allocator<_Slist_node_base*> >;
-template class _STLP_CLASS_DECLSPEC _Vector_base<_Slist_node_base*,
- allocator<_Slist_node_base*> >;
-_STLP_MOVE_TO_STD_NAMESPACE
-# endif
-
-# if defined (_STLP_DEBUG)
-_STLP_MOVE_TO_PRIV_NAMESPACE
-template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_NAME(vector)<_Slist_node_base*,
- allocator<_Slist_node_base*> >;
-_STLP_MOVE_TO_STD_NAMESPACE
-# endif
-
-template class _STLP_CLASS_DECLSPEC vector<_STLP_PRIV _Slist_node_base*,
- allocator<_STLP_PRIV _Slist_node_base*> >;
-//End of hashtable bucket types export.
-
-//Export of _Locale_impl facets container:
-# if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
-template class _STLP_CLASS_DECLSPEC allocator<locale::facet*>;
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<locale::facet**, locale::facet*, allocator<locale::facet*> >;
-template class _STLP_CLASS_DECLSPEC _Vector_base<locale::facet*, allocator<locale::facet*> >;
-_STLP_MOVE_TO_STD_NAMESPACE
-
-# endif
-# if defined (_STLP_DEBUG)
-_STLP_MOVE_TO_PRIV_NAMESPACE
-# define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector)
-template class _STLP_CLASS_DECLSPEC __construct_checker<_STLP_PRIV _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> > >;
-template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> >;
-# undef _STLP_NON_DBG_VECTOR
-_STLP_MOVE_TO_STD_NAMESPACE
-# endif
-
-template class _STLP_CLASS_DECLSPEC vector<locale::facet*, allocator<locale::facet*> >;
-//End of export of _Locale_impl facets container.
-
-# if defined (_STLP_USE_PTR_SPECIALIZATIONS)
-template class _STLP_CLASS_DECLSPEC allocator<void*>;
-
-typedef _STLP_PRIV _List_node<void*> _VoidPtr_Node;
-template class _STLP_CLASS_DECLSPEC allocator<_VoidPtr_Node>;
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<void**, void*, allocator<void*> >;
-template class _STLP_CLASS_DECLSPEC _Vector_base<void*, allocator<void*> >;
-template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(vector)<void*, allocator<void*> >;
-
-template class _STLP_CLASS_DECLSPEC _List_node<void*>;
-template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_List_node_base, _VoidPtr_Node, allocator<_VoidPtr_Node> >;
-template class _STLP_CLASS_DECLSPEC _List_base<void*, allocator<void*> >;
-template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(list)<void*, allocator<void*> >;
-
-template class _STLP_CLASS_DECLSPEC _Slist_node<void*>;
-template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base, _Slist_node<void*>, allocator<_Slist_node<void*> > >;
-template class _STLP_CLASS_DECLSPEC _Slist_base<void*, allocator<void*> >;
-template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(slist)<void*, allocator<void*> >;
-
-template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<size_t, void*, allocator<void*> >;
-template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<void***, void**, allocator<void**> >;
-template struct _STLP_CLASS_DECLSPEC _Deque_iterator<void*, _Nonconst_traits<void*> >;
-template class _STLP_CLASS_DECLSPEC _Deque_base<void*, allocator<void*> >;
-template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(deque)<void*, allocator<void*> >;
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-# endif /* _STLP_USE_PTR_SPECIALIZATIONS */
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-template class _STLP_CLASS_DECLSPEC _Rb_global<bool>;
-template class _STLP_CLASS_DECLSPEC _List_global<bool>;
-
-template class _STLP_CLASS_DECLSPEC _Sl_global<bool>;
-template class _STLP_CLASS_DECLSPEC _Stl_prime<bool>;
-
-template class _STLP_CLASS_DECLSPEC _LimG<bool>;
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-#endif /* _STLP_NO_FORCE_INSTANTIATE */
-
-_STLP_END_NAMESPACE
-
-#if defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY)
-extern "C" void _STLP_DECLSPEC _STLP_CALL _STLP_SIGNAL_RUNTIME_COMPATIBILITY() {}
-#endif
-
-#define FORCE_SYMBOL extern
-
-#if defined (_WIN32) && defined (_STLP_USE_DECLSPEC) && !defined (_STLP_USE_STATIC_LIB)
-// stlportmt.cpp : Defines the entry point for the DLL application.
-//
-# undef FORCE_SYMBOL
-# define FORCE_SYMBOL APIENTRY
-
-extern "C" {
-
-BOOL APIENTRY DllMain( HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID) {
- switch (ul_reason_for_call) {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls((HINSTANCE)hModule);
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
-}
-
-} /* extern "C" */
-
-#if !defined (_STLP_MSVC) && !defined (__MINGW32__)
-_STLP_BEGIN_NAMESPACE
-
-static void FORCE_SYMBOL
-force_link() {
- set<int>::iterator iter;
- // _M_increment; _M_decrement instantiation
- ++iter;
- --iter;
-}
-
-_STLP_END_NAMESPACE
-#endif
-
-#endif /* _WIN32 */
-
-#if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300)
-# undef std
-
-namespace std
-{
- void _STLP_CALL unexpected() {
- unexpected_handler hdl;
- set_unexpected(hdl = set_unexpected((unexpected_handler)0));
- hdl();
- }
-}
-#endif
diff --git a/src/facets_byname.cpp b/src/facets_byname.cpp
deleted file mode 100644
index 07d1a3d..0000000
--- a/src/facets_byname.cpp
+++ /dev/null
@@ -1,1057 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <hash_map>
-#include <vector>
-
-#include <locale>
-#include <istream>
-
-#include <algorithm>
-#include <functional>
-
-#include "c_locale.h"
-#include "locale_impl.h"
-#include "acquire_release.h"
-
-_STLP_BEGIN_NAMESPACE
-
-//----------------------------------------------------------------------
-// ctype_byname<char>
-
-#if defined (__DMC__)
-_STLP_DECLSPEC
-#endif
-ctype_byname<char>::ctype_byname(const char* name, size_t refs)
- : ctype<char>( 0, false, refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_ctype = _STLP_PRIV __acquire_ctype(name, buf, 0, &__err_code);
- if (!_M_ctype)
- locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
-
- _M_init();
-}
-
-void ctype_byname<char>::_M_init() {
- _M_ctype_table = _M_byname_table;
-
- // We have to do this, instead of just pointer twiddling, because
- // ctype_base::mask isn't the same type as _Locale_mask_t.
- const _Locale_mask_t* p = _Locale_ctype_table(_M_ctype);
- for (size_t i = 0; i != table_size; ++i) {
- _M_byname_table[i] = ctype_base::mask(p[i]);
- }
-}
-
-ctype_byname<char>::~ctype_byname()
-{ _STLP_PRIV __release_ctype(_M_ctype); }
-
-char ctype_byname<char>::do_toupper(char c) const
-{ return (char)_Locale_toupper(_M_ctype, c); }
-
-char ctype_byname<char>::do_tolower(char c) const
-{ return (char)_Locale_tolower(_M_ctype, c); }
-
-const char*
-ctype_byname<char>::do_toupper(char* first, const char* last) const {
- for ( ; first != last ; ++first)
- *first = (char)_Locale_toupper(_M_ctype, *first);
- return last;
-}
-
-const char*
-ctype_byname<char>::do_tolower(char* first, const char* last) const {
- for ( ; first != last ; ++first)
- *first = (char)_Locale_tolower(_M_ctype, *first);
- return last;
-}
-
-
-// Some helper functions used in ctype<>::scan_is and scan_is_not.
-#if !defined (_STLP_NO_WCHAR_T)
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// ctype_byname<wchar_t>
-
-struct _Ctype_byname_w_is_mask : public unary_function<wchar_t, bool> {
- _Locale_mask_t M;
- _Locale_ctype* M_ctp;
-
- _Ctype_byname_w_is_mask(_Locale_mask_t m, _Locale_ctype* c)
- : M(m), M_ctp(c) {}
- bool operator()(wchar_t c) const
- { return _WLocale_ctype(M_ctp, c, M) != 0; }
-};
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-#if defined (__DMC__)
-_STLP_DECLSPEC
-#endif
-ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
- : ctype<wchar_t>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_ctype = _STLP_PRIV __acquire_ctype(name, buf, 0, &__err_code);
- if (!_M_ctype)
- locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
-}
-
-ctype_byname<wchar_t>::~ctype_byname()
-{ _STLP_PRIV __release_ctype(_M_ctype); }
-
-bool ctype_byname<wchar_t>::do_is(ctype_base::mask m, wchar_t c) const
-{ return _WLocale_ctype(_M_ctype, c, (_Locale_mask_t)m) != 0; }
-
-const wchar_t*
-ctype_byname<wchar_t>::do_is(const wchar_t* low, const wchar_t* high,
- ctype_base::mask * m) const {
- _Locale_mask_t all_bits = _Locale_mask_t(ctype_base::space |
- ctype_base::print |
- ctype_base::cntrl |
- ctype_base::upper |
- ctype_base::lower |
- ctype_base::alpha |
- ctype_base::digit |
- ctype_base::punct |
- ctype_base::xdigit);
-
- for ( ; low < high; ++low, ++m)
- *m = ctype_base::mask (_WLocale_ctype(_M_ctype, *low, all_bits));
- return high;
-}
-
-const wchar_t*
-ctype_byname<wchar_t>
- ::do_scan_is(ctype_base::mask m, const wchar_t* low, const wchar_t* high) const
-{ return find_if(low, high, _STLP_PRIV _Ctype_byname_w_is_mask(m, _M_ctype)); }
-
-const wchar_t*
-ctype_byname<wchar_t>
- ::do_scan_not(ctype_base::mask m, const wchar_t* low, const wchar_t* high) const
-{ return find_if(low, high, not1(_STLP_PRIV _Ctype_byname_w_is_mask(m, _M_ctype))); }
-
-wchar_t ctype_byname<wchar_t>::do_toupper(wchar_t c) const
-{ return _WLocale_toupper(_M_ctype, c); }
-
-const wchar_t*
-ctype_byname<wchar_t>::do_toupper(wchar_t* low, const wchar_t* high) const {
- for ( ; low < high; ++low)
- *low = _WLocale_toupper(_M_ctype, *low);
- return high;
-}
-
-wchar_t ctype_byname<wchar_t>::do_tolower(wchar_t c) const
-{ return _WLocale_tolower(_M_ctype, c); }
-
-const wchar_t*
-ctype_byname<wchar_t>::do_tolower(wchar_t* low, const wchar_t* high) const {
- for ( ; low < high; ++low)
- *low = _WLocale_tolower(_M_ctype, *low);
- return high;
-}
-
-#endif /* WCHAR_T */
-
-// collate_byname<char>
-#if defined (__DMC__)
-_STLP_DECLSPEC
-#endif
-collate_byname<char>::collate_byname(const char* name, size_t refs)
- : collate<char>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_collate = _STLP_PRIV __acquire_collate(name, buf, 0, &__err_code);
- if (!_M_collate)
- locale::_M_throw_on_creation_failure(__err_code, name, "collate");
-}
-
-collate_byname<char>::~collate_byname()
-{ _STLP_PRIV __release_collate(_M_collate); }
-
-int collate_byname<char>::do_compare(const char* __low1,
- const char* __high1,
- const char* __low2,
- const char* __high2) const {
- return _Locale_strcmp(_M_collate,
- __low1, __high1 - __low1,
- __low2, __high2 - __low2);
-}
-
-collate_byname<char>::string_type
-collate_byname<char>::do_transform(const char* low, const char* high) const {
- if (low == high)
- return string_type();
-
- size_t n = _Locale_strxfrm(_M_collate, NULL, 0, low, high - low);
-
- // NOT PORTABLE. What we're doing relies on internal details of the
- // string implementation. (Contiguity of string elements and presence
- // of trailing zero.)
- string_type buf(n, 0);
- _Locale_strxfrm(_M_collate, &(*buf.begin()), n + 1, low, high - low);
- return buf;
-}
-
-
-#if !defined (_STLP_NO_WCHAR_T)
-
-// collate_byname<wchar_t>
-
-#if defined (__DMC__)
-_STLP_DECLSPEC
-#endif
-collate_byname<wchar_t>::collate_byname(const char* name, size_t refs)
- : collate<wchar_t>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_collate = _STLP_PRIV __acquire_collate(name, buf, 0, &__err_code);
- if (!_M_collate)
- locale::_M_throw_on_creation_failure(__err_code, name, "collate");
-}
-
-collate_byname<wchar_t>::~collate_byname()
-{ _STLP_PRIV __release_collate(_M_collate); }
-
-int collate_byname<wchar_t>::do_compare(const wchar_t* low1,
- const wchar_t* high1,
- const wchar_t* low2,
- const wchar_t* high2) const {
- return _WLocale_strcmp(_M_collate,
- low1, high1 - low1,
- low2, high2 - low2);
-}
-
-collate_byname<wchar_t>::string_type
-collate_byname<wchar_t>::do_transform(const wchar_t* low,
- const wchar_t* high) const {
- if (low == high)
- return string_type();
-
- size_t n = _WLocale_strxfrm(_M_collate, NULL, 0, low, high - low);
-
- // NOT PORTABLE. What we're doing relies on internal details of the
- // string implementation. (Contiguity of string elements and presence
- // of trailing zero.)
- string_type buf(n, 0);
- _WLocale_strxfrm(_M_collate, &(*buf.begin()), n + 1, low, high - low);
- return buf;
-}
-
-#endif /* _STLP_NO_WCHAR_T */
-
-//----------------------------------------------------------------------
-// codecvt_byname<char>
-
-codecvt_byname<char, char, mbstate_t>
- ::codecvt_byname(const char* name, size_t refs)
- : codecvt<char, char, mbstate_t>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-}
-
-codecvt_byname<char, char, mbstate_t>::~codecvt_byname() {}
-
-
-#if !defined (_STLP_NO_WCHAR_T)
-
-//----------------------------------------------------------------------
-// codecvt_byname<wchar_t>
-codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname(const char* name, size_t refs)
- : codecvt<wchar_t, char, mbstate_t>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_codecvt = _STLP_PRIV __acquire_codecvt(name, buf, 0, &__err_code);
- if (!_M_codecvt)
- locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
-}
-
-codecvt_byname<wchar_t, char, mbstate_t>::~codecvt_byname()
-{ _STLP_PRIV __release_codecvt(_M_codecvt); }
-
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt_byname<wchar_t, char, mbstate_t>::do_out(state_type& state,
- const intern_type* from,
- const intern_type* from_end,
- const intern_type*& from_next,
- extern_type* to,
- extern_type* to_limit,
- extern_type*& to_next) const {
- while (from != from_end && to != to_limit) {
- size_t chars_stored = _WLocale_wctomb(_M_codecvt,
- to, to_limit - to, *from,
- &state);
- if (chars_stored == (size_t) -1) {
- from_next = from;
- to_next = to;
- return error;
- }
- else if (chars_stored == (size_t) -2) {
- from_next = from;
- to_next = to;
- return partial;
- }
-
- ++from;
- to += chars_stored;
- }
-
- from_next = from;
- to_next = to;
- return ok;
-}
-
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt_byname<wchar_t, char, mbstate_t>::do_in(state_type& state,
- const extern_type* from,
- const extern_type* from_end,
- const extern_type*& from_next,
- intern_type* to,
- intern_type* to_end,
- intern_type*& to_next) const {
- while (from != from_end && to != to_end) {
- size_t chars_read = _WLocale_mbtowc(_M_codecvt,
- to, from, from_end - from,
- &state);
- if (chars_read == (size_t) -1) {
- from_next = from;
- to_next = to;
- return error;
- }
-
- if (chars_read == (size_t) -2) {
- from_next = from;
- to_next = to;
- return partial;
- }
-
- from += chars_read;
- to++;
- }
-
- from_next = from;
- to_next = to;
- return ok;
-}
-
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt_byname<wchar_t, char, mbstate_t>::do_unshift(state_type& state,
- extern_type* to,
- extern_type* to_limit,
- extern_type*& to_next) const {
- to_next = to;
- size_t result = _WLocale_unshift(_M_codecvt, &state,
- to, to_limit - to, &to_next);
- if (result == (size_t) -1)
- return error;
- else if (result == (size_t) -2)
- return partial;
- else
-# if defined (__ISCPP__)
- return /*to_next == to ? noconv :*/ ok;
-# else
- return to_next == to ? noconv : ok;
-# endif
-}
-
-int
-codecvt_byname<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW {
- if (_WLocale_is_stateless(_M_codecvt)) {
- int max_width = _WLocale_mb_cur_max(_M_codecvt);
- int min_width = _WLocale_mb_cur_min(_M_codecvt);
- return min_width == max_width ? min_width : 0;
- }
- else
- return -1;
-}
-
-bool
-codecvt_byname<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
-{ return false; }
-
-int
-codecvt_byname<wchar_t, char, mbstate_t>::do_length(state_type& state,
- const extern_type* from,
- const extern_type* end,
- size_t mx) const {
- size_t __count = 0;
- while (from != end && mx--) {
- intern_type __dummy;
- size_t chars_read = _WLocale_mbtowc(_M_codecvt,
- &__dummy, from, end - from,
- &state);
- if ((chars_read == (size_t) -1) || (chars_read == (size_t) -2)) // error or partial
- break;
- __count += chars_read;
- from += chars_read;
- }
- return int(__count);
-}
-
-int
-codecvt_byname<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
-{ return _WLocale_mb_cur_max(_M_codecvt); }
-#endif
-
-// numpunct_byname<char>
-numpunct_byname<char>::numpunct_byname(const char* name, size_t refs)
-: numpunct<char>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_numeric = _STLP_PRIV __acquire_numeric(name, buf, 0, &__err_code);
- if (!_M_numeric)
- locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
-}
-
-numpunct_byname<char>::~numpunct_byname()
-{ _STLP_PRIV __release_numeric(_M_numeric); }
-
-char numpunct_byname<char>::do_decimal_point() const
-{ return _Locale_decimal_point(_M_numeric); }
-
-char numpunct_byname<char>::do_thousands_sep() const
-{ return _Locale_thousands_sep(_M_numeric); }
-
-string numpunct_byname<char>::do_grouping() const {
- const char * __grouping = _Locale_grouping(_M_numeric);
- if (__grouping != NULL && __grouping[0] == CHAR_MAX)
- __grouping = "";
- return __grouping;
-}
-
-string numpunct_byname<char>::do_truename() const
-{ return _Locale_true(_M_numeric); }
-
-string numpunct_byname<char>::do_falsename() const
-{ return _Locale_false(_M_numeric); }
-
-//----------------------------------------------------------------------
-// numpunct<wchar_t>
-
-#if !defined (_STLP_NO_WCHAR_T)
-
-// numpunct_byname<wchar_t>
-
-numpunct_byname<wchar_t>::numpunct_byname(const char* name, size_t refs)
-: numpunct<wchar_t>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_numeric = _STLP_PRIV __acquire_numeric(name, buf, 0, &__err_code);
- if (!_M_numeric)
- locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
-}
-
-numpunct_byname<wchar_t>::~numpunct_byname()
-{ _STLP_PRIV __release_numeric(_M_numeric); }
-
-wchar_t numpunct_byname<wchar_t>::do_decimal_point() const
-{ return _WLocale_decimal_point(_M_numeric); }
-
-wchar_t numpunct_byname<wchar_t>::do_thousands_sep() const
-{ return _WLocale_thousands_sep(_M_numeric); }
-
-string numpunct_byname<wchar_t>::do_grouping() const {
- const char * __grouping = _Locale_grouping(_M_numeric);
- if (__grouping != NULL && __grouping[0] == CHAR_MAX)
- __grouping = "";
- return __grouping;
-}
-
-wstring numpunct_byname<wchar_t>::do_truename() const {
- wchar_t buf[16];
- return _WLocale_true(_M_numeric, _STLP_ARRAY_AND_SIZE(buf));
-}
-
-wstring numpunct_byname<wchar_t>::do_falsename() const {
- wchar_t buf[16];
- return _WLocale_false(_M_numeric, _STLP_ARRAY_AND_SIZE(buf));
-}
-
-#endif
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-static void _Init_monetary_formats(money_base::pattern& pos_format,
- money_base::pattern& neg_format,
- _Locale_monetary * monetary) {
- switch (_Locale_p_sign_posn(monetary)) {
- case 0: // Parentheses surround the quantity and currency symbol
- case 1: // The sign string precedes the quantity and currency symbol
- pos_format.field[0] = (char) money_base::sign;
- if (_Locale_p_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a positive value
- pos_format.field[1] = (char) money_base::symbol;
- if (_Locale_p_sep_by_space(monetary)) {
- // a space separates currency symbol from a positive value.
- pos_format.field[2] = (char) money_base::space;
- pos_format.field[3] = (char) money_base::value;
- } else {
- // a space not separates currency symbol from a positive value.
- pos_format.field[2] = (char) money_base::value;
- pos_format.field[3] = (char) money_base::none;
- }
- } else {
- // 0 if currency symbol succeeds a positive value
- pos_format.field[1] = (char) money_base::value;
- if (_Locale_p_sep_by_space(monetary)) {
- // a space separates currency symbol from a positive value.
- pos_format.field[2] = (char) money_base::space;
- pos_format.field[3] = (char) money_base::symbol;
- } else {
- // a space not separates currency symbol from a positive value.
- pos_format.field[2] = (char) money_base::symbol;
- pos_format.field[3] = (char) money_base::none;
- }
- }
- break;
- case 2: // The sign string succeeds the quantity and currency symbol.
- if (_Locale_p_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a positive value
- pos_format.field[0] = (char) money_base::symbol;
- if (_Locale_p_sep_by_space(monetary)) {
- // a space separates currency symbol from a positive value.
- pos_format.field[1] = (char) money_base::space;
- pos_format.field[2] = (char) money_base::value;
- pos_format.field[3] = (char) money_base::sign;
- } else {
- // a space not separates currency symbol from a positive value.
- pos_format.field[1] = (char) money_base::value;
- pos_format.field[2] = (char) money_base::sign;
- pos_format.field[3] = (char) money_base::none;
- }
- } else {
- // 0 if currency symbol succeeds a positive value
- pos_format.field[0] = (char) money_base::value;
- if (_Locale_p_sep_by_space(monetary)) {
- // a space separates currency symbol from a positive value.
- pos_format.field[1] = (char) money_base::space;
- pos_format.field[2] = (char) money_base::symbol;
- pos_format.field[3] = (char) money_base::sign;
- } else {
- // a space not separates currency symbol from a positive value.
- pos_format.field[1] = (char) money_base::symbol;
- pos_format.field[2] = (char) money_base::sign;
- pos_format.field[3] = (char) money_base::none;
- }
- }
- break;
- case 3: // The sign string immediately precedes the currency symbol.
- if (_Locale_p_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a positive value
- pos_format.field[0] = (char) money_base::sign;
- pos_format.field[1] = (char) money_base::symbol;
- if (_Locale_p_sep_by_space(monetary)) {
- // a space separates currency symbol from a positive value.
- pos_format.field[2] = (char) money_base::space;
- pos_format.field[3] = (char) money_base::value;
- } else {
- // a space not separates currency symbol from a positive value.
- pos_format.field[2] = (char) money_base::value;
- pos_format.field[3] = (char) money_base::none;
- }
- } else {
- // 0 if currency symbol succeeds a positive value
- pos_format.field[0] = (char) money_base::value;
- pos_format.field[1] = (char) money_base::sign;
- pos_format.field[2] = (char) money_base::symbol;
- pos_format.field[3] = (char) money_base::none;
- }
- break;
- case 4: // The sign string immediately succeeds the currency symbol.
- if (_Locale_p_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a positive value
- pos_format.field[0] = (char) money_base::symbol;
- pos_format.field[1] = (char) money_base::sign;
- pos_format.field[2] = (char) money_base::value;
- pos_format.field[3] = (char) money_base::none;
- } else {
- // 0 if currency symbol succeeds a positive value
- pos_format.field[0] = (char) money_base::value;
- if (_Locale_p_sep_by_space(monetary)) {
- // a space separates currency symbol from a positive value.
- pos_format.field[1] = (char) money_base::space;
- pos_format.field[2] = (char) money_base::symbol;
- pos_format.field[3] = (char) money_base::sign;
- } else {
- // a space not separates currency symbol from a positive value.
- pos_format.field[1] = (char) money_base::symbol;
- pos_format.field[2] = (char) money_base::sign;
- pos_format.field[3] = (char) money_base::none;
- }
- }
- break;
- default: // Default C++ Standard format
- pos_format.field[0] = (char) money_base::symbol;
- pos_format.field[1] = (char) money_base::sign;
- pos_format.field[2] = (char) money_base::none;
- pos_format.field[3] = (char) money_base::value;
- break;
- }
-
- switch (_Locale_n_sign_posn(monetary)) {
- case 0: // Parentheses surround the quantity and currency symbol
- case 1: // The sign string precedes the quantity and currency symbol
- neg_format.field[0] = (char) money_base::sign;
- if (_Locale_n_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a negative value
- neg_format.field[1] = (char) money_base::symbol;
- if (_Locale_n_sep_by_space(monetary)) {
- // a space separates currency symbol from a negative value.
- neg_format.field[2] = (char) money_base::space;
- neg_format.field[3] = (char) money_base::value;
- } else {
- // a space not separates currency symbol from a negative value.
- neg_format.field[2] = (char) money_base::value;
- neg_format.field[3] = (char) money_base::none;
- }
- } else {
- // 0 if currency symbol succeeds a negative value
- neg_format.field[1] = (char) money_base::value;
- if (_Locale_n_sep_by_space(monetary)) {
- // a space separates currency symbol from a negative value.
- neg_format.field[2] = (char) money_base::space;
- neg_format.field[3] = (char) money_base::symbol;
- } else {
- // a space not separates currency symbol from a negative value.
- neg_format.field[2] = (char) money_base::symbol;
- neg_format.field[3] = (char) money_base::none;
- }
- }
- break;
- case 2: // The sign string succeeds the quantity and currency symbol.
- if (_Locale_n_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a negative value
- neg_format.field[0] = (char) money_base::symbol;
- if (_Locale_n_sep_by_space(monetary)) {
- // a space separates currency symbol from a negative value.
- neg_format.field[1] = (char) money_base::space;
- neg_format.field[2] = (char) money_base::value;
- neg_format.field[3] = (char) money_base::sign;
- } else {
- // a space not separates currency symbol from a negative value.
- neg_format.field[1] = (char) money_base::value;
- neg_format.field[2] = (char) money_base::sign;
- neg_format.field[3] = (char) money_base::none;
- }
- } else {
- // 0 if currency symbol succeeds a negative value
- neg_format.field[0] = (char) money_base::value;
- if (_Locale_n_sep_by_space(monetary)) {
- // a space separates currency symbol from a negative value.
- neg_format.field[1] = (char) money_base::space;
- neg_format.field[2] = (char) money_base::symbol;
- neg_format.field[3] = (char) money_base::sign;
- } else {
- // a space not separates currency symbol from a negative value.
- neg_format.field[1] = (char) money_base::symbol;
- neg_format.field[2] = (char) money_base::sign;
- neg_format.field[3] = (char) money_base::none;
- }
- }
- break;
- case 3: // The sign string immediately precedes the currency symbol.
- if (_Locale_n_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a negative value
- neg_format.field[0] = (char) money_base::sign;
- neg_format.field[1] = (char) money_base::symbol;
- if (_Locale_n_sep_by_space(monetary)) {
- // a space separates currency symbol from a negative value.
- neg_format.field[2] = (char) money_base::space;
- neg_format.field[3] = (char) money_base::value;
- } else {
- // a space not separates currency symbol from a negative value.
- neg_format.field[2] = (char) money_base::value;
- neg_format.field[3] = (char) money_base::none;
- }
- } else {
- // 0 if currency symbol succeeds a negative value
- neg_format.field[0] = (char) money_base::value;
- neg_format.field[1] = (char) money_base::sign;
- neg_format.field[2] = (char) money_base::symbol;
- neg_format.field[3] = (char) money_base::none;
- }
- break;
- case 4: // The sign string immediately succeeds the currency symbol.
- if (_Locale_n_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a negative value
- neg_format.field[0] = (char) money_base::symbol;
- neg_format.field[1] = (char) money_base::sign;
- neg_format.field[2] = (char) money_base::none;
- neg_format.field[3] = (char) money_base::value;
- } else {
- // 0 if currency symbol succeeds a negative value
- neg_format.field[0] = (char) money_base::value;
- if (_Locale_n_sep_by_space(monetary)) {
- // a space separates currency symbol from a negative value.
- neg_format.field[1] = (char) money_base::space;
- neg_format.field[2] = (char) money_base::symbol;
- neg_format.field[3] = (char) money_base::sign;
- } else {
- // a space not separates currency symbol from a negative value.
- neg_format.field[1] = (char) money_base::symbol;
- neg_format.field[2] = (char) money_base::sign;
- neg_format.field[3] = (char) money_base::none;
- }
- }
- break;
- default: // Default C++ Standard format
- neg_format.field[0] = (char) money_base::symbol;
- neg_format.field[1] = (char) money_base::sign;
- neg_format.field[2] = (char) money_base::none;
- neg_format.field[3] = (char) money_base::value;
- break;
- }
-}
-
-// international variant of monetary
-
-/*
- * int_curr_symbol
- *
- * The international currency symbol. The operand is a four-character
- * string, with the first three characters containing the alphabetic
- * international currency symbol in accordance with those specified
- * in the ISO 4217 specification. The fourth character is the character used
- * to separate the international currency symbol from the monetary quantity.
- *
- * (http://www.opengroup.org/onlinepubs/7990989775/xbd/locale.html)
- */
-
-/*
- * Standards are unclear in the usage of international currency
- * and monetary formats.
- * But I am expect that international currency symbol should be the first
- * (not depends upon where currency symbol situated in the national
- * format).
- *
- * If this isn't so, let's see:
- * 1 234.56 RUR
- * GBP 1,234.56
- * USD 1,234.56
- * The situation really is worse than you see above:
- * RUR typed wrong here---it prints '1 234.56 RUR ' (see space after RUR).
- * This is due to intl_fmp.curr_symbol() == "RUR ". (see reference in comments
- * above).
- *
- */
-
-static void _Init_monetary_formats_int(money_base::pattern& pos_format,
- money_base::pattern& neg_format,
- _Locale_monetary * monetary)
-{
-
- switch (_Locale_p_sign_posn(monetary)) {
- case 0: // Parentheses surround the quantity and currency symbol
- case 1: // The sign string precedes the quantity and currency symbol
- pos_format.field[0] = (char) money_base::symbol;
- pos_format.field[1] = (char) money_base::sign;
- pos_format.field[2] = (char) money_base::value;
- pos_format.field[3] = (char) money_base::none;
- break;
- case 2: // The sign string succeeds the quantity and currency symbol.
- pos_format.field[0] = (char) money_base::symbol;
- pos_format.field[1] = (char) money_base::value;
- pos_format.field[2] = (char) money_base::sign;
- pos_format.field[3] = (char) money_base::none;
- break;
- case 3: // The sign string immediately precedes the currency symbol.
- case 4: // The sign string immediately succeeds the currency symbol.
- pos_format.field[0] = (char) money_base::symbol;
- if (_Locale_p_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a positive value
- pos_format.field[1] = (char) money_base::sign;
- pos_format.field[2] = (char) money_base::value;
- } else {
- // 0 if currency symbol succeeds a positive value
- pos_format.field[1] = (char) money_base::value;
- pos_format.field[2] = (char) money_base::sign;
- }
- pos_format.field[3] = (char) money_base::none;
- break;
- default: // Default C++ Standard format
- pos_format.field[0] = (char) money_base::symbol;
- pos_format.field[1] = (char) money_base::sign;
- pos_format.field[2] = (char) money_base::none;
- pos_format.field[3] = (char) money_base::value;
- break;
- }
-
-
- switch (_Locale_n_sign_posn(monetary)) {
- case 0: // Parentheses surround the quantity and currency symbol
- case 1: // The sign string precedes the quantity and currency symbol
- neg_format.field[0] = (char) money_base::symbol;
- neg_format.field[1] = (char) money_base::sign;
- neg_format.field[2] = (char) money_base::value;
- neg_format.field[3] = (char) money_base::none;
- break;
- case 2: // The sign string succeeds the quantity and currency symbol.
- neg_format.field[0] = (char) money_base::symbol;
- neg_format.field[1] = (char) money_base::value;
- neg_format.field[2] = (char) money_base::sign;
- neg_format.field[3] = (char) money_base::none;
- break;
- case 3: // The sign string immediately precedes the currency symbol.
- case 4: // The sign string immediately succeeds the currency symbol.
- neg_format.field[0] = (char) money_base::symbol;
- if (_Locale_n_cs_precedes(monetary)) {
- // 1 if currency symbol precedes a negative value
- neg_format.field[1] = (char) money_base::sign;
- neg_format.field[2] = (char) money_base::value;
- } else {
- // 0 if currency symbol succeeds a negative value
- neg_format.field[1] = (char) money_base::value;
- neg_format.field[2] = (char) money_base::sign;
- }
- neg_format.field[3] = (char) money_base::none;
- break;
- default: // Default C++ Standard format
- neg_format.field[0] = (char) money_base::symbol;
- neg_format.field[1] = (char) money_base::sign;
- neg_format.field[2] = (char) money_base::none;
- neg_format.field[3] = (char) money_base::value;
- break;
- }
-}
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-//
-// moneypunct_byname<>
-//
-moneypunct_byname<char, true>::moneypunct_byname(const char * name,
- size_t refs)
- : moneypunct<char, true>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code);
- if (!_M_monetary)
- locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct");
-
- _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary);
-}
-
-moneypunct_byname<char, true>::moneypunct_byname(_Locale_monetary *__mon)
- : _M_monetary(__mon) {
- _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary);
-}
-
-moneypunct_byname<char, true>::~moneypunct_byname()
-{ _STLP_PRIV __release_monetary(_M_monetary); }
-
-char moneypunct_byname<char, true>::do_decimal_point() const
-{ return _Locale_mon_decimal_point(_M_monetary); }
-
-char moneypunct_byname<char, true>::do_thousands_sep() const
-{ return _Locale_mon_thousands_sep(_M_monetary); }
-
-string moneypunct_byname<char, true>::do_grouping() const
-{ return _Locale_mon_grouping(_M_monetary); }
-
-string moneypunct_byname<char, true>::do_curr_symbol() const
-{ return _Locale_int_curr_symbol(_M_monetary); }
-
-string moneypunct_byname<char, true>::do_positive_sign() const
-{ return _Locale_positive_sign(_M_monetary); }
-
-string moneypunct_byname<char, true>::do_negative_sign() const
-{ return _Locale_negative_sign(_M_monetary); }
-
-int moneypunct_byname<char, true>::do_frac_digits() const
-{ return _Locale_int_frac_digits(_M_monetary); }
-
-moneypunct_byname<char, false>::moneypunct_byname(const char * name,
- size_t refs)
- : moneypunct<char, false>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code);
- if (!_M_monetary)
- locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct");
-
- _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary);
-}
-
-moneypunct_byname<char, false>::moneypunct_byname(_Locale_monetary *__mon)
- : _M_monetary(__mon) {
- _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary);
-}
-
-moneypunct_byname<char, false>::~moneypunct_byname()
-{ _STLP_PRIV __release_monetary(_M_monetary); }
-
-char moneypunct_byname<char, false>::do_decimal_point() const
-{ return _Locale_mon_decimal_point(_M_monetary); }
-
-char moneypunct_byname<char, false>::do_thousands_sep() const
-{ return _Locale_mon_thousands_sep(_M_monetary); }
-
-string moneypunct_byname<char, false>::do_grouping() const
-{ return _Locale_mon_grouping(_M_monetary); }
-
-string moneypunct_byname<char, false>::do_curr_symbol() const
-{ return _Locale_currency_symbol(_M_monetary); }
-
-string moneypunct_byname<char, false>::do_positive_sign() const
-{ return _Locale_positive_sign(_M_monetary); }
-
-string moneypunct_byname<char, false>::do_negative_sign() const
-{ return _Locale_negative_sign(_M_monetary); }
-
-int moneypunct_byname<char, false>::do_frac_digits() const
-{ return _Locale_frac_digits(_M_monetary); }
-
-//
-// moneypunct_byname<wchar_t>
-//
-#if !defined (_STLP_NO_WCHAR_T)
-
-moneypunct_byname<wchar_t, true>::moneypunct_byname(const char * name,
- size_t refs)
- : moneypunct<wchar_t, true>(refs) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code);
- if (!_M_monetary)
- locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct");
-
- _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary);
-}
-
-moneypunct_byname<wchar_t, true>::moneypunct_byname(_Locale_monetary *__mon)
- : _M_monetary(__mon) {
- _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary);
-}
-
-moneypunct_byname<wchar_t, true>::~moneypunct_byname()
-{ _STLP_PRIV __release_monetary(_M_monetary); }
-
-wchar_t moneypunct_byname<wchar_t, true>::do_decimal_point() const
-{ return _Locale_mon_decimal_point(_M_monetary); }
-
-wchar_t moneypunct_byname<wchar_t, true>::do_thousands_sep() const
-{ return _Locale_mon_thousands_sep(_M_monetary); }
-
-string moneypunct_byname<wchar_t, true>::do_grouping() const
-{ return _Locale_mon_grouping(_M_monetary); }
-
-inline wstring __do_widen (string const& str) {
-#if defined (_STLP_NO_MEMBER_TEMPLATES) || defined (_STLP_MSVC)
- wstring::_Reserve_t __Reserve;
- size_t __size = str.size();
- wstring result(__Reserve, __size);
- copy(str.begin(), str.end(), result.begin());
-#else
- wstring result(str.begin(), str.end());
-#endif
- return result;
-}
-
-wstring moneypunct_byname<wchar_t, true>::do_curr_symbol() const
-{ wchar_t buf[16]; return _WLocale_int_curr_symbol(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
-
-wstring moneypunct_byname<wchar_t, true>::do_positive_sign() const
-{ wchar_t buf[16]; return _WLocale_positive_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
-
-wstring moneypunct_byname<wchar_t, true>::do_negative_sign() const
-{ wchar_t buf[16]; return _WLocale_negative_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
-
-int moneypunct_byname<wchar_t, true>::do_frac_digits() const
-{ return _Locale_int_frac_digits(_M_monetary); }
-
-moneypunct_byname<wchar_t, false>::moneypunct_byname(const char * name,
- size_t refs)
- : moneypunct<wchar_t, false>(refs) {
- if (!name)
- locale::_M_throw_on_null_name() ;
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code);
- if (!_M_monetary)
- locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct");
-
- _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary);
-}
-
-moneypunct_byname<wchar_t, false>::moneypunct_byname(_Locale_monetary *__mon)
- : _M_monetary(__mon) {
- _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary);
-}
-
-moneypunct_byname<wchar_t, false>::~moneypunct_byname()
-{ _STLP_PRIV __release_monetary(_M_monetary); }
-
-wchar_t moneypunct_byname<wchar_t, false>::do_decimal_point() const
-{ return _Locale_mon_decimal_point(_M_monetary); }
-
-wchar_t moneypunct_byname<wchar_t, false>::do_thousands_sep() const
-{ return _Locale_mon_thousands_sep(_M_monetary); }
-
-string moneypunct_byname<wchar_t, false>::do_grouping() const
-{ return _Locale_mon_grouping(_M_monetary); }
-
-wstring moneypunct_byname<wchar_t, false>::do_curr_symbol() const
-{ wchar_t buf[16]; return _WLocale_currency_symbol(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
-
-wstring moneypunct_byname<wchar_t, false>::do_positive_sign() const
-{ wchar_t buf[16]; return _WLocale_positive_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
-
-wstring moneypunct_byname<wchar_t, false>::do_negative_sign() const
-{ wchar_t buf[16]; return _WLocale_negative_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
-
-int moneypunct_byname<wchar_t, false>::do_frac_digits() const
-{ return _Locale_frac_digits(_M_monetary); }
-
-#endif
-
-_STLP_END_NAMESPACE
-
diff --git a/src/fstream.cpp b/src/fstream.cpp
deleted file mode 100644
index 81543bb..0000000
--- a/src/fstream.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#ifdef _STLP_USE_UNIX_IO
-# include "details/fstream_unistd.cpp"
-#elif defined(_STLP_USE_STDIO_IO)
-# include "details/fstream_stdio.cpp"
-#elif defined(_STLP_USE_WIN32_IO)
-# include "details/fstream_win32io.cpp"
-#else
-# error "Can't recognize IO scheme to use"
-#endif
-
-_STLP_BEGIN_NAMESPACE
-
-// fbp : let us map 1 MB maximum, just be sure not to trash VM
-#define MMAP_CHUNK 0x100000L
-
-_Underflow< char, char_traits<char> >::int_type _STLP_CALL
-_Underflow< char, char_traits<char> >::_M_doit(basic_filebuf<char, char_traits<char> >* __this)
-{
- typedef char_traits<char> traits_type;
- typedef traits_type::int_type int_type;
-
- if (!__this->_M_in_input_mode) {
- if (!__this->_M_switch_to_input_mode())
- return traits_type::eof();
- }
- else if (__this->_M_in_putback_mode) {
- __this->_M_exit_putback_mode();
- if (__this->gptr() != __this->egptr()) {
- int_type __c = traits_type::to_int_type(*__this->gptr());
- return __c;
- }
- }
-
- // If it's a disk file, and if the internal and external character
- // sequences are guaranteed to be identical, then try to use memory
- // mapped I/O. Otherwise, revert to ordinary read.
- if (__this->_M_base.__regular_file()
- && __this->_M_always_noconv
- && __this->_M_base._M_in_binary_mode()) {
- // If we've mmapped part of the file already, then unmap it.
- if (__this->_M_mmap_base)
- __this->_M_base._M_unmap(__this->_M_mmap_base, __this->_M_mmap_len);
-
- // Determine the position where we start mapping. It has to be
- // a multiple of the page size.
- streamoff __cur = __this->_M_base._M_seek(0, ios_base::cur);
- streamoff __size = __this->_M_base._M_file_size();
- if (__size > 0 && __cur >= 0 && __cur < __size) {
- streamoff __offset = (__cur / __this->_M_base.__page_size()) * __this->_M_base.__page_size();
- streamoff __remainder = __cur - __offset;
-
- __this->_M_mmap_len = __size - __offset;
-
- if (__this->_M_mmap_len > MMAP_CHUNK)
- __this->_M_mmap_len = MMAP_CHUNK;
-
- if ((__this->_M_mmap_base = __this->_M_base._M_mmap(__offset, __this->_M_mmap_len)) != 0) {
- __this->setg(__STATIC_CAST(char*, __this->_M_mmap_base),
- __STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __remainder),
- __STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __this->_M_mmap_len));
- return traits_type::to_int_type(*__this->gptr());
- }
- else
- __this->_M_mmap_len = 0;
- }
- else {
- __this->_M_mmap_base = 0;
- __this->_M_mmap_len = 0;
- }
- }
-
- return __this->_M_underflow_aux();
-}
-
-//----------------------------------------------------------------------
-// Force instantiation of filebuf and fstream classes.
-#if !defined(_STLP_NO_FORCE_INSTANTIATE)
-
-template class basic_filebuf<char, char_traits<char> >;
-template class basic_ifstream<char, char_traits<char> >;
-template class basic_ofstream<char, char_traits<char> >;
-template class basic_fstream<char, char_traits<char> >;
-
-# if !defined (_STLP_NO_WCHAR_T)
-template class _Underflow<wchar_t, char_traits<wchar_t> >;
-template class basic_filebuf<wchar_t, char_traits<wchar_t> >;
-template class basic_ifstream<wchar_t, char_traits<wchar_t> >;
-template class basic_ofstream<wchar_t, char_traits<wchar_t> >;
-template class basic_fstream<wchar_t, char_traits<wchar_t> >;
-# endif /* _STLP_NO_WCHAR_T */
-
-#endif
-
-_STLP_END_NAMESPACE
diff --git a/src/ios.cpp b/src/ios.cpp
deleted file mode 100644
index cb35e0b..0000000
--- a/src/ios.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include <algorithm>
-#include <ios>
-#include <locale>
-#include <ostream> // for __get_ostreambuf definition
-
-#include "aligned_buffer.h"
-
-_STLP_BEGIN_NAMESPACE
-
-//----------------------------------------------------------------------
-// ios_base members
-
-// class ios_base::failure, a subclass of exception. It's used solely
-// for reporting errors.
-
-ios_base::failure::failure(const string& s)
- : __Named_exception(s)
-{}
-
-ios_base::failure::~failure() _STLP_NOTHROW_INHERENTLY {}
-
-#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
-// Definitions of ios_base's formatting flags.
-const ios_base::fmtflags ios_base::left;
-const ios_base::fmtflags ios_base::right;
-const ios_base::fmtflags ios_base::internal;
-const ios_base::fmtflags ios_base::dec;
-const ios_base::fmtflags ios_base::hex;
-const ios_base::fmtflags ios_base::oct;
-const ios_base::fmtflags ios_base::fixed;
-const ios_base::fmtflags ios_base::scientific;
-const ios_base::fmtflags ios_base::boolalpha;
-const ios_base::fmtflags ios_base::showbase;
-const ios_base::fmtflags ios_base::showpoint;
-const ios_base::fmtflags ios_base::showpos;
-const ios_base::fmtflags ios_base::skipws;
-const ios_base::fmtflags ios_base::unitbuf;
-const ios_base::fmtflags ios_base::uppercase;
-const ios_base::fmtflags ios_base::adjustfield;
-const ios_base::fmtflags ios_base::basefield;
-const ios_base::fmtflags ios_base::floatfield;
-
-// Definitions of ios_base's state flags.
-const ios_base::iostate ios_base::goodbit;
-const ios_base::iostate ios_base::badbit;
-const ios_base::iostate ios_base::eofbit;
-const ios_base::iostate ios_base::failbit;
-
-// Definitions of ios_base's openmode flags.
-const ios_base::openmode ios_base::app;
-const ios_base::openmode ios_base::ate;
-const ios_base::openmode ios_base::binary;
-const ios_base::openmode ios_base::in;
-const ios_base::openmode ios_base::out;
-const ios_base::openmode ios_base::trunc;
-
-// Definitions of ios_base's seekdir flags.
-const ios_base::seekdir ios_base::beg;
-const ios_base::seekdir ios_base::cur;
-const ios_base::seekdir ios_base::end;
-
-#endif
-
-// Internal functions used for managing exponentially-growing arrays of
-// POD types.
-
-// array is a pointer to N elements of type PODType. Expands the array,
-// if necessary, so that array[index] is meaningful. All new elements are
-// initialized to zero. Returns a pointer to the new array, and the new
-// size.
-
-template <class PODType>
-static pair<PODType*, size_t>
-_Stl_expand_array(PODType* __array, size_t N, int index) {
- if ((int)N < index + 1) {
- size_t new_N = (max)(2 * N, size_t(index + 1));
- PODType* new_array
- = __STATIC_CAST(PODType*,realloc(__array, new_N * sizeof(PODType)));
- if (new_array) {
- fill(new_array + N, new_array + new_N, PODType());
- return pair<PODType*, size_t>(new_array, new_N);
- }
- else
- return pair<PODType*, size_t>(__STATIC_CAST(PODType*,0), 0);
- }
- else
- return pair<PODType*, size_t>(__array, N);
-}
-
-// array is a pointer to N elements of type PODType. Allocate a new
-// array of N elements, copying the values from the old array to the new.
-// Return a pointer to the new array. It is assumed that array is non-null
-// and N is nonzero.
-template <class PODType>
-static PODType* _Stl_copy_array(const PODType* __array, size_t N) {
- PODType* result = __STATIC_CAST(PODType*,malloc(N * sizeof(PODType)));
- if (result)
- copy(__array, __array + N, result);
- return result;
-}
-
-locale ios_base::imbue(const locale& loc) {
- if (loc != _M_locale) {
- locale previous = _M_locale;
- _M_locale = loc;
- _M_invoke_callbacks(imbue_event);
- return previous;
- }
- else {
- _M_invoke_callbacks(imbue_event);
- return _M_locale;
- }
-}
-
-int _STLP_CALL ios_base::xalloc() {
-#if defined (_STLP_THREADS) && \
- defined (_STLP_WIN32THREADS) && defined (_STLP_NEW_PLATFORM_SDK)
- static volatile __stl_atomic_t _S_index = 0;
- return _STLP_ATOMIC_INCREMENT(&_S_index);
-#else
- static int _S_index = 0;
- static _STLP_STATIC_MUTEX __lock _STLP_MUTEX_INITIALIZER;
- _STLP_auto_lock sentry(__lock);
- return _S_index++;
-#endif
-}
-
-long& ios_base::iword(int index) {
- static long dummy = 0;
-
- pair<long*, size_t> tmp = _Stl_expand_array(_M_iwords, _M_num_iwords, index);
- if (tmp.first) { // The allocation, if any, succeeded.
- _M_iwords = tmp.first;
- _M_num_iwords = tmp.second;
- return _M_iwords[index];
- }
- else {
- _M_setstate_nothrow(badbit);
- _M_check_exception_mask();
- return dummy;
- }
-}
-
-
-void*& ios_base::pword(int index) {
- static void* dummy = 0;
-
- pair<void**, size_t> tmp = _Stl_expand_array(_M_pwords, _M_num_pwords, index);
- if (tmp.first) { // The allocation, if any, succeeded.
- _M_pwords = tmp.first;
- _M_num_pwords = tmp.second;
- return _M_pwords[index];
- }
- else {
- _M_setstate_nothrow(badbit);
- _M_check_exception_mask();
- return dummy;
- }
-}
-
-void ios_base::register_callback(event_callback __fn, int index) {
- pair<pair<event_callback, int>*, size_t> tmp
- = _Stl_expand_array(_M_callbacks, _M_num_callbacks, (int)_M_callback_index /* fbp: index ??? */ );
- if (tmp.first) {
- _M_callbacks = tmp.first;
- _M_num_callbacks = tmp.second;
- _M_callbacks[_M_callback_index++] = make_pair(__fn, index);
- }
- else {
- _M_setstate_nothrow(badbit);
- _M_check_exception_mask();
- }
-}
-
-// Invokes all currently registered callbacks for a particular event.
-// Behaves correctly even if one of the callbacks adds a new callback.
-void ios_base::_M_invoke_callbacks(event E) {
- for (size_t i = _M_callback_index; i > 0; --i) {
- event_callback f = _M_callbacks[i-1].first;
- int n = _M_callbacks[i-1].second;
- f(E, *this, n);
- }
-}
-
-// This function is called if the state, rdstate(), has a bit set
-// that is also set in the exception mask exceptions().
-void ios_base::_M_throw_failure() {
- const char* arg ;
-# if 0
- char buffer[256];
- char* ptr;
- strcpy(buffer, "ios failure: rdstate = 0x");
- ptr = __write_integer(buffer+strlen(buffer), ios_base::hex, __STATIC_CAST(unsigned long,_M_iostate));
- strcpy(ptr, " mask = 0x");
- ptr = __write_integer(buffer+strlen(buffer), ios_base::hex, __STATIC_CAST(unsigned long,_M_exception_mask));
- *ptr = 0;
- arg = buffer;
-# else
- arg = "ios failure";
-# endif
-
-# ifndef _STLP_USE_EXCEPTIONS
- fputs(arg, stderr);
-# else
- throw failure(arg);
-# endif
-}
-
-// Copy x's state to *this. This member function is used in the
-// implementation of basic_ios::copyfmt. Does not copy _M_exception_mask
-// or _M_iostate.
-void ios_base::_M_copy_state(const ios_base& x) {
- _M_fmtflags = x._M_fmtflags; // Copy the flags, except for _M_iostate
- _M_openmode = x._M_openmode; // and _M_exception_mask.
- _M_seekdir = x._M_seekdir;
- _M_precision = x._M_precision;
- _M_width = x._M_width;
- _M_locale = x._M_locale;
-
- if (x._M_callbacks) {
- pair<event_callback, int>* tmp = _Stl_copy_array(x._M_callbacks, x._M_callback_index);
- if (tmp) {
- free(_M_callbacks);
- _M_callbacks = tmp;
- _M_num_callbacks = _M_callback_index = x._M_callback_index;
- }
- else {
- _M_setstate_nothrow(badbit);
- _M_check_exception_mask();
- }
- }
-
- if (x._M_iwords) {
- long* tmp = _Stl_copy_array(x._M_iwords, x._M_num_iwords);
- if (tmp) {
- free(_M_iwords);
- _M_iwords = tmp;
- _M_num_iwords = x._M_num_iwords;
- }
- else {
- _M_setstate_nothrow(badbit);
- _M_check_exception_mask();
- }
- }
-
- if (x._M_pwords) {
- void** tmp = _Stl_copy_array(x._M_pwords, x._M_num_pwords);
- if (tmp) {
- free(_M_pwords);
- _M_pwords = tmp;
- _M_num_pwords = x._M_num_pwords;
- }
- else {
- _M_setstate_nothrow(badbit);
- _M_check_exception_mask();
- }
- }
-}
-
-// ios's (protected) default constructor. The standard says that all
-// fields have indeterminate values; we initialize them to zero for
-// simplicity. The only thing that really matters is that the arrays
-// are all initially null pointers, and the array element counts are all
-// initially zero.
-ios_base::ios_base()
- : _M_fmtflags(0), _M_iostate(0), _M_openmode(0), _M_seekdir(0),
- _M_exception_mask(0),
- _M_precision(0), _M_width(0),
- _M_locale(),
- _M_callbacks(0), _M_num_callbacks(0), _M_callback_index(0),
- _M_iwords(0), _M_num_iwords(0),
- _M_pwords(0),
- _M_num_pwords(0)
-{}
-
-// ios's destructor.
-ios_base::~ios_base() {
- _M_invoke_callbacks(erase_event);
- free(_M_callbacks);
- free(_M_iwords);
- free(_M_pwords);
-}
-
-//----------------------------------------------------------------------
-// Force instantiation of basic_ios
-// For DLL exports, they are already instantiated.
-#if !defined(_STLP_NO_FORCE_INSTANTIATE)
-template class _STLP_CLASS_DECLSPEC basic_ios<char, char_traits<char> >;
-# if !defined (_STLP_NO_WCHAR_T)
-template class _STLP_CLASS_DECLSPEC basic_ios<wchar_t, char_traits<wchar_t> >;
-# endif /* _STLP_NO_WCHAR_T */
-#endif
-
-_STLP_END_NAMESPACE
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/src/iostream.cpp b/src/iostream.cpp
deleted file mode 100644
index 0d3329b..0000000
--- a/src/iostream.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <memory>
-#include <istream>
-#include <fstream>
-#if defined (_STLP_MSVC) || defined (__MWERKS__) || defined (__ICL) || defined (__ISCPP__)
-# define _STLP_USE_NOT_INIT_SEGMENT
-# include <iostream>
-#endif
-
-#include "stdio_streambuf.h"
-#include "aligned_buffer.h"
-#include "_stdio_file.h"
-#include "c_locale.h"
-
-// boris : note this is repeated in <iostream>
-#ifndef _STLP_USE_NAMESPACES
-// in case of SGI iostreams, we have to rename our streams not to clash with those
-// provided in native lib
-# define cin _STLP_cin
-# define cout _STLP_cout
-# define cerr _STLP_cerr
-# define clog _STLP_clog
-#endif
-
-_STLP_BEGIN_NAMESPACE
-
-// This file handles iostream initialization. It is inherently
-// nonportable, since the C++ language definition provides no mechanism
-// for controlling order of initialization of nonlocal objects.
-// Initialization has three parts, which must be performed in the following
-// order:
-// (1) Initialize the locale system
-// (2) Call the constructors for the eight global stream objects.
-// (3) Create streambufs for the global stream objects, and initialize
-// the stream objects by calling the init() member function.
-
-
-#if defined (_STLP_USE_NOT_INIT_SEGMENT)
-
-// Definitions of the eight global I/O objects that are declared in
-// <iostream>. For some compilers we use pragmas to put the global I/O
-// objects into an initialization segment that will not
-// be executed. We then explicitly invoke the constructors
-// with placement new in ios_base::_S_initialize()
-
-# if defined (__MWERKS__)
-# pragma suppress_init_code on
-# else
-# pragma init_seg("STLPORT_NO_INIT")
-# endif
-
-_STLP_DECLSPEC istream cin(0);
-_STLP_DECLSPEC ostream cout(0);
-_STLP_DECLSPEC ostream cerr(0);
-_STLP_DECLSPEC ostream clog(0);
-
-# ifndef _STLP_NO_WCHAR_T
-_STLP_DECLSPEC wistream wcin(0);
-_STLP_DECLSPEC wostream wcout(0);
-_STLP_DECLSPEC wostream wcerr(0);
-_STLP_DECLSPEC wostream wclog(0);
-# endif
-
-# if defined (__MWERKS__)
-# pragma suppress_init_code off
-# endif
-
-#else
-
-// Definitions of the eight global I/O objects that are declared in
-// <iostream>. Disgusting hack: we deliberately define them with the
-// wrong types so that the constructors don't get run automatically.
-// We need special tricks to make sure that these objects are struct-
-// aligned rather than byte-aligned.
-
-// This is not portable. Declaring a variable with different types in
-// two translations units is "undefined", according to the C++ standard.
-// Most compilers, however, silently accept this instead of diagnosing
-// it as an error.
-
-# ifndef __DMC__
-_STLP_DECLSPEC _Stl_aligned_buffer<istream> cin;
-_STLP_DECLSPEC _Stl_aligned_buffer<ostream> cout;
-_STLP_DECLSPEC _Stl_aligned_buffer<ostream> cerr;
-_STLP_DECLSPEC _Stl_aligned_buffer<ostream> clog;
-# else
-_Stl_aligned_buffer<istream> cin;
-_Stl_aligned_buffer<ostream> cout;
-_Stl_aligned_buffer<ostream> cerr;
-_Stl_aligned_buffer<ostream> clog;
-
-# pragma alias("?cin@std@@3V?$basic_istream@std@DV?$char_traits@std@D@1@@1@A", "?cin@std@@3T?$_Stl_aligned_buffer@std@V?$basic_istream@std@DV?$char_traits@std@D@1@@1@@1@A")
-# pragma alias("?cout@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?cout@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A")
-# pragma alias("?cerr@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?cerr@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A")
-# pragma alias("?clog@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?clog@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A")
-# endif
-
-# ifndef _STLP_NO_WCHAR_T
-
-# ifndef __DMC__
-_STLP_DECLSPEC _Stl_aligned_buffer<wistream> wcin;
-_STLP_DECLSPEC _Stl_aligned_buffer<wostream> wcout;
-_STLP_DECLSPEC _Stl_aligned_buffer<wostream> wcerr;
-_STLP_DECLSPEC _Stl_aligned_buffer<wostream> wclog;
-# else
-_Stl_aligned_buffer<wistream> wcin;
-_Stl_aligned_buffer<wostream> wcout;
-_Stl_aligned_buffer<wostream> wcerr;
-_Stl_aligned_buffer<wostream> wclog;
-
-# pragma alias("?wcin@std@@3V?$basic_istream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcin@std@@3T?$_Stl_aligned_buffer@std@V?$basic_istream@std@_YV?$char_traits@std@_Y@1@@1@@1@A")
-# pragma alias("?wcout@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcout@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A")
-# pragma alias("?wcerr@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcerr@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A")
-# pragma alias("?wclog@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wclog@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A")
-# endif
-# endif
-#endif /* STL_MSVC || __MWERKS__ */
-
-// Member functions from class ios_base and ios_base::Init
-
-long ios_base::Init::_S_count = 0;
-// by default, those are synced
-bool ios_base::_S_is_synced = true;
-
-ios_base::Init::Init() {
- if (_S_count++ == 0) {
- _Locale_init();
- ios_base::_S_initialize();
- _Filebuf_base::_S_initialize();
- }
-}
-
-ios_base::Init::~Init() {
- if (--_S_count == 0) {
- ios_base::_S_uninitialize();
- _Locale_final();
- }
-}
-
-static int _Stl_extract_open_param(FILE* f)
-{ return _FILE_fd(f); }
-
-#ifdef _STLP_REDIRECT_STDSTREAMS
-static const char* _Stl_extract_open_param(const char* name)
-{ return name; }
-#endif
-
-template <class _Tp>
-static filebuf*
-_Stl_create_filebuf(_Tp x, ios_base::openmode mode ) {
- auto_ptr<filebuf> result(new basic_filebuf<char, char_traits<char> >());
- result->open(_Stl_extract_open_param(x), mode);
-
- if (result->is_open())
- return result.release();
-
- return 0;
-}
-
-#if !defined (_STLP_NO_WCHAR_T)
-static wfilebuf*
-_Stl_create_wfilebuf(FILE* f, ios_base::openmode mode) {
- auto_ptr<wfilebuf> result(new basic_filebuf<wchar_t, char_traits<wchar_t> >());
- result->_M_open(_FILE_fd(f), mode);
-
- if (result->is_open())
- return result.release();
-
- return 0;
-}
-#endif
-
-void _STLP_CALL ios_base::_S_initialize() {
-#if !defined (_STLP_HAS_NO_NAMESPACES) && !defined (_STLP_DONT_USE_PRIV_NAMESPACE)
- using _STLP_PRIV stdio_istreambuf;
- using _STLP_PRIV stdio_ostreambuf;
-#endif
-
- auto_ptr<streambuf> cin_buf;
- auto_ptr<streambuf> cout_buf;
- auto_ptr<streambuf> cerr_buf;
- auto_ptr<streambuf> clog_buf;
-
- if (_S_is_synced)
- cin_buf.reset(new stdio_istreambuf(stdin));
- else
- cin_buf.reset(_Stl_create_filebuf(stdin, ios_base::in));
-
- if (_S_is_synced) {
-#ifdef _STLP_REDIRECT_STDSTREAMS
- cout_buf.reset(_Stl_create_filebuf("/stdout.txt", ios::out));
- cerr_buf.reset(_Stl_create_filebuf("/stderr.txt", ios::out));
- clog_buf.reset(_Stl_create_filebuf("/stdlog.txt", ios::out));
-#else
- cout_buf.reset(new stdio_ostreambuf(stdout));
- cerr_buf.reset(new stdio_ostreambuf(stderr));
- clog_buf.reset(new stdio_ostreambuf(stderr));
-#endif
- }
- else {
- cout_buf.reset(_Stl_create_filebuf(stdout, ios_base::out));
- cerr_buf.reset(_Stl_create_filebuf(stderr, ios_base::out));
- clog_buf.reset(_Stl_create_filebuf(stderr, ios_base::out));
- }
-
- istream* ptr_cin = new(&cin) istream(cin_buf.get()); cin_buf.release();
- ostream* ptr_cout = new(&cout) ostream(cout_buf.get()); cout_buf.release();
- ostream* ptr_cerr = new(&cerr) ostream(cerr_buf.get()); cerr_buf.release();
- /*ostream* ptr_clog = */ new(&clog) ostream(clog_buf.get()); clog_buf.release();
- ptr_cin->tie(ptr_cout);
- ptr_cerr->setf(ios_base::unitbuf);
-
-#ifndef _STLP_NO_WCHAR_T
- auto_ptr<wfilebuf> win(_Stl_create_wfilebuf(stdin, ios_base::in));
- auto_ptr<wfilebuf> wout(_Stl_create_wfilebuf(stdout, ios_base::out));
- auto_ptr<wfilebuf> werr(_Stl_create_wfilebuf(stderr, ios_base::out));
- auto_ptr<wfilebuf> wlog(_Stl_create_wfilebuf(stderr, ios_base::out));
-
- // Run constructors for the four wide stream objects.
- wistream* ptr_wcin = new(&wcin) wistream(win.get()); win.release();
- wostream* ptr_wcout = new(&wcout) wostream(wout.get()); wout.release();
- wostream* ptr_wcerr = new(&wcerr) wostream(werr.get()); werr.release();
- /*wostream* ptr_wclog = */ new(&wclog) wostream(wlog.get()); wlog.release();
-
- ptr_wcin->tie(ptr_wcout);
- ptr_wcerr->setf(ios_base::unitbuf);
-#endif
-}
-
-void _STLP_CALL ios_base::_S_uninitialize() {
- // Note that destroying output streambufs flushes the buffers.
- istream* ptr_cin = &cin;
- ostream* ptr_cout = &cout;
- ostream* ptr_cerr = &cerr;
- ostream* ptr_clog = &clog;
-
- // We don't want any exceptions being thrown here
- ptr_cin->exceptions(0);
- ptr_cout->exceptions(0);
- ptr_cerr->exceptions(0);
- ptr_clog->exceptions(0);
-
- delete ptr_cin->rdbuf(0);
- delete ptr_cout->rdbuf(0);
- delete ptr_cerr->rdbuf(0);
- delete ptr_clog->rdbuf(0);
-
- _Destroy(ptr_cin);
- _Destroy(ptr_cout);
- _Destroy(ptr_cerr);
- _Destroy(ptr_clog);
-
-#ifndef _STLP_NO_WCHAR_T
- wistream* ptr_wcin = &wcin;
- wostream* ptr_wcout = &wcout;
- wostream* ptr_wcerr = &wcerr;
- wostream* ptr_wclog = &wclog;
-
- // We don't want any exceptions being thrown here
- ptr_wcin->exceptions(0);
- ptr_wcout->exceptions(0);
- ptr_wcerr->exceptions(0);
- ptr_wclog->exceptions(0);
-
- delete ptr_wcin->rdbuf(0);
- delete ptr_wcout->rdbuf(0);
- delete ptr_wcerr->rdbuf(0);
- delete ptr_wclog->rdbuf(0);
-
- _Destroy(ptr_wcin);
- _Destroy(ptr_wcout);
- _Destroy(ptr_wcerr);
- _Destroy(ptr_wclog);
-#endif
-}
-
-
-bool _STLP_CALL ios_base::sync_with_stdio(bool sync) {
-# if !defined (_STLP_HAS_NO_NAMESPACES) && !defined (_STLP_DONT_USE_PRIV_NAMESPACE)
- using _STLP_PRIV stdio_istreambuf;
- using _STLP_PRIV stdio_ostreambuf;
-# endif
-
- if (sync == _S_is_synced) return sync;
-
- // if by any chance we got there before std streams initialization,
- // just set the sync flag and exit
- if (Init::_S_count == 0) {
- _S_is_synced = sync;
- return sync;
- }
-
- auto_ptr<streambuf> cin_buf;
- auto_ptr<streambuf> cout_buf;
- auto_ptr<streambuf> cerr_buf;
- auto_ptr<streambuf> clog_buf;
-
- if (sync)
- cin_buf.reset(new stdio_istreambuf(stdin));
- else
- cin_buf.reset(_Stl_create_filebuf(stdin, ios_base::in));
-
- if (sync) {
-#ifdef _STLP_REDIRECT_STDSTREAMS
- cout_buf.reset(_Stl_create_filebuf("/stdout.txt", ios::out));
- cerr_buf.reset(_Stl_create_filebuf("/stderr.txt", ios::out));
- clog_buf.reset(_Stl_create_filebuf("/stdlog.txt", ios::out));
-#else
- cout_buf.reset(new stdio_ostreambuf(stdout));
- cerr_buf.reset(new stdio_ostreambuf(stderr));
- clog_buf.reset(new stdio_ostreambuf(stderr));
-#endif
- }
- else {
- cout_buf.reset(_Stl_create_filebuf(stdout, ios_base::out));
- cerr_buf.reset(_Stl_create_filebuf(stderr, ios_base::out));
- clog_buf.reset(_Stl_create_filebuf(stderr, ios_base::out));
- }
-
- if (cin_buf.get() != 0 && cout_buf.get() != 0 && cerr_buf.get() != 0 && clog_buf.get() != 0) {
- // When streambuf passed to rdbuf is not null, rdbuf is exception safe:
- delete (&cin)->rdbuf(cin_buf.release());
- delete (&cout)->rdbuf(cout_buf.release());
- delete (&cerr)->rdbuf(cerr_buf.release());
- delete (&clog)->rdbuf(clog_buf.release());
- _S_is_synced = sync;
- }
-
- return _S_is_synced;
-}
-
-_STLP_END_NAMESPACE
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/src/istream.cpp b/src/istream.cpp
deleted file mode 100644
index 715364c..0000000
--- a/src/istream.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-# include "stlport_prefix.h"
-
-#include <istream>
-
-_STLP_BEGIN_NAMESPACE
-
-#if !defined(_STLP_NO_FORCE_INSTANTIATE)
-
-// instantiations
-# if defined (_STLP_USE_TEMPLATE_EXPORT)
-template class _STLP_CLASS_DECLSPEC _Isentry<char, char_traits<char> >;
-# endif
-
-template class _STLP_CLASS_DECLSPEC basic_iostream<char, char_traits<char> >;
-template class _STLP_CLASS_DECLSPEC basic_istream<char, char_traits<char> >;
-
-# if !defined (_STLP_NO_WCHAR_T)
-# if defined (_STLP_USE_TEMPLATE_EXPORT)
-template class _STLP_CLASS_DECLSPEC _Isentry<wchar_t, char_traits<wchar_t> >;
-# endif
-template class _STLP_CLASS_DECLSPEC basic_istream<wchar_t, char_traits<wchar_t> >;
-template class _STLP_CLASS_DECLSPEC basic_iostream<wchar_t, char_traits<wchar_t> >;
-# endif /* !_STLP_NO_WCHAR_T */
-
-#endif /* _STLP_NO_FORCE_INSTANTIATE */
-
-_STLP_END_NAMESPACE
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/src/locale.cpp b/src/locale.cpp
deleted file mode 100644
index 8d724f5..0000000
--- a/src/locale.cpp
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include <locale>
-#include <stdexcept>
-
-#include "c_locale.h"
-#include "locale_impl.h"
-
-_STLP_BEGIN_NAMESPACE
-
-#define _NAMELESS "*"
-static const char _Nameless[] = _NAMELESS;
-
-static inline bool is_C_locale_name (const char* name)
-{ return ((name[0] == 'C') && (name[1] == 0)); }
-
-locale* _Stl_get_classic_locale();
-locale* _Stl_get_global_locale();
-
-#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \
- defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
-# define locale _STLP_NO_MEM_T_NAME(loc)
-#endif
-
-locale::facet::~facet() {}
-
-#if !defined (_STLP_MEMBER_TEMPLATES) || defined (_STLP_INLINE_MEMBER_TEMPLATES)
-// members that fail to be templates
-bool locale::operator()(const string& __x,
- const string& __y) const
-{ return __locale_do_operator_call(*this, __x, __y); }
-
-# if !defined (_STLP_NO_WCHAR_T)
-bool locale::operator()(const wstring& __x,
- const wstring& __y) const
-{ return __locale_do_operator_call(*this, __x, __y); }
-# endif
-#endif
-
-void _STLP_CALL locale::_M_throw_on_null_name()
-{ _STLP_THROW(runtime_error("Invalid null locale name")); }
-
-void _STLP_CALL locale::_M_throw_on_combine_error(const string& name) {
- string what = "Unable to find facet";
- what += " in ";
- what += name.empty() ? "system" : name.c_str();
- what += " locale";
- _STLP_THROW(runtime_error(what.c_str()));
-}
-
-void _STLP_CALL locale::_M_throw_on_creation_failure(int __err_code,
- const char* name, const char* facet) {
- string what;
- switch (__err_code) {
- case _STLP_LOC_UNSUPPORTED_FACET_CATEGORY:
- what = "No platform localization support for ";
- what += facet;
- what += " facet category, unable to create facet for ";
- what += name[0] == 0 ? "system" : name;
- what += " locale";
- break;
- case _STLP_LOC_NO_PLATFORM_SUPPORT:
- what = "No platform localization support, unable to create ";
- what += name[0] == 0 ? "system" : name;
- what += " locale";
- break;
- default:
- case _STLP_LOC_UNKNOWN_NAME:
- what = "Unable to create facet ";
- what += facet;
- what += " from name '";
- what += name;
- what += "'";
- break;
- case _STLP_LOC_NO_MEMORY:
- _STLP_THROW_BAD_ALLOC;
- break;
- }
-
- _STLP_THROW(runtime_error(what.c_str()));
-}
-
-// Takes a reference to a locale::id, assign a numeric index if not already
-// affected and returns it. The returned index is always positive.
-static const locale::id& _Stl_loc_get_index(locale::id& id) {
- if (id._M_index == 0) {
-#if defined (_STLP_ATOMIC_INCREMENT) && !defined (_STLP_WIN95_LIKE)
- static _STLP_VOLATILE __stl_atomic_t _S_index = __STATIC_CAST(__stl_atomic_t, locale::id::_S_max);
- id._M_index = _STLP_ATOMIC_INCREMENT(&_S_index);
-#else
- static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER;
- _STLP_auto_lock sentry(_Index_lock);
- size_t new_index = locale::id::_S_max++;
- id._M_index = new_index;
-#endif
- }
- return id;
-}
-
-// Default constructor: create a copy of the global locale.
-locale::locale() _STLP_NOTHROW
- : _M_impl(_get_Locale_impl(_Stl_get_global_locale()->_M_impl))
-{}
-
-// Copy constructor
-locale::locale(const locale& L) _STLP_NOTHROW
- : _M_impl( _get_Locale_impl( L._M_impl ) )
-{}
-
-void locale::_M_insert(facet* f, locale::id& n) {
- if (f)
- _M_impl->insert(f, _Stl_loc_get_index(n));
-}
-
-locale::locale( _Locale_impl* impl ) :
- _M_impl( _get_Locale_impl( impl ) )
-{}
-
-// Create a locale from a name.
-locale::locale(const char* name)
- : _M_impl(0) {
- if (!name)
- _M_throw_on_null_name();
-
- if (is_C_locale_name(name)) {
- _M_impl = _get_Locale_impl( locale::classic()._M_impl );
- return;
- }
-
- _Locale_impl* impl = 0;
- _STLP_TRY {
- impl = new _Locale_impl(locale::id::_S_max, name);
-
- // Insert categories one at a time.
- _Locale_name_hint *hint = 0;
- const char* ctype_name = name;
- char ctype_buf[_Locale_MAX_SIMPLE_NAME];
- const char* numeric_name = name;
- char numeric_buf[_Locale_MAX_SIMPLE_NAME];
- const char* time_name = name;
- char time_buf[_Locale_MAX_SIMPLE_NAME];
- const char* collate_name = name;
- char collate_buf[_Locale_MAX_SIMPLE_NAME];
- const char* monetary_name = name;
- char monetary_buf[_Locale_MAX_SIMPLE_NAME];
- const char* messages_name = name;
- char messages_buf[_Locale_MAX_SIMPLE_NAME];
- hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint);
- hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint);
- hint = impl->insert_time_facets(time_name, time_buf, hint);
- hint = impl->insert_collate_facets(collate_name, collate_buf, hint);
- hint = impl->insert_monetary_facets(monetary_name, monetary_buf, hint);
- impl->insert_messages_facets(messages_name, messages_buf, hint);
-
- // Try to use a normalize locale name in order to have the == operator
- // to behave correctly:
- if (strcmp(ctype_name, numeric_name) == 0 &&
- strcmp(ctype_name, time_name) == 0 &&
- strcmp(ctype_name, collate_name) == 0 &&
- strcmp(ctype_name, monetary_name) == 0 &&
- strcmp(ctype_name, messages_name) == 0) {
- impl->name = ctype_name;
- }
- // else we keep current name.
-
- // reassign impl
- _M_impl = _get_Locale_impl( impl );
- }
- _STLP_UNWIND(delete impl);
-}
-
-static void _Stl_loc_combine_names_aux(_Locale_impl* L,
- const char* name,
- const char* ctype_name, const char* time_name, const char* numeric_name,
- const char* collate_name, const char* monetary_name, const char* messages_name,
- locale::category c) {
- // This function is only called when names has been validated so using _Locale_extract_*_name
- // can't fail.
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- L->name = string("LC_CTYPE=") + _Locale_extract_ctype_name((c & locale::ctype) ? ctype_name : name, buf, 0, &__err_code) + ";";
- L->name += string("LC_TIME=") + _Locale_extract_time_name((c & locale::time) ? time_name : name, buf, 0, &__err_code) + ";";
- L->name += string("LC_NUMERIC=") + _Locale_extract_numeric_name((c & locale::numeric) ? numeric_name : name, buf, 0, &__err_code) + ";";
- L->name += string("LC_COLLATE=") + _Locale_extract_collate_name((c & locale::collate) ? collate_name : name, buf, 0, &__err_code) + ";";
- L->name += string("LC_MONETARY=") + _Locale_extract_monetary_name((c & locale::monetary) ? monetary_name : name, buf, 0, &__err_code) + ";";
- L->name += string("LC_MESSAGES=") + _Locale_extract_messages_name((c & locale::messages) ? messages_name : name, buf, 0, &__err_code);
-}
-
-// Give L a name where all facets except those in category c
-// are taken from name1, and those in category c are taken from name2.
-static void _Stl_loc_combine_names(_Locale_impl* L,
- const char* name1, const char* name2,
- locale::category c) {
- if ((c & locale::all) == 0 || strcmp(name1, name1) == 0)
- L->name = name1;
- else if ((c & locale::all) == locale::all)
- L->name = name2;
- else {
- _Stl_loc_combine_names_aux(L, name1, name2, name2, name2, name2, name2, name2, c);
- }
-}
-
-static void _Stl_loc_combine_names(_Locale_impl* L,
- const char* name,
- const char* ctype_name, const char* time_name, const char* numeric_name,
- const char* collate_name, const char* monetary_name, const char* messages_name,
- locale::category c) {
- if ((c & locale::all) == 0 || (strcmp(name, ctype_name) == 0 &&
- strcmp(name, time_name) == 0 &&
- strcmp(name, numeric_name) == 0 &&
- strcmp(name, collate_name) == 0 &&
- strcmp(name, monetary_name) == 0 &&
- strcmp(name, messages_name) == 0))
- L->name = name;
- else if ((c & locale::all) == locale::all && strcmp(ctype_name, time_name) == 0 &&
- strcmp(ctype_name, numeric_name) == 0 &&
- strcmp(ctype_name, collate_name) == 0 &&
- strcmp(ctype_name, monetary_name) == 0 &&
- strcmp(ctype_name, messages_name) == 0)
- L->name = ctype_name;
- else {
- _Stl_loc_combine_names_aux(L, name, ctype_name, time_name, numeric_name, collate_name, monetary_name, messages_name, c);
- }
-}
-
-
-// Create a locale that's a copy of L, except that all of the facets
-// in category c are instead constructed by name.
-locale::locale(const locale& L, const char* name, locale::category c)
- : _M_impl(0) {
- if (!name)
- _M_throw_on_null_name();
-
- if (!::strcmp(_Nameless, name)) {
- _STLP_THROW(runtime_error("Invalid locale name '" _NAMELESS "'"));
- }
-
- _Locale_impl* impl = 0;
-
- _STLP_TRY {
- impl = new _Locale_impl(*L._M_impl);
-
- _Locale_name_hint *hint = 0;
- const char* ctype_name = name;
- char ctype_buf[_Locale_MAX_SIMPLE_NAME];
- const char* numeric_name = name;
- char numeric_buf[_Locale_MAX_SIMPLE_NAME];
- const char* time_name = name;
- char time_buf[_Locale_MAX_SIMPLE_NAME];
- const char* collate_name = name;
- char collate_buf[_Locale_MAX_SIMPLE_NAME];
- const char* monetary_name = name;
- char monetary_buf[_Locale_MAX_SIMPLE_NAME];
- const char* messages_name = name;
- char messages_buf[_Locale_MAX_SIMPLE_NAME];
- if (c & locale::ctype)
- hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint);
- if (c & locale::numeric)
- hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint);
- if (c & locale::time)
- hint = impl->insert_time_facets(time_name, time_buf, hint);
- if (c & locale::collate)
- hint = impl->insert_collate_facets(collate_name, collate_buf, hint);
- if (c & locale::monetary)
- hint = impl->insert_monetary_facets(monetary_name, monetary_buf,hint);
- if (c & locale::messages)
- impl->insert_messages_facets(messages_name, messages_buf, hint);
-
- _Stl_loc_combine_names(impl, L._M_impl->name.c_str(),
- ctype_name, time_name, numeric_name,
- collate_name, monetary_name, messages_name, c);
- _M_impl = _get_Locale_impl( impl );
- }
- _STLP_UNWIND(delete impl)
-}
-
-// Contruct a new locale where all facets that aren't in category c
-// come from L1, and all those that are in category c come from L2.
-locale::locale(const locale& L1, const locale& L2, category c)
- : _M_impl(0) {
- _Locale_impl* impl = new _Locale_impl(*L1._M_impl);
-
- _Locale_impl* i2 = L2._M_impl;
-
- if (L1.name() != _Nameless && L2.name() != _Nameless)
- _Stl_loc_combine_names(impl, L1._M_impl->name.c_str(), L2._M_impl->name.c_str(), c);
- else {
- impl->name = _Nameless;
- }
-
- if (c & collate) {
- impl->insert( i2, _STLP_STD::collate<char>::id);
-# ifndef _STLP_NO_WCHAR_T
- impl->insert( i2, _STLP_STD::collate<wchar_t>::id);
-# endif
- }
- if (c & ctype) {
- impl->insert( i2, _STLP_STD::ctype<char>::id);
- impl->insert( i2, _STLP_STD::codecvt<char, char, mbstate_t>::id);
-# ifndef _STLP_NO_WCHAR_T
- impl->insert( i2, _STLP_STD::ctype<wchar_t>::id);
- impl->insert( i2, _STLP_STD::codecvt<wchar_t, char, mbstate_t>::id);
-# endif
- }
- if (c & monetary) {
- impl->insert( i2, _STLP_STD::moneypunct<char, true>::id);
- impl->insert( i2, _STLP_STD::moneypunct<char, false>::id);
- impl->insert( i2, _STLP_STD::money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
- impl->insert( i2, _STLP_STD::money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
-# ifndef _STLP_NO_WCHAR_T
- impl->insert( i2, _STLP_STD::moneypunct<wchar_t, true>::id);
- impl->insert( i2, _STLP_STD::moneypunct<wchar_t, false>::id);
- impl->insert( i2, _STLP_STD::money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
- impl->insert( i2, _STLP_STD::money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
-# endif
- }
- if (c & numeric) {
- impl->insert( i2, _STLP_STD::numpunct<char>::id);
- impl->insert( i2, _STLP_STD::num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
- impl->insert( i2, _STLP_STD::num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
-# ifndef _STLP_NO_WCHAR_T
- impl->insert( i2, _STLP_STD::numpunct<wchar_t>::id);
- impl->insert( i2, _STLP_STD::num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
- impl->insert( i2, _STLP_STD::num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
-# endif
- }
- if (c & time) {
- impl->insert( i2, _STLP_STD::time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
- impl->insert( i2, _STLP_STD::time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
-# ifndef _STLP_NO_WCHAR_T
- impl->insert( i2, _STLP_STD::time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
- impl->insert( i2, _STLP_STD::time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
-# endif
- }
- if (c & messages) {
- impl->insert( i2, _STLP_STD::messages<char>::id);
-# ifndef _STLP_NO_WCHAR_T
- impl->insert( i2, _STLP_STD::messages<wchar_t>::id);
-# endif
- }
- _M_impl = _get_Locale_impl( impl );
-}
-
-// Destructor.
-locale::~locale() _STLP_NOTHROW {
- if (_M_impl)
- _release_Locale_impl(_M_impl);
-}
-
-// Assignment operator. Much like the copy constructor: just a bit of
-// pointer twiddling.
-const locale& locale::operator=(const locale& L) _STLP_NOTHROW {
- if (this->_M_impl != L._M_impl) {
- if (this->_M_impl)
- _release_Locale_impl(this->_M_impl);
- this->_M_impl = _get_Locale_impl(L._M_impl);
- }
- return *this;
-}
-
-locale::facet* locale::_M_get_facet(const locale::id& n) const {
- return n._M_index < _M_impl->size() ? _M_impl->facets_vec[n._M_index] : 0;
-}
-
-locale::facet* locale::_M_use_facet(const locale::id& n) const {
- locale::facet* f = (n._M_index < _M_impl->size() ? _M_impl->facets_vec[n._M_index] : 0);
- if (!f)
- _M_impl->_M_throw_bad_cast();
- return f;
-}
-
-string locale::name() const {
- return _M_impl->name;
-}
-
-// Compare two locales for equality.
-bool locale::operator==(const locale& L) const {
- return this->_M_impl == L._M_impl ||
- (this->name() == L.name() && this->name() != _Nameless);
-}
-
-bool locale::operator!=(const locale& L) const {
- return !(*this == L);
-}
-
-// static data members.
-
-const locale& _STLP_CALL locale::classic() {
- return *_Stl_get_classic_locale();
-}
-
-#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
-locale _STLP_CALL locale::global(const locale& L) {
-#else
-_Locale_impl* _STLP_CALL locale::global(const locale& L) {
-#endif
- locale old(_Stl_get_global_locale()->_M_impl);
- if (_Stl_get_global_locale()->_M_impl != L._M_impl) {
- _release_Locale_impl(_Stl_get_global_locale()->_M_impl);
- // this assign should be atomic, should be fixed here:
- _Stl_get_global_locale()->_M_impl = _get_Locale_impl(L._M_impl);
-
- // Set the global C locale, if appropriate.
-#if !defined(_STLP_NO_LOCALE_SUPPORT)
- if (L.name() != _Nameless)
- setlocale(LC_ALL, L.name().c_str());
-#endif
- }
-
-#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
- return old;
-#else
- return old._M_impl;
-#endif
-}
-
-#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
-const locale::category locale::none;
-const locale::category locale::collate;
-const locale::category locale::ctype;
-const locale::category locale::monetary;
-const locale::category locale::numeric;
-const locale::category locale::time;
-const locale::category locale::messages;
-const locale::category locale::all;
-#endif
-
-_STLP_END_NAMESPACE
-
diff --git a/src/locale_catalog.cpp b/src/locale_catalog.cpp
deleted file mode 100644
index 31e672e..0000000
--- a/src/locale_catalog.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <hash_map>
-#include <string>
-
-#include <locale>
-#include <istream>
-
-#include "c_locale.h"
-#include "locale_impl.h"
-#include "acquire_release.h"
-
-_STLP_BEGIN_NAMESPACE
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// Those wrappers are needed to use locale functions in __acquire_category,
-// all functions have to present the same prototype.
-
-static void* _Loc_ctype_create(const char * s, _Locale_name_hint* hint, int *__err_code)
-{ return _Locale_ctype_create(s, hint, __err_code); }
-static void* _Loc_codecvt_create(const char * s, _Locale_name_hint* hint, int *__err_code)
-{ return _Locale_codecvt_create(s, hint, __err_code); }
-static void* _Loc_numeric_create(const char * s, _Locale_name_hint* hint, int *__err_code)
-{ return _Locale_numeric_create(s, hint, __err_code); }
-static void* _Loc_time_create(const char * s, _Locale_name_hint* hint, int *__err_code)
-{ return _Locale_time_create(s, hint, __err_code); }
-static void* _Loc_collate_create(const char * s, _Locale_name_hint* hint, int *__err_code)
-{ return _Locale_collate_create(s, hint, __err_code); }
-static void* _Loc_monetary_create(const char * s, _Locale_name_hint* hint, int *__err_code)
-{ return _Locale_monetary_create(s, hint, __err_code); }
-static void* _Loc_messages_create(const char * s, _Locale_name_hint* hint, int *__err_code)
-{ return _Locale_messages_create(s, hint, __err_code); }
-
-static char const* _Loc_ctype_name(void* l, char* s)
-{ return _Locale_ctype_name((_Locale_ctype*)l, s); }
-static char const* _Loc_codecvt_name(void* l, char* s)
-{ return _Locale_codecvt_name((_Locale_codecvt*)l, s); }
-static char const* _Loc_numeric_name(void* l, char* s)
-{ return _Locale_numeric_name((_Locale_numeric*)l, s); }
-static char const* _Loc_time_name(void* l, char* s)
-{ return _Locale_time_name((_Locale_time*)l, s); }
-static char const* _Loc_collate_name(void* l, char* s)
-{ return _Locale_collate_name((_Locale_collate*)l, s); }
-static char const* _Loc_monetary_name(void* l, char* s)
-{ return _Locale_monetary_name((_Locale_monetary*)l, s); }
-static char const* _Loc_messages_name(void* l, char* s)
-{ return _Locale_messages_name((_Locale_messages*)l, s); }
-
-static const char* _Loc_ctype_default(char* p)
-{ return _Locale_ctype_default(p); }
-static const char* _Loc_numeric_default(char * p)
-{ return _Locale_numeric_default(p); }
-static const char* _Loc_time_default(char* p)
-{ return _Locale_time_default(p); }
-static const char* _Loc_collate_default(char* p)
-{ return _Locale_collate_default(p); }
-static const char* _Loc_monetary_default(char* p)
-{ return _Locale_monetary_default(p); }
-static const char* _Loc_messages_default(char* p)
-{ return _Locale_messages_default(p); }
-
-static void _Loc_ctype_destroy(void* p) {_Locale_ctype_destroy((_Locale_ctype*)p); }
-static void _Loc_codecvt_destroy(void* p) {_Locale_codecvt_destroy((_Locale_codecvt*)p); }
-static void _Loc_numeric_destroy(void* p) {_Locale_numeric_destroy((_Locale_numeric*)p); }
-static void _Loc_time_destroy(void* p) {_Locale_time_destroy((_Locale_time*)p);}
-static void _Loc_collate_destroy(void* p) {_Locale_collate_destroy((_Locale_collate*)p);}
-static void _Loc_monetary_destroy(void* p) {_Locale_monetary_destroy((_Locale_monetary*)p);}
-static void _Loc_messages_destroy(void* p) {_Locale_messages_destroy((_Locale_messages*)p);}
-
-typedef void* (*loc_create_func_t)(const char *, _Locale_name_hint*, int *__err_code);
-typedef char const* (*loc_name_func_t)(void* l, char* s);
-typedef void (*loc_destroy_func_t)(void* l);
-typedef const char* (*loc_default_name_func_t)(char* s);
-typedef char const* (*loc_extract_name_func_t)(const char*, char*, _Locale_name_hint*, int *__err_code);
-
-//----------------------------------------------------------------------
-// Acquire and release low-level category objects. The whole point of
-// this is so that we don't allocate (say) four different _Locale_ctype
-// objects for a single locale.
-
-// Global hash tables for category objects.
-typedef hash_map<string, pair<void*, size_t>, hash<string>, equal_to<string> > Category_Map;
-
-// Look up a category by name
-static Category_Map** ctype_hash() {
- static Category_Map *_S_ctype_hash = 0;
- return &_S_ctype_hash;
-}
-static Category_Map** codecvt_hash() {
- static Category_Map *_S_codecvt_hash = 0;
- return &_S_codecvt_hash;
-}
-static Category_Map** numeric_hash() {
- static Category_Map *_S_numeric_hash = 0;
- return &_S_numeric_hash;
-}
-static Category_Map** time_hash() {
- static Category_Map *_S_time_hash = 0;
- return &_S_time_hash;
-}
-static Category_Map** collate_hash() {
- static Category_Map *_S_collate_hash = 0;
- return &_S_collate_hash;
-}
-static Category_Map** monetary_hash() {
- static Category_Map *_S_monetary_hash = 0;
- return &_S_monetary_hash;
-}
-static Category_Map** messages_hash() {
- static Category_Map *_S_messages_hash;
- return &_S_messages_hash;
-}
-
-// We have a single lock for all of the hash tables. We may wish to
-// replace it with six different locks.
-/* REFERENCED */
-static _STLP_STATIC_MUTEX& category_hash_mutex() {
- static _STLP_STATIC_MUTEX lock _STLP_MUTEX_INITIALIZER;
- return lock;
-}
-
-static void*
-__acquire_category(const char* &name, char *buf, _Locale_name_hint* hint,
- loc_extract_name_func_t extract_name,
- loc_create_func_t create_obj, loc_default_name_func_t default_name,
- Category_Map ** M, int *__err_code) {
-#if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564)
- typedef Category_Map::iterator Category_iterator;
- pair<Category_iterator, bool> result;
-#else
-# if !defined(_STLP_DEBUG)
- pair<_Ht_iterator<_Slist_iterator<pair<const string,pair<void *,unsigned int> >,_Nonconst_traits<pair<const string,pair<void *,unsigned int> > > >,_NonLocalHashMapTraitsT<pair<const string,pair<void *,unsigned int> > > >, bool> result;
-# else
- pair<_DBG_iter<_NonDbg_hashtable<pair<const string,pair<void *,unsigned int> >,string,hash<string>,_HashMapTraitsT<pair<const string,pair<void *,unsigned int> > >,_Select1st<pair<const string,pair<void *,unsigned int> > >,_DbgEqual<string,equal_to<string> >,allocator<pair<const string,pair<void *,unsigned int> > > >,_DbgTraits<_NonLocalHashMapTraitsT<pair<const string,pair<void *,unsigned int> > > > >, bool> result;
-# endif
-#endif
-
- *__err_code = _STLP_LOC_UNDEFINED;
-
- // Find what name to look for. Be careful if user requests the default.
- if (name[0] == 0) {
- name = default_name(buf);
- if (name == 0 || name[0] == 0)
- name = "C";
- }
- else {
- const char* cname = extract_name(name, buf, hint, __err_code);
- if (cname == 0) {
- return 0;
- }
- name = cname;
- }
-
- Category_Map::value_type __e(name, pair<void*,size_t>((void*)0,size_t(0)));
-
- _STLP_auto_lock sentry(category_hash_mutex());
-
- if (!*M)
- *M = new Category_Map();
-
- // Look for an existing entry with that name.
- result = (*M)->insert_noresize(__e);
-
- if (result.second) {
- // There was no entry in the map already. Create the category.
- (*result.first).second.first = create_obj(name, hint, __err_code);
- if (!(*result.first).second.first) {
- (*M)->erase(result.first);
-#if defined (_STLP_LEAKS_PEDANTIC)
- if ((*M)->empty()) {
- delete *M;
- *M = 0;
- }
-#endif
- return 0;
- }
- }
-
- // Increment the reference count.
- ++((*result.first).second.second);
-
- return (*result.first).second.first;
-}
-
-static void
-__release_category(void* cat,
- loc_destroy_func_t destroy_fun,
- loc_name_func_t get_name,
- Category_Map** M) {
- Category_Map *pM = *M;
-
- if (cat && pM) {
- // Find the name of the category object.
- char buf[_Locale_MAX_SIMPLE_NAME + 1];
- char const* name = get_name(cat, buf);
-
- if (name != 0) {
- _STLP_auto_lock sentry(category_hash_mutex());
- Category_Map::iterator it = pM->find(name);
- if (it != pM->end()) {
- // Decrement the ref count. If it goes to zero, delete this category
- // from the map.
- if (--((*it).second.second) == 0) {
- void* cat1 = (*it).second.first;
- destroy_fun(cat1);
- pM->erase(it);
-#if defined (_STLP_LEAKS_PEDANTIC)
- if (pM->empty()) {
- delete pM;
- *M = 0;
- }
-#endif
- }
- }
- }
- }
-}
-
-_Locale_ctype* _STLP_CALL __acquire_ctype(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
- return __REINTERPRET_CAST(_Locale_ctype*, __acquire_category(name, buf, hint,
- _Locale_extract_ctype_name, _Loc_ctype_create, _Loc_ctype_default,
- ctype_hash(), __err_code));
-}
-_Locale_codecvt* _STLP_CALL __acquire_codecvt(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
- return __REINTERPRET_CAST(_Locale_codecvt*, __acquire_category(name, buf, hint,
- _Locale_extract_ctype_name, _Loc_codecvt_create, _Loc_ctype_default,
- codecvt_hash(), __err_code));
-}
-_Locale_numeric* _STLP_CALL __acquire_numeric(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
- return __REINTERPRET_CAST(_Locale_numeric*, __acquire_category(name, buf, hint,
- _Locale_extract_numeric_name, _Loc_numeric_create, _Loc_numeric_default,
- numeric_hash(), __err_code));
-}
-_Locale_time* _STLP_CALL __acquire_time(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
- return __REINTERPRET_CAST(_Locale_time*, __acquire_category(name, buf, hint,
- _Locale_extract_time_name, _Loc_time_create, _Loc_time_default,
- time_hash(), __err_code));
-}
-_Locale_collate* _STLP_CALL __acquire_collate(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
- return __REINTERPRET_CAST(_Locale_collate*, __acquire_category(name, buf, hint,
- _Locale_extract_collate_name, _Loc_collate_create, _Loc_collate_default,
- collate_hash(), __err_code));
-}
-_Locale_monetary* _STLP_CALL __acquire_monetary(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
- return __REINTERPRET_CAST(_Locale_monetary*, __acquire_category(name, buf, hint,
- _Locale_extract_monetary_name, _Loc_monetary_create, _Loc_monetary_default,
- monetary_hash(), __err_code));
-}
-_Locale_messages* _STLP_CALL __acquire_messages(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
- return __REINTERPRET_CAST(_Locale_messages*, __acquire_category(name, buf, hint,
- _Locale_extract_messages_name, _Loc_messages_create, _Loc_messages_default,
- messages_hash(), __err_code));
-}
-
-void _STLP_CALL __release_ctype(_Locale_ctype* cat)
-{ __release_category(cat, _Loc_ctype_destroy, _Loc_ctype_name, ctype_hash()); }
-void _STLP_CALL __release_codecvt(_Locale_codecvt* cat)
-{ __release_category(cat, _Loc_codecvt_destroy, _Loc_codecvt_name, codecvt_hash()); }
-void _STLP_CALL __release_numeric(_Locale_numeric* cat)
-{ __release_category(cat, _Loc_numeric_destroy, _Loc_numeric_name, numeric_hash()); }
-void _STLP_CALL __release_time(_Locale_time* cat)
-{ __release_category(cat, _Loc_time_destroy, _Loc_time_name, time_hash()); }
-void _STLP_CALL __release_collate(_Locale_collate* cat)
-{ __release_category(cat, _Loc_collate_destroy, _Loc_collate_name, collate_hash()); }
-void _STLP_CALL __release_monetary(_Locale_monetary* cat)
-{ __release_category(cat, _Loc_monetary_destroy, _Loc_monetary_name, monetary_hash()); }
-void _STLP_CALL __release_messages(_Locale_messages* cat)
-{ __release_category(cat, _Loc_messages_destroy, _Loc_messages_name, messages_hash()); }
-
-_STLP_MOVE_TO_STD_NAMESPACE
-_STLP_END_NAMESPACE
diff --git a/src/locale_impl.cpp b/src/locale_impl.cpp
deleted file mode 100644
index 71e0864..0000000
--- a/src/locale_impl.cpp
+++ /dev/null
@@ -1,765 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <locale>
-#include <algorithm>
-#include <typeinfo>
-
-#include "c_locale.h"
-#include "aligned_buffer.h"
-#include "acquire_release.h"
-#include "locale_impl.h"
-
-_STLP_BEGIN_NAMESPACE
-
-static const char _Nameless[] = "*";
-
-static inline bool is_C_locale_name (const char* name)
-{ return ((name[0] == 'C') && (name[1] == 0)); }
-
-locale::facet * _STLP_CALL _get_facet(locale::facet *f)
-{
- if (f != 0)
- f->_M_incr();
- return f;
-}
-
-void _STLP_CALL _release_facet(locale::facet *&f)
-{
- if ((f != 0) && (f->_M_decr() == 0)) {
- delete f;
- f = 0;
- }
-}
-
-size_t locale::id::_S_max = 27;
-
-static void _Stl_loc_assign_ids();
-
-static _Stl_aligned_buffer<_Locale_impl::Init> __Loc_init_buf;
-
-_Locale_impl::Init::Init() {
- if (_M_count()._M_incr() == 1) {
- _Locale_impl::_S_initialize();
- }
-}
-
-_Locale_impl::Init::~Init() {
- if (_M_count()._M_decr() == 0) {
- _Locale_impl::_S_uninitialize();
- }
-}
-
-_Refcount_Base& _Locale_impl::Init::_M_count() const {
- static _Refcount_Base _S_count(0);
- return _S_count;
-}
-
-_Locale_impl::_Locale_impl(const char* s)
- : _Refcount_Base(0), name(s), facets_vec() {
- facets_vec.reserve( locale::id::_S_max );
- new (&__Loc_init_buf) Init();
-}
-
-_Locale_impl::_Locale_impl( _Locale_impl const& locimpl )
- : _Refcount_Base(0), name(locimpl.name), facets_vec() {
- for_each( locimpl.facets_vec.begin(), locimpl.facets_vec.end(), _get_facet);
- facets_vec = locimpl.facets_vec;
- new (&__Loc_init_buf) Init();
-}
-
-_Locale_impl::_Locale_impl( size_t n, const char* s)
- : _Refcount_Base(0), name(s), facets_vec(n, 0) {
- new (&__Loc_init_buf) Init();
-}
-
-_Locale_impl::~_Locale_impl() {
- (&__Loc_init_buf)->~Init();
- for_each( facets_vec.begin(), facets_vec.end(), _release_facet);
-}
-
-// Initialization of the locale system. This must be called before
-// any locales are constructed. (Meaning that it must be called when
-// the I/O library itself is initialized.)
-void _STLP_CALL _Locale_impl::_S_initialize() {
- _Stl_loc_assign_ids();
- make_classic_locale();
-}
-
-// Release of the classic locale ressources. Has to be called after the last
-// locale destruction and not only after the classic locale destruction as
-// the facets can be shared between different facets.
-void _STLP_CALL _Locale_impl::_S_uninitialize() {
- //Not necessary anymore as classic facets are now 'normal' dynamically allocated
- //facets with a reference counter telling to _release_facet when the facet can be
- //deleted.
- //free_classic_locale();
-}
-
-// _Locale_impl non-inline member functions.
-void _STLP_CALL _Locale_impl::_M_throw_bad_cast() {
- _STLP_THROW(bad_cast());
-}
-
-void _Locale_impl::insert(_Locale_impl *from, const locale::id& n) {
- if (n._M_index > 0 && n._M_index < from->size()) {
- this->insert(from->facets_vec[n._M_index], n);
- }
-}
-
-locale::facet* _Locale_impl::insert(locale::facet *f, const locale::id& n) {
- if (f == 0 || n._M_index == 0)
- return 0;
-
- if (n._M_index >= facets_vec.size()) {
- facets_vec.resize(n._M_index + 1);
- }
-
- if (f != facets_vec[n._M_index])
- {
- _release_facet(facets_vec[n._M_index]);
- facets_vec[n._M_index] = _get_facet(f);
- }
-
- return f;
-}
-
-//
-// <locale> content which is dependent on the name
-//
-
-/* Six functions, one for each category. Each of them takes a
- * a name, constructs that appropriate category facets by name,
- * and inserts them into the locale. */
-_Locale_name_hint* _Locale_impl::insert_ctype_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
- if (name[0] == 0)
- name = _Locale_ctype_default(buf);
-
- if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
- _Locale_impl* i2 = locale::classic()._M_impl;
- this->insert(i2, ctype<char>::id);
- this->insert(i2, codecvt<char, char, mbstate_t>::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(i2, ctype<wchar_t>::id);
- this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id);
-#endif
- } else {
- locale::facet* ct = 0;
- locale::facet* cvt = 0;
-#ifndef _STLP_NO_WCHAR_T
- locale::facet* wct = 0;
- locale::facet* wcvt = 0;
-#endif
- int __err_code;
- _Locale_ctype *__lct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code);
- if (!__lct) {
- locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
- return hint;
- }
-
- if (hint == 0) hint = _Locale_get_ctype_hint(__lct);
-
- _STLP_TRY {
- ct = new ctype_byname<char>(__lct);
- }
- _STLP_UNWIND(_STLP_PRIV __release_ctype(__lct));
-
- _STLP_TRY {
- cvt = new codecvt_byname<char, char, mbstate_t>(name);
- }
- _STLP_UNWIND(delete ct);
-
-#ifndef _STLP_NO_WCHAR_T
- _STLP_TRY {
- _Locale_ctype *__lwct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code);
- if (!__lwct) {
- locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
- return hint;
- }
-
- _STLP_TRY {
- wct = new ctype_byname<wchar_t>(__lwct);
- }
- _STLP_UNWIND(_STLP_PRIV __release_ctype(__lwct));
-
- _Locale_codecvt *__lwcvt = _STLP_PRIV __acquire_codecvt(name, buf, hint, &__err_code);
- if (__lwcvt) {
- _STLP_TRY {
- wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(__lwcvt);
- }
- _STLP_UNWIND(_STLP_PRIV __release_codecvt(__lwcvt); delete wct);
- }
- }
- _STLP_UNWIND(delete cvt; delete ct);
-#endif
-
- this->insert(ct, ctype<char>::id);
- this->insert(cvt, codecvt<char, char, mbstate_t>::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(wct, ctype<wchar_t>::id);
- if (wcvt) this->insert(wcvt, codecvt<wchar_t, char, mbstate_t>::id);
-#endif
- }
- return hint;
-}
-
-_Locale_name_hint* _Locale_impl::insert_numeric_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
- if (name[0] == 0)
- name = _Locale_numeric_default(buf);
-
- _Locale_impl* i2 = locale::classic()._M_impl;
-
- // We first insert name independant facets taken from the classic locale instance:
- this->insert(i2,
- num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
- this->insert(i2,
- num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(i2,
- num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
- this->insert(i2,
- num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
-#endif
-
- if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
- this->insert(i2, numpunct<char>::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(i2, numpunct<wchar_t>::id);
-#endif
- }
- else {
- locale::facet* punct = 0;
-#ifndef _STLP_NO_WCHAR_T
- locale::facet* wpunct = 0;
-#endif
-
- int __err_code;
- _Locale_numeric *__lpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code);
- if (!__lpunct) {
- locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
- return hint;
- }
-
- if (hint == 0) hint = _Locale_get_numeric_hint(__lpunct);
- _STLP_TRY {
- punct = new numpunct_byname<char>(__lpunct);
- }
- _STLP_UNWIND(_STLP_PRIV __release_numeric(__lpunct));
-
-#ifndef _STLP_NO_WCHAR_T
- _Locale_numeric *__lwpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code);
- if (!__lwpunct) {
- delete punct;
- locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
- return hint;
- }
- if (__lwpunct) {
- _STLP_TRY {
- wpunct = new numpunct_byname<wchar_t>(__lwpunct);
- }
- _STLP_UNWIND(_STLP_PRIV __release_numeric(__lwpunct); delete punct);
- }
-#endif
-
- this->insert(punct, numpunct<char>::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(wpunct, numpunct<wchar_t>::id);
-#endif
- }
- return hint;
-}
-
-_Locale_name_hint* _Locale_impl::insert_time_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
- if (name[0] == 0)
- name = _Locale_time_default(buf);
-
- if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
- _Locale_impl* i2 = locale::classic()._M_impl;
- this->insert(i2,
- time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
- this->insert(i2,
- time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(i2,
- time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
- this->insert(i2,
- time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
-#endif
- } else {
- locale::facet *get = 0;
- locale::facet *put = 0;
-#ifndef _STLP_NO_WCHAR_T
- locale::facet *wget = 0;
- locale::facet *wput = 0;
-#endif
-
- int __err_code;
- _Locale_time *__time = _STLP_PRIV __acquire_time(name, buf, hint, &__err_code);
- if (!__time) {
- // time facets category is not mandatory for correct stream behavior so if platform
- // do not support it we do not generate a runtime_error exception.
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- _STLP_THROW_BAD_ALLOC;
- }
- return hint;
- }
-
- if (!hint) hint = _Locale_get_time_hint(__time);
- _STLP_TRY {
- get = new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(__time);
- put = new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(__time);
-#ifndef _STLP_NO_WCHAR_T
- wget = new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(__time);
- wput = new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(__time);
-#endif
- }
-#ifndef _STLP_NO_WCHAR_T
- _STLP_UNWIND(delete wget; delete put; delete get; _STLP_PRIV __release_time(__time));
-#else
- _STLP_UNWIND(delete get; _STLP_PRIV __release_time(__time));
-#endif
-
- _STLP_PRIV __release_time(__time);
-
- this->insert(get, time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
- this->insert(put, time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(wget, time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
- this->insert(wput, time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
-#endif
- }
- return hint;
-}
-
-_Locale_name_hint* _Locale_impl::insert_collate_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
- if (name[0] == 0)
- name = _Locale_collate_default(buf);
-
- if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
- _Locale_impl* i2 = locale::classic()._M_impl;
- this->insert(i2, collate<char>::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(i2, collate<wchar_t>::id);
-#endif
- }
- else {
- locale::facet *col = 0;
-#ifndef _STLP_NO_WCHAR_T
- locale::facet *wcol = 0;
-#endif
-
- int __err_code;
- _Locale_collate *__coll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code);
- if (!__coll) {
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- _STLP_THROW_BAD_ALLOC;
- }
- return hint;
- }
-
- if (hint == 0) hint = _Locale_get_collate_hint(__coll);
- _STLP_TRY {
- col = new collate_byname<char>(__coll);
- }
- _STLP_UNWIND(_STLP_PRIV __release_collate(__coll));
-
-#ifndef _STLP_NO_WCHAR_T
- _Locale_collate *__wcoll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code);
- if (!__wcoll) {
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- delete col;
- _STLP_THROW_BAD_ALLOC;
- }
- }
- if (__wcoll) {
- _STLP_TRY {
- wcol = new collate_byname<wchar_t>(__wcoll);
- }
- _STLP_UNWIND(_STLP_PRIV __release_collate(__wcoll); delete col);
- }
-#endif
-
- this->insert(col, collate<char>::id);
-#ifndef _STLP_NO_WCHAR_T
- if (wcol) this->insert(wcol, collate<wchar_t>::id);
-#endif
- }
- return hint;
-}
-
-_Locale_name_hint* _Locale_impl::insert_monetary_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
- if (name[0] == 0)
- name = _Locale_monetary_default(buf);
-
- _Locale_impl* i2 = locale::classic()._M_impl;
-
- // We first insert name independant facets taken from the classic locale instance:
- this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
- this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
- this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
-#endif
-
- if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
- this->insert(i2, moneypunct<char, false>::id);
- this->insert(i2, moneypunct<char, true>::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(i2, moneypunct<wchar_t, false>::id);
- this->insert(i2, moneypunct<wchar_t, true>::id);
-#endif
- }
- else {
- locale::facet *punct = 0;
- locale::facet *ipunct = 0;
-
-#ifndef _STLP_NO_WCHAR_T
- locale::facet* wpunct = 0;
- locale::facet* wipunct = 0;
-#endif
-
- int __err_code;
- _Locale_monetary *__mon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
- if (!__mon) {
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- _STLP_THROW_BAD_ALLOC;
- }
- return hint;
- }
-
- if (hint == 0) hint = _Locale_get_monetary_hint(__mon);
-
- _STLP_TRY {
- punct = new moneypunct_byname<char, false>(__mon);
- }
- _STLP_UNWIND(_STLP_PRIV __release_monetary(__mon));
-
- _Locale_monetary *__imon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
- if (!__imon) {
- delete punct;
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- _STLP_THROW_BAD_ALLOC;
- }
- return hint;
- }
-
- _STLP_TRY {
- ipunct = new moneypunct_byname<char, true>(__imon);
- }
- _STLP_UNWIND(_STLP_PRIV __release_monetary(__imon); delete punct);
-
-#ifndef _STLP_NO_WCHAR_T
- _STLP_TRY {
- _Locale_monetary *__wmon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
- if (!__wmon) {
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- _STLP_THROW_BAD_ALLOC;
- }
- }
-
- if (__wmon) {
- _STLP_TRY {
- wpunct = new moneypunct_byname<wchar_t, false>(__wmon);
- }
- _STLP_UNWIND(_STLP_PRIV __release_monetary(__wmon));
-
- _Locale_monetary *__wimon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
- if (!__wimon) {
- delete wpunct;
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- _STLP_THROW_BAD_ALLOC;
- }
- wpunct = 0;
- }
- else {
- _STLP_TRY {
- wipunct = new moneypunct_byname<wchar_t, true>(__wimon);
- }
- _STLP_UNWIND(_STLP_PRIV __release_monetary(__wimon); delete wpunct);
- }
- }
- }
- _STLP_UNWIND(delete ipunct; delete punct);
-#endif
-
- this->insert(punct, moneypunct<char, false>::id);
- this->insert(ipunct, moneypunct<char, true>::id);
-#ifndef _STLP_NO_WCHAR_T
- if (wpunct) this->insert(wpunct, moneypunct<wchar_t, false>::id);
- if (wipunct) this->insert(wipunct, moneypunct<wchar_t, true>::id);
-#endif
- }
- return hint;
-}
-
-_Locale_name_hint* _Locale_impl::insert_messages_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
- if (name[0] == 0)
- name = _Locale_messages_default(buf);
-
- if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
- _Locale_impl* i2 = locale::classic()._M_impl;
- this->insert(i2, messages<char>::id);
-#ifndef _STLP_NO_WCHAR_T
- this->insert(i2, messages<wchar_t>::id);
-#endif
- }
- else {
- locale::facet *msg = 0;
-#ifndef _STLP_NO_WCHAR_T
- locale::facet *wmsg = 0;
-#endif
-
- int __err_code;
- _Locale_messages *__msg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code);
- if (!__msg) {
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- _STLP_THROW_BAD_ALLOC;
- }
- return hint;
- }
-
- _STLP_TRY {
- msg = new messages_byname<char>(__msg);
- }
- _STLP_UNWIND(_STLP_PRIV __release_messages(__msg));
-
-#ifndef _STLP_NO_WCHAR_T
- _STLP_TRY {
- _Locale_messages *__wmsg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code);
- if (!__wmsg) {
- if (__err_code == _STLP_LOC_NO_MEMORY) {
- _STLP_THROW_BAD_ALLOC;
- }
- }
-
- if (__wmsg) {
- _STLP_TRY {
- wmsg = new messages_byname<wchar_t>(__wmsg);
- }
- _STLP_UNWIND(_STLP_PRIV __release_messages(__wmsg));
- }
- }
- _STLP_UNWIND(delete msg);
-#endif
-
- this->insert(msg, messages<char>::id);
-#ifndef _STLP_NO_WCHAR_T
- if (wmsg) this->insert(wmsg, messages<wchar_t>::id);
-#endif
- }
- return hint;
-}
-
-static void _Stl_loc_assign_ids() {
- // This assigns ids to every facet that is a member of a category,
- // and also to money_get/put, num_get/put, and time_get/put
- // instantiated using ordinary pointers as the input/output
- // iterators. (The default is [io]streambuf_iterator.)
-
- money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 8;
- money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 9;
- num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 10;
- num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 11;
- time_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 12;
- time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 13;
-
-#ifndef _STLP_NO_WCHAR_T
- money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 21;
- money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 22;
- num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 23;
- num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id._M_index = 24;
- time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 25;
- time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 26;
-#endif
- // locale::id::_S_max = 27;
-}
-
-// To access those static instance use the getter below, they guaranty
-// a correct initialization.
-static locale *_Stl_classic_locale = 0;
-static locale *_Stl_global_locale = 0;
-
-locale* _Stl_get_classic_locale() {
- static _Locale_impl::Init init;
- return _Stl_classic_locale;
-}
-
-locale* _Stl_get_global_locale() {
- static _Locale_impl::Init init;
- return _Stl_global_locale;
-}
-
-#if defined (_STLP_MSVC) || defined (__ICL) || defined (__ISCPP__) || defined (__DMC__)
-/*
- * The following static variable needs to be initialized before STLport
- * users static variable in order for him to be able to use Standard
- * streams in its variable initialization.
- * This variable is here because MSVC do not allow to change the initialization
- * segment in a given translation unit, iostream.cpp already contains an
- * initialization segment specification.
- */
-# pragma warning (disable : 4073)
-# pragma init_seg(lib)
-#endif
-
-static ios_base::Init _IosInit;
-
-void _Locale_impl::make_classic_locale() {
- // This funcion will be called once: during build classic _Locale_impl
-
- // The classic locale contains every facet that belongs to a category.
- static _Stl_aligned_buffer<_Locale_impl> _Locale_classic_impl_buf;
- _Locale_impl *classic = new(&_Locale_classic_impl_buf) _Locale_impl("C");
-
- locale::facet* classic_facets[] = {
- 0,
- new collate<char>(1),
- new ctype<char>(0, false, 1),
- new codecvt<char, char, mbstate_t>(1),
- new moneypunct<char, true>(1),
- new moneypunct<char, false>(1),
- new numpunct<char>(1),
- new messages<char>(1),
- new money_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
- new money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
- new num_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
- new num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
- new time_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
- new time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
-#ifndef _STLP_NO_WCHAR_T
- new collate<wchar_t>(1),
- new ctype<wchar_t>(1),
- new codecvt<wchar_t, char, mbstate_t>(1),
- new moneypunct<wchar_t, true>(1),
- new moneypunct<wchar_t, false>(1),
- new numpunct<wchar_t>(1),
- new messages<wchar_t>(1),
- new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
- new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
- new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
- new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
- new time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
- new time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
-#endif
- 0
- };
-
- const size_t nb_classic_facets = sizeof(classic_facets) / sizeof(locale::facet *);
- classic->facets_vec.reserve(nb_classic_facets);
- classic->facets_vec.assign(&classic_facets[0], &classic_facets[0] + nb_classic_facets);
-
- static locale _Locale_classic(classic);
- _Stl_classic_locale = &_Locale_classic;
-
- static locale _Locale_global(classic);
- _Stl_global_locale = &_Locale_global;
-}
-
-// Declarations of (non-template) facets' static data members
-// size_t locale::id::_S_max = 27; // made before
-
-locale::id collate<char>::id = { 1 };
-locale::id ctype<char>::id = { 2 };
-locale::id codecvt<char, char, mbstate_t>::id = { 3 };
-locale::id moneypunct<char, true>::id = { 4 };
-locale::id moneypunct<char, false>::id = { 5 };
-locale::id numpunct<char>::id = { 6 } ;
-locale::id messages<char>::id = { 7 };
-
-#ifndef _STLP_NO_WCHAR_T
-locale::id collate<wchar_t>::id = { 14 };
-locale::id ctype<wchar_t>::id = { 15 };
-locale::id codecvt<wchar_t, char, mbstate_t>::id = { 16 };
-locale::id moneypunct<wchar_t, true>::id = { 17 } ;
-locale::id moneypunct<wchar_t, false>::id = { 18 } ;
-locale::id numpunct<wchar_t>::id = { 19 };
-locale::id messages<wchar_t>::id = { 20 };
-#endif
-
-_STLP_DECLSPEC _Locale_impl* _STLP_CALL _get_Locale_impl(_Locale_impl *loc)
-{
- _STLP_ASSERT( loc != 0 );
- loc->_M_incr();
- return loc;
-}
-
-void _STLP_CALL _release_Locale_impl(_Locale_impl *& loc)
-{
- _STLP_ASSERT( loc != 0 );
- if (loc->_M_decr() == 0) {
- if (*loc != *_Stl_classic_locale)
- delete loc;
- else
- loc->~_Locale_impl();
- loc = 0;
- }
-}
-
-_STLP_DECLSPEC _Locale_impl* _STLP_CALL _copy_Nameless_Locale_impl(_Locale_impl *loc)
-{
- _STLP_ASSERT( loc != 0 );
- _Locale_impl *loc_new = new _Locale_impl(*loc);
- loc_new->name = _Nameless;
- return loc_new;
-}
-
-/* _GetFacetId implementation have to be here in order to be in the same translation unit
- * as where id are initialize (in _Stl_loc_assign_ids) */
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<char, istreambuf_iterator<char, char_traits<char> > >*)
-{ return money_get<char, istreambuf_iterator<char, char_traits<char> > >::id; }
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<char, ostreambuf_iterator<char, char_traits<char> > >*)
-{ return money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; }
-#ifndef _STLP_NO_WCHAR_T
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
-{ return money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
-{ return money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
-#endif
-
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<char, istreambuf_iterator<char, char_traits<char> > >*)
-{ return num_get<char, istreambuf_iterator<char, char_traits<char> > >::id; }
-#ifndef _STLP_NO_WCHAR_T
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
-{ return num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
-#endif
-
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<char, ostreambuf_iterator<char, char_traits<char> > >*)
-{ return num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; }
-#ifndef _STLP_NO_WCHAR_T
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
-{ return num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
-#endif
-
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<char, istreambuf_iterator<char, char_traits<char> > >*)
-{ return time_get<char, istreambuf_iterator<char, char_traits<char> > >::id; }
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<char, ostreambuf_iterator<char, char_traits<char> > >*)
-{ return time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; }
-#ifndef _STLP_NO_WCHAR_T
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
-{ return time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
-_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
-{ return time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
-#endif
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-_STLP_END_NAMESPACE
-
diff --git a/src/locale_impl.h b/src/locale_impl.h
deleted file mode 100644
index 2aa694c..0000000
--- a/src/locale_impl.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#ifndef LOCALE_IMPL_H
-#define LOCALE_IMPL_H
-
-#include <clocale> // C locale header file.
-#include <vector>
-#include <string>
-#include <locale>
-#include "c_locale.h"
-
-_STLP_BEGIN_NAMESPACE
-
-#if defined (_STLP_USE_TEMPLATE_EXPORT)
-//Export of _Locale_impl facets container:
-# if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
-//If we are using pointer specialization, vector<locale::facet*> will use
-//the already exported vector<void*> implementation.
-_STLP_EXPORT_TEMPLATE_CLASS allocator<locale::facet*>;
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<locale::facet**, locale::facet*, allocator<locale::facet*> >;
-_STLP_EXPORT_TEMPLATE_CLASS _Vector_base<locale::facet*, allocator<locale::facet*> >;
-
-_STLP_MOVE_TO_STD_NAMESPACE
-# endif
-# if defined (_STLP_DEBUG)
-_STLP_MOVE_TO_PRIV_NAMESPACE
-# define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector)
-_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> > >;
-_STLP_EXPORT_TEMPLATE_CLASS _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> >;
-# undef _STLP_NON_DBG_VECTOR
-_STLP_MOVE_TO_STD_NAMESPACE
-# endif
-
-_STLP_EXPORT_TEMPLATE_CLASS vector<locale::facet*, allocator<locale::facet*> >;
-#endif
-
-//----------------------------------------------------------------------
-// Class _Locale_impl
-// This is the base class which implements access only and is supposed to
-// be used for classic locale only
-class _STLP_CLASS_DECLSPEC _Locale_impl : public _Refcount_Base {
- public:
- _Locale_impl(const char* s);
- _Locale_impl(const _Locale_impl&);
- _Locale_impl(size_t n, const char* s);
-
- private:
- ~_Locale_impl();
-
- public:
- size_t size() const { return facets_vec.size(); }
-
- basic_string<char, char_traits<char>, allocator<char> > name;
-
- static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_bad_cast();
-
- private:
- void operator=(const _Locale_impl&);
-
- public:
- class _STLP_CLASS_DECLSPEC Init {
- public:
- Init();
- ~Init();
- private:
- _Refcount_Base& _M_count() const;
- };
-
- static void _STLP_CALL _S_initialize();
- static void _STLP_CALL _S_uninitialize();
-
- static void make_classic_locale();
- static void free_classic_locale();
-
- friend class Init;
-
- public:
- // void remove(size_t index);
- locale::facet* insert(locale::facet*, const locale::id& n);
- void insert(_Locale_impl* from, const locale::id& n);
-
- // Helper functions for byname construction of locales.
- _Locale_name_hint* insert_ctype_facets(const char* &name, char *buf, _Locale_name_hint* hint);
- _Locale_name_hint* insert_numeric_facets(const char* &name, char *buf, _Locale_name_hint* hint);
- _Locale_name_hint* insert_time_facets(const char* &name, char *buf, _Locale_name_hint* hint);
- _Locale_name_hint* insert_collate_facets(const char* &name, char *buf, _Locale_name_hint* hint);
- _Locale_name_hint* insert_monetary_facets(const char* &name, char *buf, _Locale_name_hint* hint);
- _Locale_name_hint* insert_messages_facets(const char* &name, char *buf, _Locale_name_hint* hint);
-
- bool operator != (const locale& __loc) const { return __loc._M_impl != this; }
-
- private:
- vector<locale::facet*> facets_vec;
-
- private:
- friend _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl * );
- friend void _STLP_CALL _release_Locale_impl( _Locale_impl *& loc );
-#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \
- defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
- friend class _STLP_NO_MEM_T_NAME(loc);
-#else
- friend class locale;
-#endif
-};
-
-void _STLP_CALL _release_Locale_impl( _Locale_impl *& loc );
-
-_STLP_END_NAMESPACE
-
-#endif
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/src/lock_free_slist.h b/src/lock_free_slist.h
deleted file mode 100644
index 7c753d1..0000000
--- a/src/lock_free_slist.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Copyright (c) 1997-1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#ifndef _STLP_LOCK_FREE_SLIST_H
-#define _STLP_LOCK_FREE_SLIST_H
-
-#if defined(_STLP_PTHREADS)
-# include <pthread.h>
-
-# if defined (__GNUC__) && defined (__i386__)
-
-# define _STLP_HAS_ATOMIC_FREELIST
-/**
- * Class that implements a non-blocking and thread-safe freelist.
- * It is used for the lock-free node allocation engine.
- *
- * @author felixw@inin.com
- */
-class _STLP_atomic_freelist {
-public:
- /**
- * Type representing items of the freelist
- */
- struct item {
- item* _M_next;
- };
-
- _STLP_atomic_freelist() {
- // Statically assert layout of member is as expected by assembly code
- _STLP_STATIC_ASSERT(sizeof(_M) == 8)
- _M._M_data._M_top = 0;
- _M._M_data._M_sequence = 0;
- }
-
- /**
- * Atomically pushes the specified item onto the freelist.
- *
- * @param __item [in] Item to add to the front of the list
- */
- void push(item* __item) {
- // NOTE: GCC uses ebx as the PIC register for globals in shared libraries.
- // The GCC version I'm using (3.4.1) won't temporarily spill it if it's
- // used as input, output, or clobber. Instead, it complains with a
- // "can't find a register in class `BREG' while reloading `asm'" error.
- // This is probably a compiler bug, but as the cmpxchg8b instruction
- // requires ebx, I work around this here by using ecx for the '__item'
- // input and spilling ebx into edi. This also precludes us from using
- // a "m" operand for the cmpxchg8b argument (GCC might think it can make
- // it relative to ebx). Instead, we're using esi for the address of _M_data.
- //
- int __tmp1; // These dummy variables are used to tell GCC that the eax, ecx,
- int __tmp2; // and edx registers will not have the same value as their input.
- int __tmp3; // The optimizer will remove them as their values are not used.
- __asm__ __volatile__
- (" movl %%ebx, %%edi\n\t"
- " movl %%ecx, %%ebx\n\t"
- "L1_%=: movl %%eax, (%%ebx)\n\t" // __item._M_next = _M._M_data._M_top
- " leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1
- "lock; cmpxchg8b (%%esi)\n\t"
- " jne L1_%=\n\t" // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
- " movl %%edi, %%ebx"
- :"=a" (__tmp1), "=d" (__tmp2), "=c" (__tmp3)
- :"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "c" (__item), "S" (&_M._M_data)
- :"edi", "memory", "cc");
- }
-
- /**
- * Atomically removes the topmost item from the freelist and returns a
- * pointer to it. Returns NULL if the list is empty.
- *
- * @return Item that was removed from front of list; NULL if list empty
- */
- item* pop() {
- item* __result;
- int __tmp;
- __asm__ __volatile__
- (" movl %%ebx, %%edi\n\t"
- "L1_%=: testl %%eax, %%eax\n\t" // _M_top == NULL?
- " je L2_%=\n\t" // If yes, we're done
- " movl (%%eax), %%ebx\n\t" // new top = _M._M_data._M_top->_M_next
- " leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1
- "lock; cmpxchg8b (%%esi)\n\t"
- " jne L1_%=\n\t" // We failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
- "L2_%=: movl %%edi, %%ebx"
- :"=a" (__result), "=d" (__tmp)
- :"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "S" (&_M._M_data)
- :"edi", "ecx", "memory", "cc");
- return __result;
- }
-
- /**
- * Atomically detaches all items from the list and returns a pointer to the
- * topmost item. The items are still chained and may be traversed safely as
- * they're now "owned" by the calling thread.
- *
- * @return Pointer to topmost item in the list; NULL if list empty
- */
- item* clear() {
- item* __result;
- int __tmp;
- __asm__ __volatile__
- (" movl %%ebx, %%edi\n\t"
- "L1_%=: testl %%eax, %%eax\n\t" // _M_top == NULL?
- " je L2_%=\n\t" // If yes, we're done
- " xorl %%ebx, %%ebx\n\t" // We're attempting to set _M_top to NULL
- " leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1
- "lock; cmpxchg8b (%%esi)\n\t"
- " jne L1_%=\n\t" // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
- "L2_%=: movl %%edi, %%ebx"
- :"=a" (__result), "=d" (__tmp)
- :"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "S" (&_M._M_data)
- :"edi", "ecx", "memory", "cc");
- return __result;
- }
-
-private:
- union {
- long long _M_align;
- struct {
- item* _M_top; // Topmost element in the freelist
- unsigned int _M_sequence; // Sequence counter to prevent "ABA problem"
- } _M_data;
- } _M;
-
- _STLP_atomic_freelist(const _STLP_atomic_freelist&);
- _STLP_atomic_freelist& operator=(const _STLP_atomic_freelist&);
-};
-
-# endif /* if defined(__GNUC__) && defined(__i386__) */
-
-#elif defined (_STLP_WIN32THREADS)
-
-# if !defined (_WIN64)
-# define _STLP_USE_ASM_IMPLEMENTATION
-# endif
-
-// Here are the compiler/platform requirements for the thread safe and
-// lock free singly linked list implementation:
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
-// For the asm version:
-# if defined (_STLP_MSVC) && defined (_M_IX86) && (_M_IX86 >= 500)
-# define _STLP_HAS_ATOMIC_FREELIST
-# endif
-# else
-// For the API based version:
-# if defined (_STLP_NEW_PLATFORM_SDK) && (!defined (WINVER) || (WINVER >= 0x0501)) && \
- (!defined (_WIN32_WINNT) || (_WIN32_WINNT >= 0x0501))
-# define _STLP_HAS_ATOMIC_FREELIST
-# endif
-# endif
-
-# if defined (_STLP_HAS_ATOMIC_FREELIST)
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
-# if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) || defined (__ICL)
-# pragma warning (push)
-# pragma warning (disable : 4035) //function has no return value
-# endif
-# endif
-/**
- * Class that implements a non-blocking and thread-safe freelist.
- * It is used for the lock-free node allocation engine.
- *
- * @author felixw@inin.com
- */
-class _STLP_atomic_freelist {
-public:
- /**
- * Type representing items of the freelist
- */
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
- struct item {
- item* _M_next;
- };
-# else
- typedef SLIST_ENTRY item;
-# endif
-
- _STLP_atomic_freelist() {
- // Statically assert layout of member is as expected by assembly code
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
- _STLP_STATIC_ASSERT((sizeof(item) == sizeof(item*)) && (sizeof(_M) == 8))
- _M._M_data._M_top = 0;
- _M._M_data._M_sequence = 0;
-# else
- InitializeSListHead(&_M_head);
-# endif
- }
-
- /**
- * Atomically pushes the specified item onto the freelist.
- *
- * @param __item [in] Item to add to the front of the list
- */
- void push(item* __item) {
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
- __asm
- {
- mov esi, this
- mov ebx, __item
- mov eax, [esi] // _M._M_data._M_top
- mov edx, [esi+4] // _M._M_data._M_sequence
- L1: mov [ebx], eax // __item._M_next = _M._M_data._M_top
- lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1
- lock cmpxchg8b qword ptr [esi]
- jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
- }
-# else
- InterlockedPushEntrySList(&_M_head, __item);
-# endif
- }
-
- /**
- * Atomically removes the topmost item from the freelist and returns a
- * pointer to it. Returns NULL if the list is empty.
- *
- * @return Item that was removed from front of list; NULL if list empty
- */
- item* pop() {
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
- __asm
- {
- mov esi, this
- mov eax, [esi] // _M._M_data._M_top
- mov edx, [esi+4] // _M._M_data._M_sequence
- L1: test eax, eax // _M_top == NULL?
- je L2 // Yes, we're done
- mov ebx, [eax] // new top = _M._M_data._M_top->_M_next
- lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1
- lock cmpxchg8b qword ptr [esi]
- jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
- L2:
- }
-# else
- return InterlockedPopEntrySList(&_M_head);
-# endif
- }
-
- /**
- * Atomically detaches all items from the list and returns pointer to the
- * topmost. The items are still chained and may be traversed safely as
- * they're now "owned" by the calling thread.
- *
- * @return Pointer to topmost item in the list; NULL if list empty
- */
- item* clear() {
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
- __asm
- {
- mov esi, this
- mov eax, [esi] // _M._M_data._M_top
- mov edx, [esi+4] // _M._M_data._M_sequence
- L1: test eax, eax // _M_top == NULL?
- je L2 // Yes, we're done
- xor ebx,ebx // We're attempting to set _M._M_data._M_top to NULL
- lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1
- lock cmpxchg8b qword ptr [esi]
- jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
- L2:
- }
-# else
- return InterlockedFlushSList(&_M_head);
-# endif
- }
-
-private:
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
- union {
- __int64 _M_align;
- struct {
- item* _M_top; // Topmost element in the freelist
- unsigned int _M_sequence; // Sequence counter to prevent "ABA problem"
- } _M_data;
- } _M;
-# else
- SLIST_HEADER _M_head;
-# endif
-
- _STLP_atomic_freelist(const _STLP_atomic_freelist&);
- _STLP_atomic_freelist& operator = (const _STLP_atomic_freelist&);
-};
-
-# if defined (_STLP_USE_ASM_IMPLEMENTATION)
-# if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) || defined (__ICL)
-# pragma warning (pop)
-# endif
-# endif
-
-# endif /* _STLP_HAS_ATOMIC_FREELIST */
-
-#endif
-
-#endif /* _STLP_LOCK_FREE_SLIST_H */
diff --git a/src/message_facets.h b/src/message_facets.h
deleted file mode 100644
index 946b529..0000000
--- a/src/message_facets.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#ifndef MESSAGE_FACETS_H
-#define MESSAGE_FACETS_H
-
-#include <string>
-#include <locale>
-#include <hash_map>
-
-#include "c_locale.h"
-
-_STLP_BEGIN_NAMESPACE
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// Class _Catalog_locale_map. The reason for this is that, internally,
-// a message string is always a char*. We need a ctype facet to convert
-// a string to and from wchar_t, and the user is permitted to provide such
-// a facet when calling open().
-
-struct _Catalog_locale_map {
- _Catalog_locale_map() : M(0) {}
- ~_Catalog_locale_map() { if (M) delete M; }
-
- void insert(nl_catd_type key, const locale& L);
- locale lookup(nl_catd_type key) const;
- void erase(nl_catd_type key);
-
- typedef hash_map<nl_catd_type, locale, hash<nl_catd_type>, equal_to<nl_catd_type>,
- allocator<pair<_STLP_CONST nl_catd_type, locale> > > map_type;
- map_type *M;
-
-private: // Invalidate copy constructor and assignment
- _Catalog_locale_map(const _Catalog_locale_map&);
- void operator=(const _Catalog_locale_map&);
-};
-
-/*
- * In glibc nl_catd type is void *, but messages_base::catalog is defined as int
- * by ISO/IEC 14882; The int may be too short to store pointer on 64-bit platforms;
- * Another problem, is that do_open() may return negative value to indicate that no
- * catalog open---this case can't be represented with pointers.
- * The class _Catalog_nl_catd_map intended to make relation between
- * messages_base::catalog and nl_catd handler.
- *
- */
-
-#if defined (_STLP_USE_GLIBC2_LOCALIZATION)
-# define _STLP_USE_NL_CATD_MAPPING
-#else
-/* If no mapping a message_base::catalog entry, int typedef according C++ Standard 22.2.7.1,
- * has to be large enough to contain a nl_catd_type value.
- */
-_STLP_STATIC_ASSERT(sizeof(nl_catd_type) <= sizeof(int))
-#endif
-
-class _STLP_CLASS_DECLSPEC _Catalog_nl_catd_map {
-public:
- _Catalog_nl_catd_map()
- {}
- ~_Catalog_nl_catd_map()
- {}
-
- typedef hash_map<messages_base::catalog, nl_catd_type, hash<messages_base::catalog>, equal_to<messages_base::catalog>,
- allocator<pair<_STLP_CONST messages_base::catalog, nl_catd_type> > > map_type;
- typedef hash_map<nl_catd_type, messages_base::catalog, hash<nl_catd_type>, equal_to<nl_catd_type>,
- allocator<pair<_STLP_CONST nl_catd_type, messages_base::catalog> > > rmap_type;
- // typedef map<messages_base::catalog,nl_catd_type> map_type;
- // typedef map<nl_catd_type,messages_base::catalog> rmap_type;
-
- messages_base::catalog insert(nl_catd_type cat)
-#if !defined (_STLP_USE_NL_CATD_MAPPING)
- { return (messages_base::catalog)cat; }
-#else
- ;
-#endif
-
- void erase(messages_base::catalog)
-#if !defined (_STLP_USE_NL_CATD_MAPPING)
- {}
-#else
- ;
-#endif
-
- nl_catd_type operator [] ( messages_base::catalog cat )
-#if !defined (_STLP_USE_NL_CATD_MAPPING)
- { return cat; }
-#else
- { return cat < 0 ? 0 : M[cat]; }
-#endif
-
-private:
- _Catalog_nl_catd_map(const _Catalog_nl_catd_map&);
- _Catalog_nl_catd_map& operator =(const _Catalog_nl_catd_map&);
-
-#if defined (_STLP_USE_NL_CATD_MAPPING)
- map_type M;
- rmap_type Mr;
- static _STLP_VOLATILE __stl_atomic_t _count;
-#endif
-};
-
-class _Messages {
-public:
- typedef messages_base::catalog catalog;
-
- _Messages(bool, const char *name);
- _Messages(bool, _Locale_messages*);
-
- catalog do_open(const string& __fn, const locale& __loc) const;
- string do_get(catalog __c, int __set, int __msgid,
- const string& __dfault) const;
-#if !defined (_STLP_NO_WCHAR_T)
- wstring do_get(catalog __c, int __set, int __msgid,
- const wstring& __dfault) const;
-#endif
- void do_close(catalog __c) const;
- ~_Messages();
-
-private:
- _Locale_messages* _M_message_obj;
- _Catalog_locale_map* _M_map;
- mutable _Catalog_nl_catd_map _M_cat;
-
- //private definition to avoid warning (with ICL)
- _Messages(const _Messages&);
- _Messages& operator=(const _Messages&);
-};
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-_STLP_END_NAMESPACE
-
-#endif
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/src/messages.cpp b/src/messages.cpp
deleted file mode 100644
index ae4669e..0000000
--- a/src/messages.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <typeinfo>
-
-#include "message_facets.h"
-#include "acquire_release.h"
-
-_STLP_BEGIN_NAMESPACE
-
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-void _Catalog_locale_map::insert(nl_catd_type key, const locale& L) {
- _STLP_TRY {
-#if !defined (_STLP_NO_TYPEINFO) && !defined (_STLP_NO_RTTI)
- // Don't bother to do anything unless we're using a non-default ctype facet
-# ifdef _STLP_NO_WCHAR_T
- typedef char _Char;
-# else
- typedef wchar_t _Char;
-# endif
-
- typedef ctype<_Char> wctype;
- wctype const& wct = use_facet<wctype>(L);
- if (typeid(wct) != typeid(wctype)) {
-#endif
- if (!M)
- M = new map_type;
-
- M->insert(map_type::value_type(key, L));
-#if !defined (_STLP_NO_TYPEINFO) && !defined (_STLP_NO_RTTI)
- }
-#endif
- }
- _STLP_CATCH_ALL {}
-}
-
-void _Catalog_locale_map::erase(nl_catd_type key) {
- if (M)
- M->erase(key);
-}
-
-locale _Catalog_locale_map::lookup(nl_catd_type key) const {
- if (M) {
- map_type::const_iterator i = M->find(key);
- return i != M->end() ? (*i).second : locale::classic();
- }
- else
- return locale::classic();
-}
-
-
-#if defined (_STLP_USE_NL_CATD_MAPPING)
-_STLP_VOLATILE __stl_atomic_t _Catalog_nl_catd_map::_count = 0;
-
-messages_base::catalog _Catalog_nl_catd_map::insert(nl_catd_type cat) {
- messages_base::catalog &res = Mr[cat];
- if ( res == 0 ) {
-#if defined (_STLP_ATOMIC_INCREMENT)
- res = __STATIC_CAST(int, _STLP_ATOMIC_INCREMENT(&_count));
-#else
- static _STLP_STATIC_MUTEX _Count_lock _STLP_MUTEX_INITIALIZER;
- {
- _STLP_auto_lock sentry(_Count_lock);
- res = __STATIC_CAST(int, ++_count);
- }
-#endif
- M[res] = cat;
- }
- return res;
-}
-
-void _Catalog_nl_catd_map::erase(messages_base::catalog cat) {
- map_type::iterator mit(M.find(cat));
- if (mit != M.end()) {
- Mr.erase((*mit).second);
- M.erase(mit);
- }
-}
-#endif
-
-//----------------------------------------------------------------------
-//
-_Messages::_Messages(bool is_wide, const char *name) :
- _M_message_obj(0), _M_map(0) {
- if (!name)
- locale::_M_throw_on_null_name();
-
- int __err_code;
- char buf[_Locale_MAX_SIMPLE_NAME];
- _M_message_obj = _STLP_PRIV __acquire_messages(name, buf, 0, &__err_code);
- if (!_M_message_obj)
- locale::_M_throw_on_creation_failure(__err_code, name, "messages");
-
- if (is_wide)
- _M_map = new _Catalog_locale_map;
-}
-
-_Messages::_Messages(bool is_wide, _Locale_messages* msg) :
- _M_message_obj(msg), _M_map(is_wide ? new _Catalog_locale_map() : 0)
-{}
-
-_Messages::~_Messages() {
- __release_messages(_M_message_obj);
- delete _M_map;
-}
-
-_Messages::catalog _Messages::do_open(const string& filename, const locale& L) const {
- nl_catd_type result = _M_message_obj ? _Locale_catopen(_M_message_obj, filename.c_str())
- : (nl_catd_type)(-1);
-
- if ( result != (nl_catd_type)(-1) ) {
- if ( _M_map != 0 ) {
- _M_map->insert(result, L);
- }
- return _STLP_MUTABLE(_Messages_impl, _M_cat).insert( result );
- }
-
- return -1;
-}
-
-string _Messages::do_get(catalog cat,
- int set, int p_id, const string& dfault) const {
- return _M_message_obj != 0 && cat >= 0
- ? string(_Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[cat],
- set, p_id, dfault.c_str()))
- : dfault;
-}
-
-#if !defined (_STLP_NO_WCHAR_T)
-
-wstring
-_Messages::do_get(catalog thecat,
- int set, int p_id, const wstring& dfault) const {
- typedef ctype<wchar_t> wctype;
- const wctype& ct = use_facet<wctype>(_M_map->lookup(_STLP_MUTABLE(_Messages_impl, _M_cat)[thecat]));
-
- const char* str = _Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat], set, p_id, "");
-
- // Verify that the lookup failed; an empty string might represent success.
- if (!str)
- return dfault;
- else if (str[0] == '\0') {
- const char* str2 = _Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat], set, p_id, "*");
- if (!str2 || ((str2[0] == '*') && (str2[1] == '\0')))
- return dfault;
- }
-
- // str is correct. Now we must widen it to get a wstring.
- size_t n = strlen(str);
-
- // NOT PORTABLE. What we're doing relies on internal details of the
- // string implementation. (Contiguity of string elements.)
- wstring result(n, wchar_t(0));
- ct.widen(str, str + n, &*result.begin());
- return result;
-}
-
-#endif
-
-void _Messages::do_close(catalog thecat) const {
- if (_M_message_obj)
- _Locale_catclose(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat]);
- if (_M_map) _M_map->erase(_STLP_MUTABLE(_Messages_impl, _M_cat)[thecat]);
- _STLP_MUTABLE(_Messages_impl, _M_cat).erase( thecat );
-}
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-//----------------------------------------------------------------------
-// messages<char>
-messages<char>::messages(size_t refs)
- : locale::facet(refs) {}
-
-messages_byname<char>::messages_byname(const char *name, size_t refs)
- : messages<char>(refs), _M_impl(new _STLP_PRIV _Messages(false, name)) {}
-
-messages_byname<char>::messages_byname(_Locale_messages* msg)
- : messages<char>(0), _M_impl(new _STLP_PRIV _Messages(false, msg)) {}
-
-messages_byname<char>::~messages_byname()
-{ delete _M_impl; }
-
-messages_byname<char>::catalog
-messages_byname<char>::do_open(const string& filename, const locale& l) const
-{ return _M_impl->do_open(filename, l); }
-
-string
-messages_byname<char>::do_get(catalog cat, int set, int p_id,
- const string& dfault) const
-{ return _M_impl->do_get(cat, set, p_id, dfault); }
-
-void messages_byname<char>::do_close(catalog cat) const
-{ _M_impl->do_close(cat); }
-
-#if !defined (_STLP_NO_WCHAR_T)
-
-//----------------------------------------------------------------------
-// messages<wchar_t>
-
-messages<wchar_t>::messages(size_t refs)
- : locale::facet(refs) {}
-
-messages_byname<wchar_t>::messages_byname(const char *name, size_t refs)
- : messages<wchar_t>(refs), _M_impl(new _STLP_PRIV _Messages(true, name)) {}
-
-messages_byname<wchar_t>::messages_byname(_Locale_messages* msg)
- : messages<wchar_t>(0), _M_impl(new _STLP_PRIV _Messages(true, msg)) {}
-
-messages_byname<wchar_t>::~messages_byname()
-{ delete _M_impl; }
-
-messages_byname<wchar_t>::catalog
-messages_byname<wchar_t>::do_open(const string& filename, const locale& L) const
-{ return _M_impl->do_open(filename, L); }
-
-wstring
-messages_byname<wchar_t>::do_get(catalog thecat,
- int set, int p_id, const wstring& dfault) const
-{ return _M_impl->do_get(thecat, set, p_id, dfault); }
-
-void messages_byname<wchar_t>::do_close(catalog cat) const
-{ _M_impl->do_close(cat); }
-
-#endif
-
-_STLP_END_NAMESPACE
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/src/monetary.cpp b/src/monetary.cpp
deleted file mode 100644
index d4a6767..0000000
--- a/src/monetary.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <locale>
-#include <istream>
-
-_STLP_BEGIN_NAMESPACE
-
-static void _Init_monetary_formats(money_base::pattern& pos_format,
- money_base::pattern& neg_format) {
- pos_format.field[0] = (char) money_base::symbol;
- pos_format.field[1] = (char) money_base::sign;
- pos_format.field[2] = (char) money_base::none;
- pos_format.field[3] = (char) money_base::value;
-
- neg_format.field[0] = (char) money_base::symbol;
- neg_format.field[1] = (char) money_base::sign;
- neg_format.field[2] = (char) money_base::none;
- neg_format.field[3] = (char) money_base::value;
-}
-
-// This is being used throughout the library
-static const char _S_empty_string[] = "";
-#ifndef _STLP_NO_WCHAR_T
-static const wchar_t _S_empty_wstring[] = L"";
-#endif
-
-//
-// moneypunct<>
-//
-
-moneypunct<char, true>::moneypunct(size_t __refs) : locale::facet(__refs)
-{ _Init_monetary_formats(_M_pos_format, _M_neg_format); }
-moneypunct<char, true>::~moneypunct() {}
-
-char moneypunct<char, true>::do_decimal_point() const {return ' ';}
-char moneypunct<char, true>::do_thousands_sep() const {return ' ';}
-string moneypunct<char, true>::do_grouping() const { return _S_empty_string; }
-string moneypunct<char, true>::do_curr_symbol() const { return _S_empty_string; }
-string moneypunct<char, true>::do_positive_sign() const { return _S_empty_string; }
-string moneypunct<char, true>::do_negative_sign() const { return _S_empty_string; }
-money_base::pattern moneypunct<char, true>::do_pos_format() const {return _M_pos_format;}
-money_base::pattern moneypunct<char, true>::do_neg_format() const {return _M_neg_format;}
-int moneypunct<char, true>::do_frac_digits() const {return 0;}
-
-moneypunct<char, false>::moneypunct(size_t __refs) : locale::facet(__refs)
-{ _Init_monetary_formats(_M_pos_format, _M_neg_format); }
-moneypunct<char, false>::~moneypunct() {}
-
-char moneypunct<char, false>::do_decimal_point() const {return ' ';}
-char moneypunct<char, false>::do_thousands_sep() const {return ' ';}
-
-string moneypunct<char, false>::do_grouping() const { return _S_empty_string; }
-string moneypunct<char, false>::do_curr_symbol() const { return _S_empty_string; }
-string moneypunct<char, false>::do_positive_sign() const { return _S_empty_string; }
-string moneypunct<char, false>::do_negative_sign() const { return _S_empty_string; }
-money_base::pattern moneypunct<char, false>::do_pos_format() const {return _M_pos_format;}
-money_base::pattern moneypunct<char, false>::do_neg_format() const {return _M_neg_format;}
-int moneypunct<char, false>::do_frac_digits() const {return 0;}
-
-#ifndef _STLP_NO_WCHAR_T
-moneypunct<wchar_t, true>::moneypunct(size_t __refs) : locale::facet(__refs)
-{ _Init_monetary_formats(_M_pos_format, _M_neg_format); }
-moneypunct<wchar_t, true>::~moneypunct() {}
-
-wchar_t moneypunct<wchar_t, true>::do_decimal_point() const {return L' ';}
-wchar_t moneypunct<wchar_t, true>::do_thousands_sep() const {return L' ';}
-string moneypunct<wchar_t, true>::do_grouping() const {return _S_empty_string;}
-
-wstring moneypunct<wchar_t, true>::do_curr_symbol() const
-{return _S_empty_wstring;}
-wstring moneypunct<wchar_t, true>::do_positive_sign() const
-{return _S_empty_wstring;}
-wstring moneypunct<wchar_t, true>::do_negative_sign() const
-{return _S_empty_wstring;}
-int moneypunct<wchar_t, true>::do_frac_digits() const {return 0;}
-money_base::pattern moneypunct<wchar_t, true>::do_pos_format() const
-{return _M_pos_format;}
-money_base::pattern moneypunct<wchar_t, true>::do_neg_format() const
-{return _M_neg_format;}
-
-moneypunct<wchar_t, false>::moneypunct(size_t __refs) : locale::facet(__refs)
-{ _Init_monetary_formats(_M_pos_format, _M_neg_format); }
-moneypunct<wchar_t, false>::~moneypunct() {}
-
-wchar_t moneypunct<wchar_t, false>::do_decimal_point() const {return L' ';}
-wchar_t moneypunct<wchar_t, false>::do_thousands_sep() const {return L' ';}
-string moneypunct<wchar_t, false>::do_grouping() const { return _S_empty_string;}
-wstring moneypunct<wchar_t, false>::do_curr_symbol() const
-{return _S_empty_wstring;}
-wstring moneypunct<wchar_t, false>::do_positive_sign() const
-{return _S_empty_wstring;}
-wstring moneypunct<wchar_t, false>::do_negative_sign() const
-{return _S_empty_wstring;}
-int moneypunct<wchar_t, false>::do_frac_digits() const {return 0;}
-
-money_base::pattern moneypunct<wchar_t, false>::do_pos_format() const
-{return _M_pos_format;}
-money_base::pattern moneypunct<wchar_t, false>::do_neg_format() const
-{return _M_neg_format;}
-
-#endif /* WCHAR_T */
-
-//
-// Instantiations
-//
-
-#if !defined (_STLP_NO_FORCE_INSTANTIATE)
-
-template class _STLP_CLASS_DECLSPEC money_get<char, istreambuf_iterator<char, char_traits<char> > >;
-template class _STLP_CLASS_DECLSPEC money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
-// template class money_put<char, char*>;
-
-# ifndef _STLP_NO_WCHAR_T
-template class _STLP_CLASS_DECLSPEC money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
-template class _STLP_CLASS_DECLSPEC money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
-// template class money_put<wchar_t, wchar_t*>;
-// template class money_get<wchar_t, const wchar_t*>;
-# endif
-
-#endif
-
-#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
-const bool moneypunct<char, true>::intl;
-const bool moneypunct<char, false>::intl;
-# ifndef _STLP_NO_WCHAR_T
-const bool moneypunct<wchar_t, true>::intl;
-const bool moneypunct<wchar_t, false>::intl;
-# endif
-#endif
-
-_STLP_END_NAMESPACE
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/src/num_get.cpp b/src/num_get.cpp
deleted file mode 100644
index 45901ac..0000000
--- a/src/num_get.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-#include "stlport_prefix.h"
-
-#include <locale>
-#include <istream>
-#include <algorithm>
-
-_STLP_BEGIN_NAMESPACE
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-// __valid_grouping compares two strings, one representing the
-// group sizes encountered when reading an integer, and the other
-// representing the valid group sizes as returned by the numpunct
-// grouping() member function. Both are interpreted right-to-left.
-// The grouping string is treated as if it were extended indefinitely
-// with its last value. For a grouping to be valid, each term in
-// the first string must be equal to the corresponding term in the
-// second, except for the last, which must be less than or equal.
-
-// boris : this takes reversed first string !
-bool _STLP_CALL
-__valid_grouping(const char * first1, const char * last1,
- const char * first2, const char * last2) {
- if (first1 == last1 || first2 == last2) return true;
-
- --last1; --last2;
-
- while (first1 != last1) {
- if (*last1 != *first2)
- return false;
- --last1;
- if (first2 != last2) ++first2;
- }
-
- return *last1 <= *first2;
-}
-
-_STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned __index) {
- static const unsigned char __val_table[128] = {
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
- };
-
- return __val_table[__index];
-}
-
-_STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms()
-{ return "+-0xX"; }
-
-// index is actually a char
-
-#if !defined (_STLP_NO_WCHAR_T)
-
-// Similar, except return the character itself instead of the numeric
-// value. Used for floating-point input.
-bool _STLP_CALL __get_fdigit(wchar_t& c, const wchar_t* digits) {
- const wchar_t* p = find(digits, digits + 10, c);
- if (p != digits + 10) {
- c = (char)('0' + (p - digits));
- return true;
- }
- else
- return false;
-}
-
-bool _STLP_CALL __get_fdigit_or_sep(wchar_t& c, wchar_t sep,
- const wchar_t * digits) {
- if (c == sep) {
- c = (char)',';
- return true;
- }
- else
- return __get_fdigit(c, digits);
-}
-
-#endif
-
-_STLP_MOVE_TO_STD_NAMESPACE
-
-#if !defined(_STLP_NO_FORCE_INSTANTIATE)
-//----------------------------------------------------------------------
-// Force instantiation of num_get<>
-template class _STLP_CLASS_DECLSPEC istreambuf_iterator<char, char_traits<char> >;
-// template class num_get<char, const char*>;
-template class num_get<char, istreambuf_iterator<char, char_traits<char> > >;
-
-# if !defined (_STLP_NO_WCHAR_T)
-template class _STLP_CLASS_DECLSPEC istreambuf_iterator<wchar_t, char_traits<wchar_t> >;
-template class num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
-// template class num_get<wchar_t, const wchar_t*>;
-# endif
-#endif
-
-_STLP_END_NAMESPACE
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/src/num_get_float.cpp b/src/num_get_float.cpp
deleted file mode 100644
index 0407604..0000000
--- a/src/num_get_float.cpp
+++ /dev/null
@@ -1,884 +0,0 @@
-/*
- * Copyright (c) 1999
- * Silicon Graphics Computer Systems, Inc.
- *
- * Copyright (c) 1999
- * Boris Fomitchev
- *
- * This material is provided "as is", with absolutely no warranty expressed
- * or implied. Any use is at your own risk.
- *
- * Permission to use or copy this software for any purpose is hereby granted
- * without fee, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- */
-
-#include "stlport_prefix.h"
-
-#include <limits>
-#include <locale>
-#include <istream>
-
-#if (defined (__GNUC__) && !defined (__sun) && !defined (__hpux)) || \
- defined (__DMC__)
-# include <stdint.h>
-#endif
-
-#if defined (__linux__) || defined (__MINGW32__) || defined (__CYGWIN__) || \
- defined (__BORLANDC__) || defined (__DMC__) || defined (__HP_aCC)
-
-# if defined (__BORLANDC__)
-typedef unsigned int uint32_t;
-typedef unsigned __int64 uint64_t;
-# endif
-
-union _ll {
- uint64_t i64;
- struct {
-# if defined (_STLP_BIG_ENDIAN)
- uint32_t hi;
- uint32_t lo;
-# elif defined (_STLP_LITTLE_ENDIAN)
- uint32_t lo;
- uint32_t hi;
-# else
-# error Unknown endianess
-# endif
- } i32;
-};
-
-# if defined (__linux__) && !defined (__ANDROID__)
-# include <ieee754.h>
-# else
-union ieee854_long_double {
- long double d;
-
- /* This is the IEEE 854 double-extended-precision format. */
- struct {
- unsigned int mantissa1:32;
- unsigned int mantissa0:32;
- unsigned int exponent:15;
- unsigned int negative:1;
- unsigned int empty:16;
- } ieee;
-};
-
-# define IEEE854_LONG_DOUBLE_BIAS 0x3fff
-# endif
-#endif
-
-_STLP_BEGIN_NAMESPACE
-_STLP_MOVE_TO_PRIV_NAMESPACE
-
-//----------------------------------------------------------------------
-// num_get
-
-// Helper functions for _M_do_get_float.
-
-#if !defined (_STLP_NO_WCHAR_T)
-void _STLP_CALL
-_Initialize_get_float( const ctype<wchar_t>& ct,
- wchar_t& Plus, wchar_t& Minus,
- wchar_t& pow_e, wchar_t& pow_E,
- wchar_t* digits) {
- char ndigits[11] = "0123456789";
- Plus = ct.widen('+');
- Minus = ct.widen('-');
- pow_e = ct.widen('e');
- pow_E = ct.widen('E');
- ct.widen(ndigits + 0, ndigits + 10, digits);
-}
-#endif /* WCHAR_T */
-
-/*
- * __string_to_double is just lifted from atof, the difference being
- * that we just use '.' for the decimal point, rather than let it
- * be taken from the current C locale, which of course is not accessible
- * to us.
- */
-#if defined (_STLP_MSVC) || defined (__BORLANDC__) || defined (__ICL)
-typedef unsigned long uint32;
-typedef unsigned __int64 uint64;
-# define ULL(x) x##Ui64
-#elif defined (__unix) || defined (__MINGW32__) || \
- (defined (__DMC__) && (__LONGLONG)) || defined (__WATCOMC__) || \
- defined (__ANDROID__)
-typedef uint32_t uint32;
-typedef uint64_t uint64;
-# define ULL(x) x##ULL
-#else
-# error There should be some unsigned 64-bit integer on the system!
-#endif
-
-// Multiplication of two 64-bit integers, giving a 128-bit result.
-// Taken from Algorithm M in Knuth section 4.3.1, with the loop
-// hand-unrolled.
-static void _Stl_mult64(const uint64 u, const uint64 v,
- uint64& high, uint64& low) {
- const uint64 low_mask = ULL(0xffffffff);
- const uint64 u0 = u & low_mask;
- const uint64 u1 = u >> 32;
- const uint64 v0 = v & low_mask;
- const uint64 v1 = v >> 32;
-
- uint64 t = u0 * v0;
- low = t & low_mask;
-
- t = u1 * v0 + (t >> 32);
- uint64 w1 = t & low_mask;
- uint64 w2 = t >> 32;
-
- uint64 x = u0 * v1 + w1;
- low += (x & low_mask) << 32;
- high = u1 * v1 + w2 + (x >> 32);
-}
-
-#if !defined (__linux__) || defined (__ANDROID__)
-
-# define bit11 ULL(0x7ff)
-# define exponent_mask (bit11 << 52)
-
-# if !defined (__GNUC__) || (__GNUC__ != 3) || (__GNUC_MINOR__ != 4) || \
- (!defined (__CYGWIN__) && !defined (__MINGW32__))
-//Generate bad code when compiled with -O2 option.
-inline
-# endif
-void _Stl_set_exponent(uint64 &val, uint64 exp)
-{ val = (val & ~exponent_mask) | ((exp & bit11) << 52); }
-
-#endif // __linux__
-
-/* Power of ten fractions for tenscale*/
-/* The constants are factored so that at most two constants
- * and two multiplies are needed. Furthermore, one of the constants
- * is represented exactly - 10**n where 1<= n <= 27.
- */
-
-static const uint64 _Stl_tenpow[80] = {
-ULL(0xa000000000000000), /* _Stl_tenpow[0]=(10**1)/(2**4) */
-ULL(0xc800000000000000), /* _Stl_tenpow[1]=(10**2)/(2**7) */
-ULL(0xfa00000000000000), /* _Stl_tenpow[2]=(10**3)/(2**10) */
-ULL(0x9c40000000000000), /* _Stl_tenpow[3]=(10**4)/(2**14) */
-ULL(0xc350000000000000), /* _Stl_tenpow[4]=(10**5)/(2**17) */
-ULL(0xf424000000000000), /* _Stl_tenpow[5]=(10**6)/(2**20) */
-ULL(0x9896800000000000), /* _Stl_tenpow[6]=(10**7)/(2**24) */
-ULL(0xbebc200000000000), /* _Stl_tenpow[7]=(10**8)/(2**27) */
-ULL(0xee6b280000000000), /* _Stl_tenpow[8]=(10**9)/(2**30) */
-ULL(0x9502f90000000000), /* _Stl_tenpow[9]=(10**10)/(2**34) */
-ULL(0xba43b74000000000), /* _Stl_tenpow[10]=(10**11)/(2**37) */
-ULL(0xe8d4a51000000000), /* _Stl_tenpow[11]=(10**12)/(2**40) */
-ULL(0x9184e72a00000000), /* _Stl_tenpow[12]=(10**13)/(2**44) */
-ULL(0xb5e620f480000000), /* _Stl_tenpow[13]=(10**14)/(2**47) */
-ULL(0xe35fa931a0000000), /* _Stl_tenpow[14]=(10**15)/(2**50) */
-ULL(0x8e1bc9bf04000000), /* _Stl_tenpow[15]=(10**16)/(2**54) */
-ULL(0xb1a2bc2ec5000000), /* _Stl_tenpow[16]=(10**17)/(2**57) */
-ULL(0xde0b6b3a76400000), /* _Stl_tenpow[17]=(10**18)/(2**60) */
-ULL(0x8ac7230489e80000), /* _Stl_tenpow[18]=(10**19)/(2**64) */
-ULL(0xad78ebc5ac620000), /* _Stl_tenpow[19]=(10**20)/(2**67) */
-ULL(0xd8d726b7177a8000), /* _Stl_tenpow[20]=(10**21)/(2**70) */
-ULL(0x878678326eac9000), /* _Stl_tenpow[21]=(10**22)/(2**74) */
-ULL(0xa968163f0a57b400), /* _Stl_tenpow[22]=(10**23)/(2**77) */
-ULL(0xd3c21bcecceda100), /* _Stl_tenpow[23]=(10**24)/(2**80) */
-ULL(0x84595161401484a0), /* _Stl_tenpow[24]=(10**25)/(2**84) */
-ULL(0xa56fa5b99019a5c8), /* _Stl_tenpow[25]=(10**26)/(2**87) */
-ULL(0xcecb8f27f4200f3a), /* _Stl_tenpow[26]=(10**27)/(2**90) */
-
-ULL(0xd0cf4b50cfe20766), /* _Stl_tenpow[27]=(10**55)/(2**183) */
-ULL(0xd2d80db02aabd62c), /* _Stl_tenpow[28]=(10**83)/(2**276) */
-ULL(0xd4e5e2cdc1d1ea96), /* _Stl_tenpow[29]=(10**111)/(2**369) */
-ULL(0xd6f8d7509292d603), /* _Stl_tenpow[30]=(10**139)/(2**462) */
-ULL(0xd910f7ff28069da4), /* _Stl_tenpow[31]=(10**167)/(2**555) */
-ULL(0xdb2e51bfe9d0696a), /* _Stl_tenpow[32]=(10**195)/(2**648) */
-ULL(0xdd50f1996b947519), /* _Stl_tenpow[33]=(10**223)/(2**741) */
-ULL(0xdf78e4b2bd342cf7), /* _Stl_tenpow[34]=(10**251)/(2**834) */
-ULL(0xe1a63853bbd26451), /* _Stl_tenpow[35]=(10**279)/(2**927) */
-ULL(0xe3d8f9e563a198e5), /* _Stl_tenpow[36]=(10**307)/(2**1020) */
-
-// /* _Stl_tenpow[36]=(10**335)/(2**) */
-// /* _Stl_tenpow[36]=(10**335)/(2**) */
-
-ULL(0xfd87b5f28300ca0e), /* _Stl_tenpow[37]=(10**-28)/(2**-93) */
-ULL(0xfb158592be068d2f), /* _Stl_tenpow[38]=(10**-56)/(2**-186) */
-ULL(0xf8a95fcf88747d94), /* _Stl_tenpow[39]=(10**-84)/(2**-279) */
-ULL(0xf64335bcf065d37d), /* _Stl_tenpow[40]=(10**-112)/(2**-372) */
-ULL(0xf3e2f893dec3f126), /* _Stl_tenpow[41]=(10**-140)/(2**-465) */
-ULL(0xf18899b1bc3f8ca2), /* _Stl_tenpow[42]=(10**-168)/(2**-558) */
-ULL(0xef340a98172aace5), /* _Stl_tenpow[43]=(10**-196)/(2**-651) */
-ULL(0xece53cec4a314ebe), /* _Stl_tenpow[44]=(10**-224)/(2**-744) */
-ULL(0xea9c227723ee8bcb), /* _Stl_tenpow[45]=(10**-252)/(2**-837) */
-ULL(0xe858ad248f5c22ca), /* _Stl_tenpow[46]=(10**-280)/(2**-930) */
-ULL(0xe61acf033d1a45df), /* _Stl_tenpow[47]=(10**-308)/(2**-1023) */
-ULL(0xe3e27a444d8d98b8), /* _Stl_tenpow[48]=(10**-336)/(2**-1116) */
-ULL(0xe1afa13afbd14d6e) /* _Stl_tenpow[49]=(10**-364)/(2**-1209) */
-};
-
-static const short _Stl_twoexp[80] = {
-4,7,10,14,17,20,24,27,30,34,37,40,44,47,50,54,57,60,64,67,70,74,77,80,84,87,90,
-183,276,369,462,555,648,741,834,927,1020,
--93,-186,-279,-372,-465,-558,-651,-744,-837,-930,-1023,-1116,-1209
-};
-
-#define TEN_1 0 /* offset to 10 ** 1 */
-#define TEN_27 26 /* offset to 10 ** 27 */
-#define TEN_M28 37 /* offset to 10 ** -28 */
-#define NUM_HI_P 11
-#define NUM_HI_N 13
-
-#define _Stl_HIBITULL (ULL(1) << 63)
-
-static void _Stl_norm_and_round(uint64& p, int& norm, uint64 prodhi, uint64 prodlo) {
- norm = 0;
- if ((prodhi & _Stl_HIBITULL) == 0) {
- /* leading bit is a zero
- * may have to normalize
- */
- if ((prodhi == ~_Stl_HIBITULL) &&
- ((prodlo >> 62) == 0x3)) { /* normalization followed by round
- * would cause carry to create
- * extra bit, so don't normalize
- */
- p = _Stl_HIBITULL;
- return;
- }
- p = (prodhi << 1) | (prodlo >> 63); /* normalize */
- norm = 1;
- prodlo <<= 1;
- }
- else {
- p = prodhi;
- }
-
- if ((prodlo & _Stl_HIBITULL) != 0) { /* first guard bit a one */
- if (((p & 0x1) != 0) ||
- prodlo != _Stl_HIBITULL ) { /* not borderline for round to even */
- /* round */
- ++p;
- if (p == 0)
- ++p;
- }
- }
-}
-
-// Convert a 64-bitb fraction * 10^exp to a 64-bit fraction * 2^bexp.
-// p: 64-bit fraction
-// exp: base-10 exponent
-// bexp: base-2 exponent (output parameter)
-static void _Stl_tenscale(uint64& p, int exp, int& bexp) {
- bexp = 0;
-
- if ( exp == 0 ) { /* no scaling needed */
- return;
- }
-
- int exp_hi = 0, exp_lo = exp; /* exp = exp_hi*32 + exp_lo */
- int tlo = TEN_1, thi; /* offsets in power of ten table */
- int num_hi; /* number of high exponent powers */
-
- if (exp > 0) { /* split exponent */
- if (exp_lo > 27) {
- exp_lo++;
- while (exp_lo > 27) {
- exp_hi++;
- exp_lo -= 28;
- }
- }
- thi = TEN_27;
- num_hi = NUM_HI_P;
- } else { // exp < 0
- while (exp_lo < 0) {
- exp_hi++;
- exp_lo += 28;
- }
- thi = TEN_M28;
- num_hi = NUM_HI_N;
- }
-
- uint64 prodhi, prodlo; /* 128b product */
- int norm; /* number of bits of normalization */
-
- int hi, lo; /* offsets in power of ten table */
- while (exp_hi) { /* scale */
- hi = (min) (exp_hi, num_hi); /* only a few large powers of 10 */
- exp_hi -= hi; /* could iterate in extreme case */
- hi += thi-1;
- _Stl_mult64(p, _Stl_tenpow[hi], prodhi, prodlo);
- _Stl_norm_and_round(p, norm, prodhi, prodlo);
- bexp += _Stl_twoexp[hi] - norm;
- }
<