Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
2000-04-22 04:33:34 +08:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 2, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this library; see the file COPYING. If not, write to the Free
|
|
|
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
// USA.
|
|
|
|
|
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
|
|
// library without restriction. Specifically, if other files instantiate
|
|
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
|
|
// this file and link it with other files to produce an executable, this
|
|
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
|
|
// the GNU General Public License. This exception does not however
|
|
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
|
|
// the GNU General Public License.
|
|
|
|
|
|
|
|
#include <bits/std_clocale.h>
|
|
|
|
#include <bits/std_cstring.h>
|
|
|
|
#include <bits/std_cassert.h>
|
|
|
|
#include <bits/std_cctype.h>
|
|
|
|
#include <bits/std_limits.h>
|
2000-10-11 07:50:39 +08:00
|
|
|
#include <exception>
|
2000-04-22 04:33:34 +08:00
|
|
|
#include <bits/std_stdexcept.h>
|
|
|
|
#include <bits/std_locale.h>
|
|
|
|
#include <bits/std_istream.h>
|
|
|
|
#include <bits/std_ostream.h>
|
|
|
|
#include <bits/std_vector.h>
|
|
|
|
#include <bits/std_memory.h> // for auto_ptr
|
2000-06-13 10:13:54 +08:00
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
[multiple changes]
2000-10-02 Steven King <sxking@uswest.net>
* mkcshadow: Fixed script to output proper include guard.
* bits/char_traits.h: Cleaned up types in char_traits<char> functions.
* libio/_G_config.h: Hacked to make work with shadow heraders.
* shadow/*: Hacked to make shadow headers work.
2000-10-02 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
Self-compile with shadow headers.
* acconfig.h (_GLIBCPP_USE_SHADOW_HEADERS): Define. Eventually,
like _GLIBCPP_USE_NAMESPACES before it, this macro will die when
it becomes the default way the library is built.
* acinclude.m4 (GLIBCPP_ENABLE_SHADOW): New macro.
* config/gnu-linux/bits/ctype_base.h (ctype_base): Use it.
* config/gnu-linux/ctype.cc (ctype): Use it.
* src/localename.cc (locale::_Impl::_M_replace_categories): Remove
call to assert.
* src/locale.cc: Explicitly cast mbstate_t to void* in calls to
memset. This should not be necessary, but an ambiguous overload
with it in.
* shadow/bits/std_cwchar.h: Fix.
* shadow/wchar.h: Fix.
* config/gnu-linux/bits/ctype_base.h (ctype_base): Inject ctype
enums into namespace std:: for ctype_base enum. Other OS types
will have to do this as well.
* config/gnu-linux/ctype.cc (ctype): Inject ctype data into
namespace std, in particular __ctype_toupper, __ctype_tolower,
__ctype_b.
* shadow/iolibio.h: New file.
* shadow/bits/wrap_iolibio.h: New file.
* shadow/libioP.h: New file.
* shadow/bits/wrap_libioP.h: New file.
* shadow/bits/wrap_fcntl.h: New file.
* shadow/fcntl.h: New file.
* shadow/iconv.h: New file. Inject iconv names into the global
namespace, unmangled for the moment.
* shadow/bits/wrap_iconv.h: New file.
* shadow/unistd.h: Remove. Useless.
* shadow/bits/wrap_unistd.h: Remove.
* src/Makefile.am: Take out machine-ansi.h, add fcntl.h unistd.h.
* src/Makefile.in: Regenerate.
* config/c_io_libio.h (_IO_codecvt): Change to normal C++ decl.
* shadow/libio.h: Fix.
* shadow/bits/wrap_libio.h: Fix.
* shadow/bits/std_clocale.h: Remove typedef struct construct,
which will not compile.
* shadow/bits/std_ctime.h: Same.
* shadow/pthread.h: New file. Put pthreads types and functions
into global scope, which is probably not the correct long-term
solution but has to be done at the moment before libio wrappers
can even be started.
* shadow/bits/wrap_pthread.h: New file.
* bits/std_ios.h: Formatting tweak.
* shadow/bits/std_cstdio.h: Format. Remove extraneous bits.
* acinclude.m4 (GLIBCPP_CHECK_COMPILER_FEATURES): Add -Werror to
tests for compiler features.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* config/c_io_libio.cc: Remove fcntl.h include, as SEEK_SET
redefined.
* libio/libioP.h: Comment out fcntl.h include.
* shadow/math.h: Add in float and long declarations, as per ISO C9X.
* bits/c++config: Define _ISOC99_SOURCE.
* acinclude.m4 (GLIBCPP_ENABLE_SHADOW): Add -fno-builtins to
CSHADOWFLAGS, as well as _ISOC99_SOURCE.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* src/Makefile.am (CSHADOW_INCLUDES): Enable, again.
(CSHADOW_INCLUDES): Add -I$(top_srcdir)/std before shadow include dir.
(CXXCOMPILE): Remove $(DEFS), which searches $(top_srcdir) before
std or shadow directories.
(LTCXXCOMPILE): Same.
(INCLUDES): Add $(top_builddir) before $(top_srcdir).
(AC_CXXFLAGS): Add CSHADOWFLAGS.
* src/Makefile.in: Regenerate.
* src/complex.cc (FCT): Change ::name to name.
* src/complexl.cc (FCT): Same. Use _GLIBCPP_USE_LONG_LONG here.
* src/complexf.cc (FCT): Same.
* src/complexf.cc: Remove FCT define, as things are properly
overloaded in the std namespace with the shadow headers.
* src/complexl.cc: Same.
* src/complex.cc: Same.
From-SVN: r36707
2000-10-04 13:06:32 +08:00
|
|
|
# include <bits/std_cwctype.h> // for towupper, etc.
|
2000-06-13 10:13:54 +08:00
|
|
|
#endif
|
2000-09-15 15:06:46 +08:00
|
|
|
|
2000-12-22 19:03:33 +08:00
|
|
|
namespace std
|
|
|
|
{
|
2000-09-01 16:58:07 +08:00
|
|
|
// Definitions for static const data members of locale.
|
2000-09-15 03:44:03 +08:00
|
|
|
const locale::category locale::none;
|
|
|
|
const locale::category locale::ctype;
|
|
|
|
const locale::category locale::numeric;
|
2000-12-22 19:03:33 +08:00
|
|
|
const locale::category locale::collate;
|
2000-09-15 03:44:03 +08:00
|
|
|
const locale::category locale::time;
|
2000-12-22 19:03:33 +08:00
|
|
|
const locale::category locale::monetary;
|
2000-09-15 03:44:03 +08:00
|
|
|
const locale::category locale::messages;
|
|
|
|
const locale::category locale::all;
|
|
|
|
|
|
|
|
locale::_Impl* locale::_S_classic;
|
2000-11-02 16:05:16 +08:00
|
|
|
locale::_Impl* locale::_S_global;
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
const size_t locale::_S_num_categories;
|
|
|
|
const size_t locale::_S_num_facets;
|
2000-09-01 16:58:07 +08:00
|
|
|
|
2000-12-22 19:03:33 +08:00
|
|
|
// Definitions for locale::id of standard facets.
|
|
|
|
locale::id ctype<char>::id;
|
|
|
|
locale::id codecvt<char, char, mbstate_t>::id;
|
|
|
|
|
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
|
|
|
locale::id ctype<wchar_t>::id;
|
|
|
|
locale::id codecvt<wchar_t, char, mbstate_t>::id;
|
2000-09-01 16:58:07 +08:00
|
|
|
#endif
|
2000-12-22 19:03:33 +08:00
|
|
|
|
|
|
|
// Definitions for static const data members of locale::id
|
|
|
|
size_t locale::id::_S_highwater; // init'd to 0 by linker
|
|
|
|
|
|
|
|
// Definitions for static const data members of locale::_Impl
|
2000-09-01 16:58:07 +08:00
|
|
|
const locale::id* const
|
|
|
|
locale::_Impl::_S_id_ctype[] =
|
|
|
|
{
|
|
|
|
&std::ctype<char>::id,
|
2000-10-20 14:52:00 +08:00
|
|
|
&codecvt<char, char, mbstate_t>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2000-12-22 19:03:33 +08:00
|
|
|
&std::ctype<wchar_t>::id,
|
2000-10-20 14:52:00 +08:00
|
|
|
&codecvt<wchar_t, char, mbstate_t>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#endif
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
const locale::id* const
|
2000-12-22 19:03:33 +08:00
|
|
|
locale::_Impl::_S_id_numeric[] =
|
2000-09-01 16:58:07 +08:00
|
|
|
{
|
2000-12-22 19:03:33 +08:00
|
|
|
&num_get<char>::id,
|
|
|
|
&num_put<char>::id,
|
|
|
|
&numpunct<char>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2000-12-22 19:03:33 +08:00
|
|
|
&num_get<wchar_t>::id,
|
|
|
|
&num_put<wchar_t>::id,
|
|
|
|
&numpunct<wchar_t>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#endif
|
|
|
|
0
|
|
|
|
};
|
2000-12-22 19:03:33 +08:00
|
|
|
|
2000-09-01 16:58:07 +08:00
|
|
|
const locale::id* const
|
2000-12-22 19:03:33 +08:00
|
|
|
locale::_Impl::_S_id_collate[] =
|
2000-09-01 16:58:07 +08:00
|
|
|
{
|
2000-12-22 19:03:33 +08:00
|
|
|
&std::collate<char>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2000-12-22 19:03:33 +08:00
|
|
|
&std::collate<wchar_t>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#endif
|
|
|
|
0
|
|
|
|
};
|
2000-12-22 19:03:33 +08:00
|
|
|
|
2000-09-01 16:58:07 +08:00
|
|
|
const locale::id* const
|
|
|
|
locale::_Impl::_S_id_time[] =
|
|
|
|
{
|
2000-10-20 14:52:00 +08:00
|
|
|
&time_get<char>::id,
|
|
|
|
&time_put<char>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2000-12-22 19:03:33 +08:00
|
|
|
&time_get<wchar_t>::id,
|
2000-10-20 14:52:00 +08:00
|
|
|
&time_put<wchar_t>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#endif
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
const locale::id* const
|
2000-12-22 19:03:33 +08:00
|
|
|
locale::_Impl::_S_id_monetary[] =
|
2000-09-01 16:58:07 +08:00
|
|
|
{
|
2000-12-22 19:03:33 +08:00
|
|
|
&money_get<char>::id,
|
|
|
|
&money_put<char>::id,
|
|
|
|
&moneypunct<char, false>::id,
|
|
|
|
&moneypunct<char, true >::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2000-12-22 19:03:33 +08:00
|
|
|
&money_get<wchar_t>::id,
|
|
|
|
&money_put<wchar_t>::id,
|
|
|
|
&moneypunct<wchar_t, false>::id,
|
|
|
|
&moneypunct<wchar_t, true >::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#endif
|
2000-12-22 19:03:33 +08:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
const locale::id* const
|
|
|
|
locale::_Impl::_S_id_messages[] =
|
|
|
|
{
|
|
|
|
&std::messages<char>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2000-12-22 19:03:33 +08:00
|
|
|
&std::messages<wchar_t>::id,
|
2000-09-01 16:58:07 +08:00
|
|
|
#endif
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
const locale::id* const* const
|
|
|
|
locale::_Impl::_S_facet_categories[] =
|
|
|
|
{
|
2000-10-20 14:52:00 +08:00
|
|
|
// Order must match the decl order in class locale.
|
2000-09-01 16:58:07 +08:00
|
|
|
locale::_Impl::_S_id_ctype,
|
|
|
|
locale::_Impl::_S_id_numeric,
|
2000-12-22 19:03:33 +08:00
|
|
|
locale::_Impl::_S_id_collate,
|
2000-09-01 16:58:07 +08:00
|
|
|
locale::_Impl::_S_id_time,
|
2000-12-22 19:03:33 +08:00
|
|
|
locale::_Impl::_S_id_monetary,
|
2000-09-01 16:58:07 +08:00
|
|
|
locale::_Impl::_S_id_messages,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
// Construct and return valid pattern consisting of some combination of:
|
|
|
|
// space none symbol sign value
|
|
|
|
money_base::pattern
|
|
|
|
money_base::_S_construct_pattern(char __preceeds, char __space, char __posn)
|
|
|
|
{
|
|
|
|
pattern __ret;
|
|
|
|
|
|
|
|
// This insanely complicated routine attempts to construct a valid
|
|
|
|
// pattern for use with monyepunct. A couple of invariants:
|
|
|
|
|
|
|
|
// if (__preceeds) symbol -> value
|
|
|
|
// else value -> symbol
|
|
|
|
|
|
|
|
// if (__space) space
|
|
|
|
// else none
|
|
|
|
|
|
|
|
// none == never first
|
|
|
|
// space never first or last
|
|
|
|
|
|
|
|
// Any elegant implementations of this are welcome.
|
|
|
|
switch (__posn)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
// 1 The sign precedes the value and symbol.
|
|
|
|
if (__space)
|
|
|
|
{
|
|
|
|
// Pattern starts with sign.
|
|
|
|
if (__preceeds)
|
|
|
|
{
|
|
|
|
__ret.field[1] = symbol;
|
|
|
|
__ret.field[2] = space;
|
|
|
|
__ret.field[3] = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__ret.field[1] = value;
|
|
|
|
__ret.field[2] = space;
|
|
|
|
__ret.field[3] = symbol;
|
|
|
|
}
|
|
|
|
__ret.field[0] = sign;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Pattern starts with sign and ends with none.
|
|
|
|
if (__preceeds)
|
|
|
|
{
|
|
|
|
__ret.field[1] = symbol;
|
|
|
|
__ret.field[2] = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__ret.field[1] = value;
|
|
|
|
__ret.field[2] = symbol;
|
|
|
|
}
|
|
|
|
__ret.field[0] = sign;
|
|
|
|
__ret.field[3] = none;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// 2 The sign follows the value and symbol.
|
|
|
|
if (__space)
|
|
|
|
{
|
|
|
|
// Pattern either ends with sign.
|
|
|
|
if (__preceeds)
|
|
|
|
{
|
|
|
|
__ret.field[0] = symbol;
|
|
|
|
__ret.field[1] = space;
|
|
|
|
__ret.field[2] = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__ret.field[0] = value;
|
|
|
|
__ret.field[1] = space;
|
|
|
|
__ret.field[2] = symbol;
|
|
|
|
}
|
|
|
|
__ret.field[3] = sign;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Pattern ends with sign then none.
|
|
|
|
if (__preceeds)
|
|
|
|
{
|
|
|
|
__ret.field[0] = symbol;
|
|
|
|
__ret.field[1] = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__ret.field[0] = value;
|
|
|
|
__ret.field[1] = symbol;
|
|
|
|
}
|
|
|
|
__ret.field[2] = sign;
|
|
|
|
__ret.field[3] = none;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// 3 The sign immediately precedes the symbol.
|
|
|
|
if (__space)
|
|
|
|
{
|
|
|
|
// Have space.
|
|
|
|
if (__preceeds)
|
|
|
|
{
|
|
|
|
__ret.field[0] = sign;
|
|
|
|
__ret.field[1] = symbol;
|
|
|
|
__ret.field[2] = space;
|
|
|
|
__ret.field[3] = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__ret.field[0] = value;
|
|
|
|
__ret.field[1] = space;
|
|
|
|
__ret.field[2] = sign;
|
|
|
|
__ret.field[3] = symbol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Have none.
|
|
|
|
if (__preceeds)
|
|
|
|
{
|
|
|
|
__ret.field[0] = sign;
|
|
|
|
__ret.field[1] = symbol;
|
|
|
|
__ret.field[2] = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__ret.field[0] = value;
|
|
|
|
__ret.field[1] = sign;
|
|
|
|
__ret.field[2] = symbol;
|
|
|
|
}
|
|
|
|
__ret.field[3] = none;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
// 4 The sign immediately follows the symbol.
|
|
|
|
if (__space)
|
|
|
|
{
|
|
|
|
// Have space.
|
|
|
|
if (__preceeds)
|
|
|
|
{
|
|
|
|
__ret.field[0] = symbol;
|
|
|
|
__ret.field[1] = sign;
|
|
|
|
__ret.field[2] = space;
|
|
|
|
__ret.field[3] = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__ret.field[0] = value;
|
|
|
|
__ret.field[1] = space;
|
|
|
|
__ret.field[2] = symbol;
|
|
|
|
__ret.field[3] = sign;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Have none.
|
|
|
|
if (__preceeds)
|
|
|
|
{
|
|
|
|
__ret.field[0] = symbol;
|
|
|
|
__ret.field[1] = sign;
|
|
|
|
__ret.field[2] = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__ret.field[0] = value;
|
|
|
|
__ret.field[1] = symbol;
|
|
|
|
__ret.field[2] = sign;
|
|
|
|
}
|
|
|
|
__ret.field[3] = none;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
locale::~locale() throw()
|
|
|
|
{ _M_impl->_M_remove_reference(); }
|
|
|
|
|
|
|
|
void
|
|
|
|
locale::_M_coalesce(const locale& __base, const locale& __add,
|
|
|
|
category __cat)
|
|
|
|
{
|
|
|
|
__cat = _S_normalize_category(__cat);
|
|
|
|
_M_impl = new _Impl(*__base._M_impl, 1);
|
|
|
|
|
|
|
|
try
|
|
|
|
{ _M_impl->_M_replace_categories(__add._M_impl, __cat); }
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
_M_impl->_M_remove_reference();
|
2001-02-16 08:44:44 +08:00
|
|
|
__throw_exception_again;
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
locale::locale() throw()
|
|
|
|
{
|
|
|
|
_S_initialize();
|
|
|
|
(_M_impl = _S_global)->_M_add_reference();
|
|
|
|
} // XXX MT
|
|
|
|
|
|
|
|
locale::locale(const locale& __other) throw()
|
|
|
|
{ (_M_impl = __other._M_impl)->_M_add_reference(); }
|
|
|
|
|
|
|
|
locale::locale(_Impl* __ip) throw()
|
|
|
|
: _M_impl(__ip)
|
|
|
|
{ __ip->_M_add_reference(); }
|
|
|
|
|
|
|
|
locale::locale(const char* __s)
|
|
|
|
{
|
|
|
|
if (__s)
|
|
|
|
{
|
|
|
|
if (strcmp(__s, "C") == 0 || strcmp(__s, "POSIX") == 0)
|
|
|
|
(_M_impl = _S_classic)->_M_add_reference();
|
|
|
|
else
|
|
|
|
_M_impl = new _Impl(__s, 1);
|
|
|
|
}
|
|
|
|
else
|
2001-02-16 08:44:44 +08:00
|
|
|
__throw_runtime_error("attempt to create locale from NULL name");
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
locale::locale(const locale& __base, const char* __s, category __cat)
|
|
|
|
{
|
|
|
|
// NB: There are complicated, yet more efficient ways to do
|
|
|
|
// this. Building up locales on a per-category way is tedious, so
|
|
|
|
// let's do it this way until people complain.
|
|
|
|
locale __add(__s);
|
|
|
|
_M_coalesce(__base, __add, __cat);
|
|
|
|
}
|
|
|
|
|
|
|
|
locale::locale(const locale& __base, const locale& __add, category __cat)
|
|
|
|
{ _M_coalesce(__base, __add, __cat); }
|
|
|
|
|
|
|
|
bool
|
|
|
|
locale::operator==(const locale& __rhs) const throw()
|
|
|
|
{
|
|
|
|
string __name = this->name();
|
|
|
|
return (_M_impl == __rhs._M_impl
|
|
|
|
|| (__name != "*" && __name == __rhs.name()));
|
|
|
|
}
|
|
|
|
|
|
|
|
const locale&
|
|
|
|
locale::operator=(const locale& __other) throw()
|
|
|
|
{
|
|
|
|
__other._M_impl->_M_add_reference();
|
|
|
|
_M_impl->_M_remove_reference();
|
|
|
|
_M_impl = __other._M_impl;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
locale
|
|
|
|
locale::global(const locale& __other)
|
|
|
|
{
|
|
|
|
// XXX MT
|
|
|
|
_S_initialize();
|
|
|
|
locale __old(_S_global);
|
|
|
|
__other._M_impl->_M_add_reference();
|
|
|
|
_S_global->_M_remove_reference();
|
|
|
|
_S_global = __other._M_impl;
|
|
|
|
if (_S_global->_M_check_same_name() && _S_global->_M_names[0] != "*")
|
|
|
|
setlocale(LC_ALL, __other.name().c_str());
|
|
|
|
return __old;
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
locale::name() const
|
|
|
|
{
|
|
|
|
string __ret;
|
|
|
|
// Need some kind of separator character. This one was pretty much
|
|
|
|
// arbitrarily chosen as to not conflict with glibc locales: the
|
|
|
|
// exact formatting is not set in stone.
|
|
|
|
const char __separator = '|';
|
|
|
|
|
|
|
|
if (_M_impl->_M_check_same_name())
|
|
|
|
__ret = _M_impl->_M_names[0];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < _S_num_categories; ++i)
|
|
|
|
__ret += __separator + _M_impl->_M_names[i];
|
|
|
|
}
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
locale const&
|
|
|
|
locale::classic()
|
|
|
|
{
|
|
|
|
static locale* __classic_locale;
|
|
|
|
// XXX MT
|
|
|
|
if (!_S_classic)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// 26 Standard facets, 2 references.
|
|
|
|
// One reference for _M_classic, one for _M_global
|
|
|
|
_S_classic = new _Impl("C", 2);
|
|
|
|
_S_global = _S_classic;
|
|
|
|
|
|
|
|
// Finesse static init order hassles
|
|
|
|
__classic_locale = new locale(_S_classic);
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
delete __classic_locale;
|
|
|
|
if (_S_classic)
|
|
|
|
{
|
|
|
|
_S_classic->_M_remove_reference();
|
|
|
|
_S_global->_M_remove_reference();
|
|
|
|
}
|
|
|
|
_S_classic = _S_global = 0;
|
|
|
|
// XXX MT
|
2001-02-16 08:44:44 +08:00
|
|
|
__throw_exception_again;
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *__classic_locale;
|
|
|
|
}
|
|
|
|
|
|
|
|
locale::category
|
|
|
|
locale::_S_normalize_category(category __cat)
|
|
|
|
{
|
|
|
|
int __ret;
|
|
|
|
if (__cat == none || (__cat & all) && !(__cat & ~all))
|
|
|
|
__ret = __cat;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// NB: May be a C-style "LC_ALL" category; convert.
|
|
|
|
switch (__cat)
|
|
|
|
{
|
|
|
|
case LC_COLLATE:
|
|
|
|
__ret = collate;
|
|
|
|
break;
|
|
|
|
case LC_CTYPE:
|
|
|
|
__ret = ctype;
|
|
|
|
break;
|
|
|
|
case LC_MONETARY:
|
|
|
|
__ret = monetary;
|
|
|
|
break;
|
|
|
|
case LC_NUMERIC:
|
|
|
|
__ret = numeric;
|
|
|
|
break;
|
|
|
|
case LC_TIME:
|
|
|
|
__ret = time;
|
|
|
|
break;
|
|
|
|
#ifdef _GLIBCPP_HAVE_LC_MESSAGES
|
|
|
|
case LC_MESSAGES:
|
|
|
|
__ret = messages;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case LC_ALL:
|
|
|
|
__ret = all;
|
|
|
|
break;
|
|
|
|
default:
|
2001-02-16 08:44:44 +08:00
|
|
|
__throw_runtime_error("bad locale category");
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return __ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
locale::facet::
|
|
|
|
facet(size_t __refs) throw()
|
|
|
|
: _M_references(__refs)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void
|
|
|
|
locale::facet::
|
|
|
|
_M_add_reference() throw()
|
|
|
|
{ ++_M_references; } // XXX MT
|
|
|
|
|
|
|
|
void
|
|
|
|
locale::facet::
|
|
|
|
_M_remove_reference() throw()
|
|
|
|
{
|
|
|
|
if (_M_references)
|
|
|
|
--_M_references;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{ delete this; } // XXX MT
|
|
|
|
catch (...)
|
|
|
|
{ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Definitions for static const data members of ctype_base.
|
|
|
|
const ctype_base::mask ctype_base::space;
|
|
|
|
const ctype_base::mask ctype_base::print;
|
|
|
|
const ctype_base::mask ctype_base::cntrl;
|
|
|
|
const ctype_base::mask ctype_base::upper;
|
|
|
|
const ctype_base::mask ctype_base::lower;
|
|
|
|
const ctype_base::mask ctype_base::alpha;
|
|
|
|
const ctype_base::mask ctype_base::digit;
|
|
|
|
const ctype_base::mask ctype_base::punct;
|
|
|
|
const ctype_base::mask ctype_base::xdigit;
|
|
|
|
const ctype_base::mask ctype_base::alnum;
|
|
|
|
const ctype_base::mask ctype_base::graph;
|
|
|
|
|
|
|
|
// Platform-specific initialization code for ctype tables.
|
|
|
|
#include <bits/ctype_noninline.h>
|
|
|
|
|
|
|
|
const size_t ctype<char>::table_size;
|
|
|
|
|
|
|
|
ctype<char>::~ctype()
|
|
|
|
{ if (_M_del) delete[] this->table(); }
|
|
|
|
|
|
|
|
// These are dummy placeholders as these virtual functions are never called.
|
|
|
|
bool
|
|
|
|
ctype<char>::do_is(mask, char_type) const
|
|
|
|
{ return false; }
|
|
|
|
|
|
|
|
const char*
|
|
|
|
ctype<char>::do_is(const char_type* __c, const char_type*, mask*) const
|
|
|
|
{ return __c; }
|
|
|
|
|
|
|
|
const char*
|
|
|
|
ctype<char>::do_scan_is(mask, const char_type* __c, const char_type*) const
|
|
|
|
{ return __c; }
|
|
|
|
|
|
|
|
const char*
|
|
|
|
ctype<char>::do_scan_not(mask, const char_type* __c, const char_type*) const
|
|
|
|
{ return __c; }
|
|
|
|
|
|
|
|
char
|
|
|
|
ctype<char>::do_widen(char __c) const
|
|
|
|
{ return __c; }
|
|
|
|
|
|
|
|
const char*
|
|
|
|
ctype<char>::do_widen(const char* __low, const char* __high,
|
|
|
|
char* __dest) const
|
|
|
|
{
|
|
|
|
memcpy(__dest, __low, __high - __low);
|
|
|
|
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* __dest) const
|
|
|
|
{
|
|
|
|
memcpy(__dest, __low, __high - __low);
|
|
|
|
return __high;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctype_byname<char>::ctype_byname(const char* /*__s*/, size_t __refs)
|
|
|
|
: ctype<char>(new mask[table_size], true, __refs)
|
|
|
|
{ }
|
|
|
|
|
2000-09-01 16:58:07 +08:00
|
|
|
// Definitions for static const data members of money_base
|
|
|
|
const money_base::pattern
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
money_base::_S_default_pattern = {{symbol, sign, none, value}};
|
2000-09-01 16:58:07 +08:00
|
|
|
|
|
|
|
template<>
|
|
|
|
_Format_cache<char>::_Format_cache()
|
|
|
|
: _M_valid(true),
|
|
|
|
_M_decimal_point('.'), _M_thousands_sep(','),
|
|
|
|
_M_truename("true"), _M_falsename("false"), _M_use_grouping(false)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
|
|
|
template<>
|
|
|
|
_Format_cache<wchar_t>::_Format_cache()
|
|
|
|
: _M_valid(true),
|
|
|
|
_M_decimal_point(L'.'), _M_thousands_sep(L','),
|
|
|
|
_M_truename(L"true"), _M_falsename(L"false"), _M_use_grouping(false)
|
|
|
|
{ }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template<>
|
|
|
|
const ctype<char>&
|
2000-10-19 07:26:22 +08:00
|
|
|
use_facet<ctype<char> >(const locale& __loc)
|
2000-09-01 16:58:07 +08:00
|
|
|
{
|
|
|
|
size_t __i = ctype<char>::id._M_index;
|
|
|
|
const locale::_Impl* __tmp = __loc._M_impl;
|
|
|
|
return static_cast<const ctype<char>&>(* (*(__tmp->_M_facets))[__i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
|
|
|
template<>
|
|
|
|
const ctype<wchar_t>&
|
2000-10-19 07:26:22 +08:00
|
|
|
use_facet<ctype<wchar_t> >(const locale& __loc)
|
2000-09-01 16:58:07 +08:00
|
|
|
{
|
|
|
|
size_t __i = ctype<wchar_t>::id._M_index;
|
|
|
|
const locale::_Impl* __tmp = __loc._M_impl;
|
|
|
|
return static_cast<const ctype<wchar_t>&>(* (*(__tmp->_M_facets))[__i]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void
|
|
|
|
num_get<char, istreambuf_iterator<char> >::
|
|
|
|
_M_extract(istreambuf_iterator<char> __beg,
|
|
|
|
istreambuf_iterator<char> __end, ios_base& __io,
|
|
|
|
ios_base::iostate& __err, char* __xtrc, int& __base,
|
|
|
|
bool __fp) const
|
|
|
|
{
|
|
|
|
typedef _Format_cache<char> __cache_type;
|
|
|
|
|
|
|
|
// Prepare for possible failure
|
|
|
|
__xtrc[0] = '\0';
|
|
|
|
|
|
|
|
// Stage 1: determine a conversion specifier.
|
|
|
|
ios_base::fmtflags __basefield = __io.flags() & ios_base::basefield;
|
|
|
|
if (__basefield == ios_base::dec)
|
|
|
|
__base = 10;
|
|
|
|
else if (__basefield == ios_base::oct)
|
|
|
|
__base = 8;
|
|
|
|
else if (__basefield == ios_base::hex)
|
|
|
|
__base = 16;
|
|
|
|
else
|
|
|
|
__base = 0;
|
|
|
|
// As far as I can tell, bases other than 10 are not available for
|
|
|
|
// floating point types
|
|
|
|
if (__fp)
|
|
|
|
__base = 10;
|
|
|
|
|
|
|
|
// Stage 2: extract characters.
|
|
|
|
__cache_type const* __fmt = __cache_type::_S_get(__io);
|
|
|
|
bool __valid = __beg != __end;
|
|
|
|
// Fail quickly if !__valid
|
|
|
|
if (!__valid)
|
|
|
|
{
|
|
|
|
__err |= (ios_base::eofbit | ios_base::failbit);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Acceptable formats for numbers here are based on 22.2.3.1
|
|
|
|
string __grp;
|
|
|
|
int __sep_pos = 0;
|
|
|
|
int __pos = 0;
|
|
|
|
const char* __lits = __fmt->_S_literals;
|
|
|
|
char __c = *__beg;
|
|
|
|
|
|
|
|
// Check first for sign
|
|
|
|
bool __testsign = false;
|
|
|
|
if ((__c == __lits[__cache_type::_S_minus])
|
|
|
|
|| (__c == __lits[__cache_type::_S_plus]))
|
|
|
|
{
|
|
|
|
__xtrc[__pos++] = __c;
|
|
|
|
++__beg;
|
|
|
|
__testsign = true;
|
|
|
|
// whitespace may follow a sign
|
|
|
|
while ((__beg != __end) && (isspace(*__beg)))
|
|
|
|
++__beg;
|
|
|
|
|
|
|
|
// There had better be more to come...
|
|
|
|
if (__beg == __end)
|
|
|
|
{
|
|
|
|
__xtrc[__pos] = '\0';
|
|
|
|
__err |= (ios_base::eofbit | ios_base::failbit);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool __testzero = false; // Has there been a leading zero?
|
|
|
|
|
|
|
|
// Now check if first character is a zero
|
|
|
|
__c = *__beg;
|
|
|
|
if (__c == __lits[__cache_type::_S_digits])
|
|
|
|
{
|
|
|
|
__testzero = true;
|
|
|
|
++__beg;
|
|
|
|
|
|
|
|
// We have to check for __beg == __end here. If so,
|
|
|
|
// a plain '0' (possibly with a sign) can be got rid of now
|
|
|
|
if (__beg == __end)
|
|
|
|
{
|
|
|
|
__xtrc[__pos++] = __c;
|
|
|
|
__xtrc[__pos] = '\0';
|
|
|
|
__err |= ios_base::eofbit;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Figure out base for integer types only
|
|
|
|
// Based on Table 55 of 22.2.2.1.2
|
|
|
|
if (!__fp && __base != 10 && __base != 8)
|
|
|
|
{
|
|
|
|
// Here, __base == 0 or 16
|
|
|
|
__c = *__beg;
|
|
|
|
if ((__c == __lits[__cache_type::_S_x])
|
|
|
|
|| (__c == __lits[__cache_type::_S_X]))
|
|
|
|
{
|
|
|
|
++__beg;
|
|
|
|
__base = 16;
|
|
|
|
__testzero = false; // "0x" is not a leading zero
|
|
|
|
}
|
|
|
|
else if (__base == 0)
|
|
|
|
__base = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove any more leading zeros
|
|
|
|
while (__beg != __end)
|
|
|
|
{
|
|
|
|
if (*__beg == __lits[__cache_type::_S_digits])
|
|
|
|
{
|
|
|
|
++__beg;
|
|
|
|
__testzero = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (__base == 0) // 1st character is not zero
|
|
|
|
__base = 10;
|
|
|
|
|
|
|
|
// We now seek "units", i.e. digits and thousands separators.
|
|
|
|
// We may need to know if anything is found here. A leading zero
|
|
|
|
// (removed by now) would count.
|
|
|
|
bool __testunits = __testzero;
|
|
|
|
while (__valid && __beg != __end)
|
|
|
|
{
|
|
|
|
__valid = false;
|
|
|
|
__c = *__beg;
|
|
|
|
const char* __p = strchr(__fmt->_S_literals, __c);
|
|
|
|
|
|
|
|
// NB: strchr returns true for __c == 0x0
|
|
|
|
if (__p && __c)
|
|
|
|
{
|
|
|
|
// Try first for acceptable digit; record it if found
|
|
|
|
if ((__p >= &__lits[__cache_type::_S_digits]
|
|
|
|
&& __p < &__lits[__cache_type::_S_digits + __base])
|
|
|
|
|| (__p >= &__lits[__cache_type::_S_udigits]
|
|
|
|
&& __p < &__lits[__cache_type::_S_udigits + __base]))
|
|
|
|
{
|
|
|
|
__xtrc[__pos++] = __c;
|
|
|
|
++__sep_pos;
|
|
|
|
__valid = true;
|
|
|
|
__testunits = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (__c == __fmt->_M_thousands_sep
|
|
|
|
&& __fmt->_M_use_grouping)
|
|
|
|
{
|
|
|
|
// NB: Thousands separator at the beginning of a string
|
|
|
|
// is a no-no, as is two consecutive thousands
|
|
|
|
// separators
|
|
|
|
if (__sep_pos)
|
|
|
|
{
|
|
|
|
__grp += static_cast<char>(__sep_pos);
|
|
|
|
__sep_pos = 0;
|
|
|
|
__valid = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
__err |= ios_base::failbit;
|
|
|
|
}
|
|
|
|
if (__valid)
|
|
|
|
++__beg;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Digit grouping is checked. If _M_groupings() doesn't
|
|
|
|
// match, then get very very upset, and set failbit.
|
|
|
|
if (__fmt->_M_use_grouping && !__grp.empty())
|
|
|
|
{
|
|
|
|
// Add the ending grouping
|
|
|
|
__grp += static_cast<char>(__sep_pos);
|
|
|
|
|
|
|
|
// __grp is parsed L to R
|
|
|
|
// 1,222,444 == __grp of "/1/3/3"
|
|
|
|
// __fmt->_M_grouping is parsed R to L
|
|
|
|
// 1,222,444 == __fmt->_M_grouping of "/3" == "/3/3/3"
|
|
|
|
int __i = 0;
|
|
|
|
int __j = 0;
|
|
|
|
const int __len = __fmt->_M_grouping.size();
|
|
|
|
int __n = __grp.size();
|
|
|
|
bool __test = true;
|
|
|
|
|
|
|
|
// Parsed number groupings have to match the
|
|
|
|
// numpunct::grouping string exactly, starting at the
|
|
|
|
// right-most point of the parsed sequence of elements ...
|
|
|
|
while (__test && __i < __n - 1)
|
|
|
|
for (__j = 0; __test && __j < __len && __i < __n - 1; ++__j,++__i)
|
|
|
|
__test &= __fmt->_M_grouping[__j] == __grp[__n - __i - 1];
|
|
|
|
// ... but the last parsed grouping can be <= numpunct
|
|
|
|
// grouping.
|
|
|
|
__j == __len ? __j = 0 : __j;
|
|
|
|
__test &= __fmt->_M_grouping[__j] >= __grp[__n - __i - 1];
|
|
|
|
|
|
|
|
if (!__test)
|
|
|
|
{
|
|
|
|
__err |= ios_base::failbit;
|
|
|
|
__xtrc[__pos] = '\0';
|
|
|
|
if (__beg == __end)
|
|
|
|
__err |= ios_base::eofbit;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there was nothing but zeros, put one in the output string
|
|
|
|
if (__testzero && (__pos == 0 || (__pos == 1 && __testsign)))
|
|
|
|
__xtrc[__pos++] = __lits[__cache_type::_S_digits];
|
|
|
|
|
|
|
|
// That's it for integer types. Remaining code is for floating point
|
|
|
|
if (__fp && __beg != __end)
|
|
|
|
{
|
|
|
|
__c = *__beg;
|
|
|
|
// Check first for decimal point. There MUST be one if
|
|
|
|
// __testunits is false.
|
|
|
|
bool __testdec = false; // Is there a decimal point
|
|
|
|
// with digits following it?
|
|
|
|
if (__c == __fmt->_M_decimal_point)
|
|
|
|
{
|
|
|
|
__xtrc[__pos++] = '.';
|
|
|
|
++__beg;
|
|
|
|
// Now we get any digits after the decimal point
|
|
|
|
// There MUST be some if __testunits is false.
|
|
|
|
while (__beg != __end)
|
|
|
|
{
|
|
|
|
__c = *__beg;
|
|
|
|
const char* __p = strchr(__fmt->_S_literals, __c);
|
|
|
|
if ((__p >= &__lits[__cache_type::_S_digits]
|
|
|
|
&& __p < &__lits[__cache_type::_S_digits + __base])
|
|
|
|
|| (__p >= &__lits[__cache_type::_S_udigits]
|
|
|
|
&& __p < &__lits[__cache_type::_S_udigits + __base]))
|
|
|
|
{
|
|
|
|
__xtrc[__pos++] = __c;
|
|
|
|
++__beg;
|
|
|
|
__testdec = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!__testunits && !__testdec) // Ill formed
|
|
|
|
{
|
|
|
|
__err |= ios_base::failbit;
|
|
|
|
__xtrc[__pos] = '\0';
|
|
|
|
if (__beg == __end)
|
|
|
|
__err |= ios_base::eofbit;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now we may find an exponent
|
|
|
|
if (__beg != __end)
|
|
|
|
{
|
|
|
|
__c = *__beg;
|
|
|
|
if ((__c == __lits[__cache_type::_S_ee])
|
|
|
|
|| (__c == __lits[__cache_type::_S_Ee]))
|
|
|
|
{
|
|
|
|
__xtrc[__pos++] = __c;
|
|
|
|
++__beg;
|
|
|
|
// Now there may be a sign
|
|
|
|
if (__beg != __end)
|
|
|
|
{
|
|
|
|
__c = *__beg;
|
|
|
|
if ((__c == __lits[__cache_type::_S_minus])
|
|
|
|
|| (__c == __lits[__cache_type::_S_plus]))
|
|
|
|
{
|
|
|
|
__xtrc[__pos++] = __c;
|
|
|
|
++__beg;
|
|
|
|
// whitespace may follow a sign
|
|
|
|
while ((__beg != __end) && (isspace(*__beg)))
|
|
|
|
++__beg;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// And now there must be some digits
|
|
|
|
if (__beg == __end)
|
|
|
|
{
|
|
|
|
__xtrc[__pos] = '\0';
|
|
|
|
__err |= (ios_base::eofbit | ios_base::failbit);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (__beg != __end)
|
|
|
|
{
|
|
|
|
__c = *__beg;
|
|
|
|
const char* __p = strchr(__fmt->_S_literals, __c);
|
|
|
|
if ((__p >= &__lits[__cache_type::_S_digits]
|
|
|
|
&& __p < &__lits[__cache_type::_S_digits + __base])
|
|
|
|
|| (__p >= &__lits[__cache_type::_S_udigits]
|
|
|
|
&& __p < &__lits[__cache_type::_S_udigits + __base]))
|
|
|
|
{
|
|
|
|
__xtrc[__pos++] = __c;
|
|
|
|
++__beg;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Finally, that's it for floating point
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finish up
|
|
|
|
__xtrc[__pos] = '\0';
|
|
|
|
if (__beg == __end)
|
|
|
|
__err |= ios_base::eofbit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The following code uses sprintf() to convert floating point
|
|
|
|
// values for insertion into a stream. The current implementation
|
|
|
|
// replicates the code in _S_pad_numeric() (in _S_output_float()) in
|
|
|
|
// order to prevent having to create a "wide" buffer in addition to
|
|
|
|
// the "narrow" buffer passed to sprintf(). An optimization would be
|
|
|
|
// to replace sprintf() with code that works directly on a wide
|
|
|
|
// buffer and then use _S_pad_numeric() to do the padding. It would
|
|
|
|
// be good to replace sprintf() anyway to avoid accidental buffer
|
|
|
|
// overruns and to gain back the efficiency that C++ provides by
|
|
|
|
// knowing up front the type of the values to insert. This
|
|
|
|
// implementation follows the C++ standard fairly directly as
|
|
|
|
// outlined in 22.2.2.2 [lib.locale.num.put]
|
|
|
|
bool
|
2001-02-07 09:54:21 +08:00
|
|
|
__build_float_format(ios_base& __io, char* __fptr, char __modifier,
|
|
|
|
streamsize __prec)
|
2000-09-01 16:58:07 +08:00
|
|
|
{
|
|
|
|
bool __incl_prec = false;
|
|
|
|
ios_base::fmtflags __flags = __io.flags();
|
|
|
|
*__fptr++ = '%';
|
|
|
|
// [22.2.2.2.2] Table 60
|
|
|
|
if (__flags & ios_base::showpos)
|
|
|
|
*__fptr++ = '+';
|
|
|
|
if (__flags & ios_base::showpoint)
|
|
|
|
*__fptr++ = '#';
|
|
|
|
// As per [22.2.2.2.2.11]
|
|
|
|
if (__flags & ios_base::fixed || __prec > 0)
|
|
|
|
{
|
|
|
|
*__fptr++ = '.';
|
|
|
|
*__fptr++ = '*';
|
|
|
|
__incl_prec = true;
|
|
|
|
}
|
|
|
|
if (__modifier)
|
|
|
|
*__fptr++ = __modifier;
|
|
|
|
ios_base::fmtflags __fltfield = __flags & ios_base::floatfield;
|
|
|
|
// [22.2.2.2.2] Table 58
|
|
|
|
if (__fltfield == ios_base::fixed)
|
|
|
|
*__fptr++ = 'f';
|
|
|
|
else if (__fltfield == ios_base::scientific)
|
|
|
|
*__fptr++ = (__flags & ios_base::uppercase) ? 'E' : 'e';
|
|
|
|
else
|
|
|
|
*__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g';
|
|
|
|
*__fptr = '\0';
|
|
|
|
return __incl_prec;
|
|
|
|
}
|
|
|
|
|
2000-04-22 04:33:34 +08:00
|
|
|
collate<char>::collate(size_t __refs)
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
: locale::facet(__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
|
|
|
collate<char>::~collate() { }
|
|
|
|
|
|
|
|
int
|
2000-09-15 03:44:03 +08:00
|
|
|
collate<char>::do_compare(const char* __lo1, const char* __hi1,
|
|
|
|
const char* __lo2, const char* __hi2) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
|
|
|
for (; __lo1 < __hi1 && __lo2 < __hi2; ++__lo1, ++__lo2)
|
|
|
|
if (*__lo1 != *__lo2)
|
|
|
|
return (*__lo1 < *__lo2) ? -1 : 1;
|
|
|
|
if (__lo1 < __hi1)
|
|
|
|
return 1;
|
|
|
|
else if (__lo2 < __hi2)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
2000-06-03 09:52:32 +08:00
|
|
|
collate<char>::
|
|
|
|
do_transform(const char* __lo, const char* __hi) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{ return string(__lo, __hi - __lo); }
|
|
|
|
|
|
|
|
long
|
2000-06-03 09:52:32 +08:00
|
|
|
collate<char>::
|
|
|
|
do_hash(const char* __lo, const char* __hi) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
|
|
|
unsigned long __val = 0xdeadbeef;
|
|
|
|
for (; __lo < __hi; ++__lo)
|
|
|
|
__val = *__lo ^ ((__val << 7) &
|
|
|
|
(__val >> (numeric_limits<unsigned long>::digits - 1)));
|
|
|
|
return __val;
|
|
|
|
}
|
|
|
|
|
2000-09-15 03:44:03 +08:00
|
|
|
collate_byname<char>::collate_byname(const char* /*__s*/, size_t __refs)
|
2000-06-03 09:52:32 +08:00
|
|
|
: collate<char>(__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-09-15 03:44:03 +08:00
|
|
|
moneypunct_byname<char, false>::moneypunct_byname(const char* /*__s*/,
|
|
|
|
size_t __refs)
|
2000-06-03 09:52:32 +08:00
|
|
|
: moneypunct<char, false>(__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-09-15 03:44:03 +08:00
|
|
|
moneypunct_byname<char, true>::moneypunct_byname(const char* /*__s*/,
|
|
|
|
size_t __refs)
|
2000-06-03 09:52:32 +08:00
|
|
|
: moneypunct<char, true>(__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-06-03 09:52:32 +08:00
|
|
|
messages_byname<char>::
|
|
|
|
messages_byname(const char* /*__s*/, size_t __refs)
|
|
|
|
: messages<char>(__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
|
|
|
#ifdef _GLIBCPP_USE_WCHAR_T
|
2000-12-07 14:44:49 +08:00
|
|
|
ctype<wchar_t>::__wmask_type
|
|
|
|
ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
|
|
|
|
{
|
|
|
|
__wmask_type __ret;
|
|
|
|
switch (__m)
|
|
|
|
{
|
|
|
|
case space:
|
|
|
|
__ret = wctype("space");
|
|
|
|
break;
|
|
|
|
case print:
|
|
|
|
__ret = wctype("print");
|
|
|
|
break;
|
|
|
|
case cntrl:
|
|
|
|
__ret = wctype("cntrl");
|
|
|
|
break;
|
|
|
|
case upper:
|
|
|
|
__ret = wctype("upper");
|
|
|
|
break;
|
|
|
|
case lower:
|
|
|
|
__ret = wctype("lower");
|
|
|
|
break;
|
|
|
|
case alpha:
|
|
|
|
__ret = wctype("alpha");
|
|
|
|
break;
|
|
|
|
case digit:
|
|
|
|
__ret = wctype("digit");
|
|
|
|
break;
|
|
|
|
case punct:
|
|
|
|
__ret = wctype("punct");
|
|
|
|
break;
|
|
|
|
case xdigit:
|
|
|
|
__ret = wctype("xdigit");
|
|
|
|
break;
|
|
|
|
case alnum:
|
|
|
|
__ret = wctype("alnum");
|
|
|
|
break;
|
|
|
|
case graph:
|
|
|
|
__ret = wctype("graph");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
__ret = 0;
|
|
|
|
}
|
|
|
|
return __ret;
|
|
|
|
};
|
|
|
|
|
2000-12-20 06:55:07 +08:00
|
|
|
ctype<wchar_t>::~ctype() { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-06-13 10:13:54 +08:00
|
|
|
// NB: These ctype<wchar_t> methods are not configuration-specific,
|
|
|
|
// unlike the ctype<char> bits.
|
2000-12-07 14:44:49 +08:00
|
|
|
ctype<wchar_t>::ctype(size_t __refs) : __ctype_abstract_base<wchar_t>(__refs)
|
|
|
|
{ }
|
2000-06-13 10:13:54 +08:00
|
|
|
|
|
|
|
wchar_t
|
|
|
|
ctype<wchar_t>::do_toupper(wchar_t __c) const
|
2000-08-31 05:01:33 +08:00
|
|
|
{ return towupper(__c); }
|
2000-06-13 10:13:54 +08:00
|
|
|
|
|
|
|
const wchar_t*
|
|
|
|
ctype<wchar_t>::do_toupper(wchar_t* __low, const wchar_t* __high) const
|
|
|
|
{
|
|
|
|
while (__low < __high)
|
|
|
|
{
|
2000-08-31 05:01:33 +08:00
|
|
|
*__low = towupper(*__low);
|
2000-06-13 10:13:54 +08:00
|
|
|
++__low;
|
|
|
|
}
|
|
|
|
return __high;
|
|
|
|
}
|
|
|
|
|
|
|
|
wchar_t
|
|
|
|
ctype<wchar_t>::do_tolower(wchar_t __c) const
|
2000-08-31 05:01:33 +08:00
|
|
|
{ return towlower(__c); }
|
2000-06-13 10:13:54 +08:00
|
|
|
|
|
|
|
const wchar_t*
|
|
|
|
ctype<wchar_t>::do_tolower(wchar_t* __low, const wchar_t* __high) const
|
|
|
|
{
|
|
|
|
while (__low < __high)
|
|
|
|
{
|
2000-08-31 05:01:33 +08:00
|
|
|
*__low = towlower(*__low);
|
2000-06-13 10:13:54 +08:00
|
|
|
++__low;
|
|
|
|
}
|
|
|
|
return __high;
|
|
|
|
}
|
|
|
|
|
2000-04-22 04:33:34 +08:00
|
|
|
bool
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype<wchar_t>::
|
2000-08-31 05:01:33 +08:00
|
|
|
do_is(mask __m, char_type __c) const
|
2000-08-31 07:13:57 +08:00
|
|
|
{ return static_cast<bool>(iswctype(__c, _M_convert_to_wmask(__m))); }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
|
|
|
const wchar_t*
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype<wchar_t>::
|
2000-08-31 05:01:33 +08:00
|
|
|
do_is(const wchar_t* __low, const wchar_t* __high, mask* __m) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-08-31 05:01:33 +08:00
|
|
|
while (__low < __high && !this->is(*__m, *__low))
|
|
|
|
++__low;
|
2000-06-13 10:13:54 +08:00
|
|
|
return __low;
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const wchar_t*
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype<wchar_t>::
|
2000-08-31 05:01:33 +08:00
|
|
|
do_scan_is(mask __m, const wchar_t* __low, const wchar_t* __high) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-08-31 05:01:33 +08:00
|
|
|
while (__low < __high && !this->is(__m, *__low))
|
|
|
|
++__low;
|
2000-04-22 04:33:34 +08:00
|
|
|
return __low;
|
|
|
|
}
|
|
|
|
|
|
|
|
const wchar_t*
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype<wchar_t>::
|
2000-08-31 05:01:33 +08:00
|
|
|
do_scan_not(mask __m, const char_type* __low, const char_type* __high) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-08-31 05:01:33 +08:00
|
|
|
while (__low < __high && this->is(__m, *__low) != 0)
|
|
|
|
++__low;
|
2000-04-22 04:33:34 +08:00
|
|
|
return __low;
|
|
|
|
}
|
|
|
|
|
|
|
|
wchar_t
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype<wchar_t>::
|
|
|
|
do_widen(char __c) const
|
2000-08-31 05:01:33 +08:00
|
|
|
{ return btowc(__c); }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
|
|
|
const char*
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype<wchar_t>::
|
2000-08-31 05:01:33 +08:00
|
|
|
do_widen(const char* __low, const char* __high, wchar_t* __dest) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-08-31 05:01:33 +08:00
|
|
|
mbstate_t __state;
|
[multiple changes]
2000-10-02 Steven King <sxking@uswest.net>
* mkcshadow: Fixed script to output proper include guard.
* bits/char_traits.h: Cleaned up types in char_traits<char> functions.
* libio/_G_config.h: Hacked to make work with shadow heraders.
* shadow/*: Hacked to make shadow headers work.
2000-10-02 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
Self-compile with shadow headers.
* acconfig.h (_GLIBCPP_USE_SHADOW_HEADERS): Define. Eventually,
like _GLIBCPP_USE_NAMESPACES before it, this macro will die when
it becomes the default way the library is built.
* acinclude.m4 (GLIBCPP_ENABLE_SHADOW): New macro.
* config/gnu-linux/bits/ctype_base.h (ctype_base): Use it.
* config/gnu-linux/ctype.cc (ctype): Use it.
* src/localename.cc (locale::_Impl::_M_replace_categories): Remove
call to assert.
* src/locale.cc: Explicitly cast mbstate_t to void* in calls to
memset. This should not be necessary, but an ambiguous overload
with it in.
* shadow/bits/std_cwchar.h: Fix.
* shadow/wchar.h: Fix.
* config/gnu-linux/bits/ctype_base.h (ctype_base): Inject ctype
enums into namespace std:: for ctype_base enum. Other OS types
will have to do this as well.
* config/gnu-linux/ctype.cc (ctype): Inject ctype data into
namespace std, in particular __ctype_toupper, __ctype_tolower,
__ctype_b.
* shadow/iolibio.h: New file.
* shadow/bits/wrap_iolibio.h: New file.
* shadow/libioP.h: New file.
* shadow/bits/wrap_libioP.h: New file.
* shadow/bits/wrap_fcntl.h: New file.
* shadow/fcntl.h: New file.
* shadow/iconv.h: New file. Inject iconv names into the global
namespace, unmangled for the moment.
* shadow/bits/wrap_iconv.h: New file.
* shadow/unistd.h: Remove. Useless.
* shadow/bits/wrap_unistd.h: Remove.
* src/Makefile.am: Take out machine-ansi.h, add fcntl.h unistd.h.
* src/Makefile.in: Regenerate.
* config/c_io_libio.h (_IO_codecvt): Change to normal C++ decl.
* shadow/libio.h: Fix.
* shadow/bits/wrap_libio.h: Fix.
* shadow/bits/std_clocale.h: Remove typedef struct construct,
which will not compile.
* shadow/bits/std_ctime.h: Same.
* shadow/pthread.h: New file. Put pthreads types and functions
into global scope, which is probably not the correct long-term
solution but has to be done at the moment before libio wrappers
can even be started.
* shadow/bits/wrap_pthread.h: New file.
* bits/std_ios.h: Formatting tweak.
* shadow/bits/std_cstdio.h: Format. Remove extraneous bits.
* acinclude.m4 (GLIBCPP_CHECK_COMPILER_FEATURES): Add -Werror to
tests for compiler features.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* config/c_io_libio.cc: Remove fcntl.h include, as SEEK_SET
redefined.
* libio/libioP.h: Comment out fcntl.h include.
* shadow/math.h: Add in float and long declarations, as per ISO C9X.
* bits/c++config: Define _ISOC99_SOURCE.
* acinclude.m4 (GLIBCPP_ENABLE_SHADOW): Add -fno-builtins to
CSHADOWFLAGS, as well as _ISOC99_SOURCE.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* src/Makefile.am (CSHADOW_INCLUDES): Enable, again.
(CSHADOW_INCLUDES): Add -I$(top_srcdir)/std before shadow include dir.
(CXXCOMPILE): Remove $(DEFS), which searches $(top_srcdir) before
std or shadow directories.
(LTCXXCOMPILE): Same.
(INCLUDES): Add $(top_builddir) before $(top_srcdir).
(AC_CXXFLAGS): Add CSHADOWFLAGS.
* src/Makefile.in: Regenerate.
* src/complex.cc (FCT): Change ::name to name.
* src/complexl.cc (FCT): Same. Use _GLIBCPP_USE_LONG_LONG here.
* src/complexf.cc (FCT): Same.
* src/complexf.cc: Remove FCT define, as things are properly
overloaded in the std namespace with the shadow headers.
* src/complexl.cc: Same.
* src/complex.cc: Same.
From-SVN: r36707
2000-10-04 13:06:32 +08:00
|
|
|
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
|
2000-08-31 05:01:33 +08:00
|
|
|
mbsrtowcs(__dest, &__low, __high - __low, &__state);
|
2000-04-22 04:33:34 +08:00
|
|
|
return __high;
|
|
|
|
}
|
|
|
|
|
|
|
|
char
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype<wchar_t>::
|
2000-08-31 05:01:33 +08:00
|
|
|
do_narrow(wchar_t __wc, char __dfault) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-08-31 05:01:33 +08:00
|
|
|
int __c = wctob(__wc);
|
|
|
|
return (__c == EOF ? __dfault : static_cast<char>(__c));
|
2000-04-22 04:33:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const wchar_t*
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype<wchar_t>::
|
2000-08-31 05:01:33 +08:00
|
|
|
do_narrow(const wchar_t* __low, const wchar_t* __high, char __dfault,
|
|
|
|
char* __dest) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
2000-08-31 05:01:33 +08:00
|
|
|
mbstate_t __state;
|
[multiple changes]
2000-10-02 Steven King <sxking@uswest.net>
* mkcshadow: Fixed script to output proper include guard.
* bits/char_traits.h: Cleaned up types in char_traits<char> functions.
* libio/_G_config.h: Hacked to make work with shadow heraders.
* shadow/*: Hacked to make shadow headers work.
2000-10-02 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
Self-compile with shadow headers.
* acconfig.h (_GLIBCPP_USE_SHADOW_HEADERS): Define. Eventually,
like _GLIBCPP_USE_NAMESPACES before it, this macro will die when
it becomes the default way the library is built.
* acinclude.m4 (GLIBCPP_ENABLE_SHADOW): New macro.
* config/gnu-linux/bits/ctype_base.h (ctype_base): Use it.
* config/gnu-linux/ctype.cc (ctype): Use it.
* src/localename.cc (locale::_Impl::_M_replace_categories): Remove
call to assert.
* src/locale.cc: Explicitly cast mbstate_t to void* in calls to
memset. This should not be necessary, but an ambiguous overload
with it in.
* shadow/bits/std_cwchar.h: Fix.
* shadow/wchar.h: Fix.
* config/gnu-linux/bits/ctype_base.h (ctype_base): Inject ctype
enums into namespace std:: for ctype_base enum. Other OS types
will have to do this as well.
* config/gnu-linux/ctype.cc (ctype): Inject ctype data into
namespace std, in particular __ctype_toupper, __ctype_tolower,
__ctype_b.
* shadow/iolibio.h: New file.
* shadow/bits/wrap_iolibio.h: New file.
* shadow/libioP.h: New file.
* shadow/bits/wrap_libioP.h: New file.
* shadow/bits/wrap_fcntl.h: New file.
* shadow/fcntl.h: New file.
* shadow/iconv.h: New file. Inject iconv names into the global
namespace, unmangled for the moment.
* shadow/bits/wrap_iconv.h: New file.
* shadow/unistd.h: Remove. Useless.
* shadow/bits/wrap_unistd.h: Remove.
* src/Makefile.am: Take out machine-ansi.h, add fcntl.h unistd.h.
* src/Makefile.in: Regenerate.
* config/c_io_libio.h (_IO_codecvt): Change to normal C++ decl.
* shadow/libio.h: Fix.
* shadow/bits/wrap_libio.h: Fix.
* shadow/bits/std_clocale.h: Remove typedef struct construct,
which will not compile.
* shadow/bits/std_ctime.h: Same.
* shadow/pthread.h: New file. Put pthreads types and functions
into global scope, which is probably not the correct long-term
solution but has to be done at the moment before libio wrappers
can even be started.
* shadow/bits/wrap_pthread.h: New file.
* bits/std_ios.h: Formatting tweak.
* shadow/bits/std_cstdio.h: Format. Remove extraneous bits.
* acinclude.m4 (GLIBCPP_CHECK_COMPILER_FEATURES): Add -Werror to
tests for compiler features.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* config/c_io_libio.cc: Remove fcntl.h include, as SEEK_SET
redefined.
* libio/libioP.h: Comment out fcntl.h include.
* shadow/math.h: Add in float and long declarations, as per ISO C9X.
* bits/c++config: Define _ISOC99_SOURCE.
* acinclude.m4 (GLIBCPP_ENABLE_SHADOW): Add -fno-builtins to
CSHADOWFLAGS, as well as _ISOC99_SOURCE.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* src/Makefile.am (CSHADOW_INCLUDES): Enable, again.
(CSHADOW_INCLUDES): Add -I$(top_srcdir)/std before shadow include dir.
(CXXCOMPILE): Remove $(DEFS), which searches $(top_srcdir) before
std or shadow directories.
(LTCXXCOMPILE): Same.
(INCLUDES): Add $(top_builddir) before $(top_srcdir).
(AC_CXXFLAGS): Add CSHADOWFLAGS.
* src/Makefile.in: Regenerate.
* src/complex.cc (FCT): Change ::name to name.
* src/complexl.cc (FCT): Same. Use _GLIBCPP_USE_LONG_LONG here.
* src/complexf.cc (FCT): Same.
* src/complexf.cc: Remove FCT define, as things are properly
overloaded in the std namespace with the shadow headers.
* src/complexl.cc: Same.
* src/complex.cc: Same.
From-SVN: r36707
2000-10-04 13:06:32 +08:00
|
|
|
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
|
2000-08-31 05:01:33 +08:00
|
|
|
size_t __len = __high - __low;
|
|
|
|
size_t __conv = wcsrtombs(__dest, &__low, __len, &__state);
|
|
|
|
if (__conv == __len)
|
|
|
|
*__dest = __dfault;
|
2000-04-22 04:33:34 +08:00
|
|
|
return __high;
|
|
|
|
}
|
|
|
|
|
2000-06-03 09:52:32 +08:00
|
|
|
ctype_byname<wchar_t>::
|
|
|
|
ctype_byname(const char* /*__s*/, size_t __refs)
|
|
|
|
: ctype<wchar_t>(__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-06-03 09:52:32 +08:00
|
|
|
collate<wchar_t>::
|
Preliminary named locales.
2001-01-29 Benjamin Kosnik <bkoz@redhat.com>
Preliminary named locales.
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): New macro.
* aclocal.m4: Regenerate.
* configure.in: Use it.
* configure: Regerate.
* src/Makefile.am (sources): Add c++locale.cc.
(build_headers): Add c++locale.h.
* src/Makefile.in: Regenerate.
* config/c_locale_gnu.h: New file.
* config/c_locale_gnu.cc: New file. Non-inline member functions
for named locales, gnu-specific.
* config/c_locale_generic.h: New file.
* config/c_locale_generic.cc: New file. Non-inline member
functions for named locales, generic version.
* docs/html/configopts.html: Add documentation on new options.
* include/bits/locale_facets.h (class _Messages): Remove.
(class _Moneypunct): Remove.
* src/locale-inst.cc: Remove.
* include/bits/locale_facets.h (class _Collate): Remove.
* src/locale-inst.cc (std): Remove.
* src/locale.cc: And here.
* include/bits/localefwd.h (locale::_M_coalesce): New
function. Correctly put together multi-name locales.
(_Impl(const _Impl&, category, size_t)): Remove.
* include/bits/localefwd.h (locale::_Impl): Remove _M_construct_*
member functions.
(_M_normalize_category_names): Remove.
(_M_replace_categories): Fix.
* src/localename.cc (locale::_Impl::_M_construct_collate): Remove.
(locale::_Impl::_M_construct_ctype): Remove.
(locale::_Impl::_M_construct_monetary): Remove.
(locale::_Impl::_M_construct_numeric): Remove.
(locale::_Impl::_M_construct_time): Remove.
(locale::_Impl::_M_construct_messages): Remove.
* include/bits/locale_facets.h (_Bad_use_facet): Remove.
(_Use_facet_failure_handle): Remove.
* src/locale.cc: Remove definitions.
* src/locale-inst.cc: And here.
* testsuite/22_locale/ctor_copy_dtor.cc (test01): Fixup. Add tests.
* src/localename.cc (locale::facet::_S_create_c_locale): Properly
create and error-check underlying locale object.
(locale::facet::_S_destroy_c_locale): Add, take care of properly
tearing down underlying locale object.
* include/bits/localefwd.h (locale::facet): Declare.
* testsuite/22_locale/members.cc: Don't test "fr_FR" locale for
correctness, as glibc apparently has incorrect info in it. Test
with it when it works again.....
* include/bits/localefwd.h (locale::_Impl::__vec_string):
Remove. Number of categories is fixed at six, so just simplify and
make this an array of strings.
(locale::_Impl::_M_has_name): Remove.
(locale::_Impl::_M_name): Remove.
(locale::_Impl::_M_category_names): Turns into...
(locale::_Impl::_M_names): ...this.
(locale::_Impl::_M_has_same_name()): New function.
* src/localename.cc (locale::_Impl::~_Impl()): Remove here.
(locale::_Impl::_Impl(size_t __refs, string __str)): Simplify
signature.
* src/locale.cc (locale::name()): Construct mangled name
accurately reflecting combined locale categories.
* src/locale.cc (locale::classic()): Don't initialize here.
* src/localename.cc (locale::_Impl::_Impl(size_t __num, size_t
__refs, bool __has_name, string __str): Do it here.
* include/bits/localefwd.h: _S_categories_num to
_S_num_categories. _S_facets_num to _S_num_facets.
(locale::id::id()): Explicitly set _M_index to zero.
* src/locale.cc: Same.
* src/locale.cc: (locale::locale(const char*)): Construct named
locales uniquely.
* src/locale.cc: Remove numpunct_byname ctors.
* testsuite/22_locale/numpunct_byname.cc: New file.
* testsuite/22_locale/numpunct.cc: New file.
* include/bits/localefwd.h (class locale): Change data members to
protected, from private.
(_Impl::_M_get_c_locale): Add member function.
(locale::facet::_M_get_global_impl()): Add member function.
* include/bits/locale_facets.h (numpunct::_M_init): Change to take
a __c_locale pointer.
(numpunct::numpunct( __c_locale*, size_t)): Add additonal ctor for
named locales.
* testsuite/22_locale/members.cc: New file, test name and combine.
* include/bits/locale_facets.h (class numpunct): Remove class
_Punct and _Numpunct. Rewrite class numpunct to be correct for
named locales.
* include/bits/localefwd.h (locale::_Imp::_M_c_locale): Add.
* src/localename.cc (_Impl::~_Impl()): Call __frelocale.
(_Imp::_Impl(size_t, size_t, bool, string)) Initialize _M_c_locale.
* src/locale-inst.cc: Remove _Numpunct, _Punct instantiations.
* testsuite/22_locale/numpunct_char_members.cc: New file.
From-SVN: r39347
2001-01-30 17:18:51 +08:00
|
|
|
collate(size_t __refs): locale::facet(__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-06-03 09:52:32 +08:00
|
|
|
collate<wchar_t>::
|
|
|
|
~collate() { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-06-03 09:52:32 +08:00
|
|
|
int
|
|
|
|
collate<wchar_t>::
|
2000-04-22 04:33:34 +08:00
|
|
|
do_compare(const wchar_t* /*__lo1*/, const wchar_t* /*__hi1*/,
|
|
|
|
const wchar_t* /*__lo2*/, const wchar_t* /*__hi2*/) const
|
|
|
|
{
|
|
|
|
return 0; // XXX not done
|
|
|
|
}
|
|
|
|
|
2000-06-03 09:52:32 +08:00
|
|
|
wstring collate<wchar_t>::
|
|
|
|
do_transform(const wchar_t* /*__lo*/, const wchar_t* /*__hi*/) const
|
2000-04-22 04:33:34 +08:00
|
|
|
{
|
|
|
|
return wstring(); // XXX not done
|
|
|
|
}
|
|
|
|
|
|
|
|
long collate<wchar_t>::
|
|
|
|
do_hash(const wchar_t* /*__lo*/, const wchar_t* /*__hi*/) const
|
|
|
|
{
|
|
|
|
return 0; // XXX not done
|
|
|
|
}
|
|
|
|
|
2000-06-03 09:52:32 +08:00
|
|
|
collate_byname<wchar_t>::
|
|
|
|
collate_byname(const char* /*__s*/, size_t __refs)
|
|
|
|
: collate<wchar_t> (__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
|
2000-06-03 09:52:32 +08:00
|
|
|
messages_byname<wchar_t>::
|
|
|
|
messages_byname(const char* /*__s*/, size_t __refs)
|
|
|
|
: messages<wchar_t> (__refs) { }
|
2000-04-22 04:33:34 +08:00
|
|
|
#endif // _GLIBCPP_USE_WCHAR_T
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|