Clean up initialization and simplfy caching of underlying "C" locale objects.
2001-12-14 Benjamin Kosnik <bkoz@redhat.com> Clean up initialization and simplfy caching of underlying "C" locale objects. * src/localename.cc (locale::_Impl::_Impl(string, size_t): Unconditionally create __clocale object for all named locales, including "C" and "POSIX". * config/locale/c_locale_generic.cc (locale::facet::_S_create_c_locale): Always set __cloc to zero. * config/locale/c_locale_gnu.cc: Always delete. * include/bits/localefwd.h (locale::facet::_S_c_locale): New. * src/locale.cc (locale::classic()): Initialize locale::facet::_S_c_locale. (locale::facet::_S_c_locale): Define. * include/bits/locale_facets.h: Add ctype_byname<wchar_t> ctor specialization. * src/locale.cc: Add definition here. * config/os/gnu-linux/bits/ctype_inline.h: Tweak. * config/os/gnu-linux/bits/ctype_noninline.h: Adjust initializations. * include/bits/locale_facets.h (ctype<char>::_M_c_locale_ctype): Add. Adjust ctors, dtors. (ctype<char>::_M_toupper): Remove const&. (ctype<char>::_M_tolower): Remove const&. (ctype<char>::_M_ctable): Remove const&. * include/bits/locale_facets.h (collate): Clean up initialization of _M_c_locale_collate in ctors and dtors. * config/locale/collate_members_gnu.cc: Always use extended functions. * include/bits/locale_facets.h (messages): Clean up inits in ctor/dtor. (messages_byname): Same. * config/locale/messages_members_generic.h (messages::~messages): Remove. * config/locale/messages_members_gnu.h: Same. * include/bits/localefwd.h: Clean. Move dtor definitions to * src/locale.cc: Here. * testsuite/22_locale/facet.cc: Fix spelling. Named locale support for ctype<wchar_t>. * acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): Add variable ctype_members_* bits. * aclocal.m4: Regenerate. * configure: Regenerate. * src/Makefile.am (sources): Add ctype.cc. * src/Makefile.in: Regenerate. * config/locale/ctype_members_generic.cc: New file. * config/locale/ctype_members_gnu.cc: New file. * src/locale.cc: Remove ctype<wchart_t> definitions. From-SVN: r48034
This commit is contained in:
parent
88f92c0f3f
commit
def9790d51
@ -1,3 +1,55 @@
|
||||
2001-12-14 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
Clean up initialization and simplfy caching of underlying "C"
|
||||
locale objects.
|
||||
* src/localename.cc (locale::_Impl::_Impl(string, size_t):
|
||||
Unconditionally create __clocale object for all named locales,
|
||||
including "C" and "POSIX".
|
||||
* config/locale/c_locale_generic.cc
|
||||
(locale::facet::_S_create_c_locale): Always set __cloc to zero.
|
||||
* config/locale/c_locale_gnu.cc: Always delete.
|
||||
* include/bits/localefwd.h (locale::facet::_S_c_locale): New.
|
||||
* src/locale.cc (locale::classic()): Initialize
|
||||
locale::facet::_S_c_locale.
|
||||
(locale::facet::_S_c_locale): Define.
|
||||
|
||||
* include/bits/locale_facets.h: Add ctype_byname<wchar_t> ctor
|
||||
specialization.
|
||||
* src/locale.cc: Add definition here.
|
||||
* config/os/gnu-linux/bits/ctype_inline.h: Tweak.
|
||||
* config/os/gnu-linux/bits/ctype_noninline.h: Adjust initializations.
|
||||
* include/bits/locale_facets.h (ctype<char>::_M_c_locale_ctype): Add.
|
||||
Adjust ctors, dtors.
|
||||
(ctype<char>::_M_toupper): Remove const&.
|
||||
(ctype<char>::_M_tolower): Remove const&.
|
||||
(ctype<char>::_M_ctable): Remove const&.
|
||||
|
||||
* include/bits/locale_facets.h (collate): Clean up initialization
|
||||
of _M_c_locale_collate in ctors and dtors.
|
||||
* config/locale/collate_members_gnu.cc: Always use extended
|
||||
functions.
|
||||
|
||||
* include/bits/locale_facets.h (messages): Clean up inits in ctor/dtor.
|
||||
(messages_byname): Same.
|
||||
* config/locale/messages_members_generic.h (messages::~messages):
|
||||
Remove.
|
||||
* config/locale/messages_members_gnu.h: Same.
|
||||
|
||||
* include/bits/localefwd.h: Clean. Move dtor definitions to
|
||||
* src/locale.cc: Here.
|
||||
* testsuite/22_locale/facet.cc: Fix spelling.
|
||||
|
||||
Named locale support for ctype<wchar_t>.
|
||||
* acinclude.m4 (GLIBCPP_ENABLE_CLOCALE): Add variable
|
||||
ctype_members_* bits.
|
||||
* aclocal.m4: Regenerate.
|
||||
* configure: Regenerate.
|
||||
* src/Makefile.am (sources): Add ctype.cc.
|
||||
* src/Makefile.in: Regenerate.
|
||||
* config/locale/ctype_members_generic.cc: New file.
|
||||
* config/locale/ctype_members_gnu.cc: New file.
|
||||
* src/locale.cc: Remove ctype<wchart_t> definitions.
|
||||
|
||||
2001-12-13 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
* acconfig.h: Test for __builtin_sqrt instead of
|
||||
|
@ -1059,6 +1059,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
|
||||
CLOCALE_CC=config/locale/c_locale_generic.cc
|
||||
CCODECVT_H=config/locale/codecvt_specializations_generic.h
|
||||
CCOLLATE_CC=config/locale/collate_members_generic.cc
|
||||
CCTYPE_CC=config/locale/ctype_members_generic.cc
|
||||
CMESSAGES_H=config/locale/messages_members_generic.h
|
||||
CMESSAGES_CC=config/locale/messages_members_generic.cc
|
||||
CMONEY_CC=config/locale/moneypunct_members_generic.cc
|
||||
@ -1088,6 +1089,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
|
||||
CLOCALE_CC=config/locale/c_locale_gnu.cc
|
||||
CCODECVT_H=config/locale/codecvt_specializations_ieee_1003.1-200x.h
|
||||
CCOLLATE_CC=config/locale/collate_members_gnu.cc
|
||||
CCTYPE_CC=config/locale/ctype_members_gnu.cc
|
||||
CMESSAGES_H=config/locale/messages_members_gnu.h
|
||||
CMESSAGES_CC=config/locale/messages_members_gnu.cc
|
||||
CMONEY_CC=config/locale/moneypunct_members_gnu.cc
|
||||
@ -1104,6 +1106,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
|
||||
CLOCALE_CC=config/locale/c_locale_ieee_1003.1-200x.cc
|
||||
CCODECVT_H=config/locale/codecvt_specializations_ieee_1003.1-200x.h
|
||||
CCOLLATE_CC=config/locale/collate_members_generic.cc
|
||||
CCTYPE_CC=config/locale/ctype_members_generic.cc
|
||||
CMESSAGES_H=config/locale/messages_members_ieee_1003.1-200x.h
|
||||
CMESSAGES_CC=config/locale/messages_members_ieee_1003.1-200x.cc
|
||||
CMONEY_CC=config/locale/moneypunct_members_generic.cc
|
||||
@ -1127,6 +1130,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
|
||||
AC_SUBST(CMESSAGES_H)
|
||||
AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
|
||||
AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
|
||||
AC_LINK_FILES($CCTYPE_CC, src/ctype.cc)
|
||||
AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)
|
||||
AC_LINK_FILES($CMONEY_CC, src/moneypunct.cc)
|
||||
AC_LINK_FILES($CNUMERIC_CC, src/numpunct.cc)
|
||||
|
4
libstdc++-v3/aclocal.m4
vendored
4
libstdc++-v3/aclocal.m4
vendored
@ -1071,6 +1071,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
|
||||
CLOCALE_CC=config/locale/c_locale_generic.cc
|
||||
CCODECVT_H=config/locale/codecvt_specializations_generic.h
|
||||
CCOLLATE_CC=config/locale/collate_members_generic.cc
|
||||
CCTYPE_CC=config/locale/ctype_members_generic.cc
|
||||
CMESSAGES_H=config/locale/messages_members_generic.h
|
||||
CMESSAGES_CC=config/locale/messages_members_generic.cc
|
||||
CMONEY_CC=config/locale/moneypunct_members_generic.cc
|
||||
@ -1100,6 +1101,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
|
||||
CLOCALE_CC=config/locale/c_locale_gnu.cc
|
||||
CCODECVT_H=config/locale/codecvt_specializations_ieee_1003.1-200x.h
|
||||
CCOLLATE_CC=config/locale/collate_members_gnu.cc
|
||||
CCTYPE_CC=config/locale/ctype_members_gnu.cc
|
||||
CMESSAGES_H=config/locale/messages_members_gnu.h
|
||||
CMESSAGES_CC=config/locale/messages_members_gnu.cc
|
||||
CMONEY_CC=config/locale/moneypunct_members_gnu.cc
|
||||
@ -1116,6 +1118,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
|
||||
CLOCALE_CC=config/locale/c_locale_ieee_1003.1-200x.cc
|
||||
CCODECVT_H=config/locale/codecvt_specializations_ieee_1003.1-200x.h
|
||||
CCOLLATE_CC=config/locale/collate_members_generic.cc
|
||||
CCTYPE_CC=config/locale/ctype_members_generic.cc
|
||||
CMESSAGES_H=config/locale/messages_members_ieee_1003.1-200x.h
|
||||
CMESSAGES_CC=config/locale/messages_members_ieee_1003.1-200x.cc
|
||||
CMONEY_CC=config/locale/moneypunct_members_generic.cc
|
||||
@ -1139,6 +1142,7 @@ AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
|
||||
AC_SUBST(CMESSAGES_H)
|
||||
AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
|
||||
AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
|
||||
AC_LINK_FILES($CCTYPE_CC, src/ctype.cc)
|
||||
AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)
|
||||
AC_LINK_FILES($CMONEY_CC, src/moneypunct.cc)
|
||||
AC_LINK_FILES($CNUMERIC_CC, src/numpunct.cc)
|
||||
|
@ -38,8 +38,8 @@
|
||||
namespace std
|
||||
{
|
||||
void
|
||||
locale::facet::_S_create_c_locale(__c_locale&, const char*)
|
||||
{ }
|
||||
locale::facet::_S_create_c_locale(__c_locale& __cloc, const char*)
|
||||
{ __cloc = NULL; }
|
||||
|
||||
void
|
||||
locale::facet::_S_destroy_c_locale(__c_locale&)
|
||||
|
@ -56,10 +56,7 @@ namespace std
|
||||
|
||||
void
|
||||
locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
|
||||
{
|
||||
if (__cloc)
|
||||
__freelocale(__cloc);
|
||||
}
|
||||
{ __freelocale(__cloc); }
|
||||
|
||||
__c_locale
|
||||
locale::facet::_S_clone_c_locale(__c_locale& __cloc)
|
||||
|
@ -43,46 +43,25 @@ namespace std
|
||||
int
|
||||
collate<char>::_M_compare_helper(const char* __one,
|
||||
const char* __two) const
|
||||
{
|
||||
if (_M_c_locale_collate)
|
||||
return __strcoll_l(__one, __two, _M_c_locale_collate);
|
||||
else
|
||||
return strcoll(__one, __two);
|
||||
}
|
||||
{ return __strcoll_l(__one, __two, _M_c_locale_collate); }
|
||||
|
||||
template<>
|
||||
size_t
|
||||
collate<char>::_M_transform_helper(char* __to, const char* __from,
|
||||
size_t __n) const
|
||||
{
|
||||
if (_M_c_locale_collate)
|
||||
return __strxfrm_l(__to, __from, __n, _M_c_locale_collate);
|
||||
else
|
||||
return strxfrm(__to, __from, __n);
|
||||
}
|
||||
{ return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
|
||||
|
||||
#ifdef _GLIBCPP_USE_WCHAR_T
|
||||
template<>
|
||||
int
|
||||
collate<wchar_t>::_M_compare_helper(const wchar_t* __one,
|
||||
const wchar_t* __two) const
|
||||
{
|
||||
if (_M_c_locale_collate)
|
||||
return __wcscoll_l(__one, __two, _M_c_locale_collate);
|
||||
else
|
||||
return wcscoll(__one, __two);
|
||||
}
|
||||
{ return __wcscoll_l(__one, __two, _M_c_locale_collate); }
|
||||
|
||||
template<>
|
||||
size_t
|
||||
collate<wchar_t>::_M_transform_helper(wchar_t* __to,
|
||||
const wchar_t* __from,
|
||||
collate<wchar_t>::_M_transform_helper(wchar_t* __to, const wchar_t* __from,
|
||||
size_t __n) const
|
||||
{
|
||||
if (_M_c_locale_collate)
|
||||
return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate);
|
||||
else
|
||||
return wcsxfrm(__to, __from, __n);
|
||||
}
|
||||
{ return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
|
||||
#endif
|
||||
}
|
||||
|
195
libstdc++-v3/config/locale/ctype_members_generic.cc
Normal file
195
libstdc++-v3/config/locale/ctype_members_generic.cc
Normal file
@ -0,0 +1,195 @@
|
||||
// std::ctype implementation details, generic version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
//
|
||||
// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
|
||||
//
|
||||
|
||||
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
#include <locale>
|
||||
|
||||
namespace std
|
||||
{
|
||||
// NB: The other ctype<char> specializations are in src/locale.cc and
|
||||
// various /config/os/* files.
|
||||
template<>
|
||||
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
|
||||
: ctype<char>(0, false, __refs)
|
||||
{
|
||||
_S_destroy_c_locale(_M_c_locale_ctype);
|
||||
_S_create_c_locale(_M_c_locale_ctype, __s);
|
||||
}
|
||||
|
||||
#ifdef _GLIBCPP_USE_WCHAR_T
|
||||
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;
|
||||
};
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::do_toupper(wchar_t __c) const
|
||||
{ return towupper(__c); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi)
|
||||
{
|
||||
*__lo = towupper(*__lo);
|
||||
++__lo;
|
||||
}
|
||||
return __hi;
|
||||
}
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::do_tolower(wchar_t __c) const
|
||||
{ return towlower(__c); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi)
|
||||
{
|
||||
*__lo = towlower(*__lo);
|
||||
++__lo;
|
||||
}
|
||||
return __hi;
|
||||
}
|
||||
|
||||
bool
|
||||
ctype<wchar_t>::
|
||||
do_is(mask __m, char_type __c) const
|
||||
{ return static_cast<bool>(iswctype(__c, _M_convert_to_wmask(__m))); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __m) const
|
||||
{
|
||||
while (__lo < __hi && !this->do_is(*__m, *__lo))
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi && !this->do_is(__m, *__lo))
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
|
||||
{
|
||||
while (__lo < __hi && this->do_is(__m, *__lo) != 0)
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::
|
||||
do_widen(char __c) const
|
||||
{ return btowc(__c); }
|
||||
|
||||
const char*
|
||||
ctype<wchar_t>::
|
||||
do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
|
||||
{
|
||||
mbstate_t __state;
|
||||
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
|
||||
mbsrtowcs(__dest, &__lo, __hi - __lo, &__state);
|
||||
return __hi;
|
||||
}
|
||||
|
||||
char
|
||||
ctype<wchar_t>::
|
||||
do_narrow(wchar_t __wc, char __dfault) const
|
||||
{
|
||||
int __c = wctob(__wc);
|
||||
return (__c == EOF ? __dfault : static_cast<char>(__c));
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
|
||||
char* __dest) const
|
||||
{
|
||||
mbstate_t __state;
|
||||
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
|
||||
size_t __len = __hi - __lo;
|
||||
size_t __conv = wcsrtombs(__dest, &__lo, __len, &__state);
|
||||
if (__conv == __len)
|
||||
*__dest = __dfault;
|
||||
return __hi;
|
||||
}
|
||||
#endif // _GLIBCPP_USE_WCHAR_T
|
||||
}
|
200
libstdc++-v3/config/locale/ctype_members_gnu.cc
Normal file
200
libstdc++-v3/config/locale/ctype_members_gnu.cc
Normal file
@ -0,0 +1,200 @@
|
||||
// std::ctype implementation details, GNU version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
//
|
||||
// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
|
||||
//
|
||||
|
||||
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
#include <locale>
|
||||
|
||||
namespace std
|
||||
{
|
||||
// NB: The other ctype<char> specializations are in src/locale.cc and
|
||||
// various /config/os/* files.
|
||||
template<>
|
||||
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
|
||||
: ctype<char>(0, false, __refs)
|
||||
{
|
||||
if (_M_c_locale_ctype)
|
||||
_S_destroy_c_locale(_M_c_locale_ctype);
|
||||
_S_create_c_locale(_M_c_locale_ctype, __s);
|
||||
_M_toupper = _M_c_locale_ctype->__ctype_toupper;
|
||||
_M_tolower = _M_c_locale_ctype->__ctype_tolower;
|
||||
_M_table = _M_c_locale_ctype->__ctype_b;
|
||||
}
|
||||
|
||||
#ifdef _GLIBCPP_USE_WCHAR_T
|
||||
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_l("space", _M_c_locale_ctype);
|
||||
break;
|
||||
case print:
|
||||
__ret = __wctype_l("print", _M_c_locale_ctype);
|
||||
break;
|
||||
case cntrl:
|
||||
__ret = __wctype_l("cntrl", _M_c_locale_ctype);
|
||||
break;
|
||||
case upper:
|
||||
__ret = __wctype_l("upper", _M_c_locale_ctype);
|
||||
break;
|
||||
case lower:
|
||||
__ret = __wctype_l("lower", _M_c_locale_ctype);
|
||||
break;
|
||||
case alpha:
|
||||
__ret = __wctype_l("alpha", _M_c_locale_ctype);
|
||||
break;
|
||||
case digit:
|
||||
__ret = __wctype_l("digit", _M_c_locale_ctype);
|
||||
break;
|
||||
case punct:
|
||||
__ret = __wctype_l("punct", _M_c_locale_ctype);
|
||||
break;
|
||||
case xdigit:
|
||||
__ret = __wctype_l("xdigit", _M_c_locale_ctype);
|
||||
break;
|
||||
case alnum:
|
||||
__ret = __wctype_l("alnum", _M_c_locale_ctype);
|
||||
break;
|
||||
case graph:
|
||||
__ret = __wctype_l("graph", _M_c_locale_ctype);
|
||||
break;
|
||||
default:
|
||||
__ret = 0;
|
||||
}
|
||||
return __ret;
|
||||
};
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::do_toupper(wchar_t __c) const
|
||||
{ return __towupper_l(__c, _M_c_locale_ctype); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi)
|
||||
{
|
||||
*__lo = __towupper_l(*__lo, _M_c_locale_ctype);
|
||||
++__lo;
|
||||
}
|
||||
return __hi;
|
||||
}
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::do_tolower(wchar_t __c) const
|
||||
{ return __towlower_l(__c, _M_c_locale_ctype); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi)
|
||||
{
|
||||
*__lo = __towlower_l(*__lo, _M_c_locale_ctype);
|
||||
++__lo;
|
||||
}
|
||||
return __hi;
|
||||
}
|
||||
|
||||
bool
|
||||
ctype<wchar_t>::
|
||||
do_is(mask __m, char_type __c) const
|
||||
{ return static_cast<bool>(__iswctype_l(__c, _M_convert_to_wmask(__m),
|
||||
_M_c_locale_ctype)); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __m) const
|
||||
{
|
||||
while (__lo < __hi && !this->do_is(*__m, *__lo))
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi && !this->do_is(__m, *__lo))
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
|
||||
{
|
||||
while (__lo < __hi && this->do_is(__m, *__lo) != 0)
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::
|
||||
do_widen(char __c) const
|
||||
{ return btowc(__c); }
|
||||
|
||||
const char*
|
||||
ctype<wchar_t>::
|
||||
do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
|
||||
{
|
||||
mbstate_t __state;
|
||||
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
|
||||
mbsrtowcs(__dest, &__lo, __hi - __lo, &__state);
|
||||
return __hi;
|
||||
}
|
||||
|
||||
char
|
||||
ctype<wchar_t>::
|
||||
do_narrow(wchar_t __wc, char __dfault) const
|
||||
{
|
||||
int __c = wctob(__wc);
|
||||
return (__c == EOF ? __dfault : static_cast<char>(__c));
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
|
||||
char* __dest) const
|
||||
{
|
||||
mbstate_t __state;
|
||||
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
|
||||
size_t __len = __hi - __lo;
|
||||
size_t __conv = wcsrtombs(__dest, &__lo, __len, &__state);
|
||||
if (__conv == __len)
|
||||
*__dest = __dfault;
|
||||
return __hi;
|
||||
}
|
||||
#endif // _GLIBCPP_USE_WCHAR_T
|
||||
}
|
@ -41,10 +41,6 @@
|
||||
{ return this->do_open(__s, __loc); }
|
||||
|
||||
// Virtual member functions.
|
||||
template<typename _CharT>
|
||||
messages<_CharT>::~messages()
|
||||
{ }
|
||||
|
||||
template<typename _CharT>
|
||||
messages<_CharT>::catalog
|
||||
messages<_CharT>::do_open(const basic_string<char>&, const locale&) const
|
||||
|
@ -43,14 +43,6 @@
|
||||
return this->do_open(__s, __loc);
|
||||
}
|
||||
|
||||
// Virtual member functions.
|
||||
template<typename _CharT>
|
||||
messages<_CharT>::~messages()
|
||||
{
|
||||
if (_M_c_locale_messages)
|
||||
_S_destroy_c_locale(_M_c_locale_messages);
|
||||
}
|
||||
|
||||
template<typename _CharT>
|
||||
messages<_CharT>::catalog
|
||||
messages<_CharT>::do_open(const basic_string<char>& __s,
|
||||
|
@ -61,8 +61,7 @@
|
||||
ctype<char>::
|
||||
scan_not(mask __m, const char* __low, const char* __high) const
|
||||
{
|
||||
while (__low < __high
|
||||
&& (_M_table[*__low] & __m) != 0)
|
||||
while (__low < __high && (_M_table[*__low] & __m) != 0)
|
||||
++__low;
|
||||
return __low;
|
||||
}
|
||||
|
@ -43,25 +43,27 @@
|
||||
ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
|
||||
size_t __refs)
|
||||
: __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del),
|
||||
_M_toupper(__cloc ? __cloc->__ctype_toupper : __ctype_toupper),
|
||||
_M_tolower(__cloc ? __cloc->__ctype_tolower : __ctype_tolower),
|
||||
_M_ctable(__ctype_b),
|
||||
_M_table(__table ? __table : (__cloc ? __cloc->__ctype_b : __ctype_b))
|
||||
{ }
|
||||
_M_ctable(__ctype_b)
|
||||
{
|
||||
_M_c_locale_ctype = _S_clone_c_locale(__cloc);
|
||||
_M_toupper = _M_c_locale_ctype->__ctype_toupper;
|
||||
_M_tolower = _M_c_locale_ctype->__ctype_tolower;
|
||||
_M_table = __table ? __table : _M_c_locale_ctype->__ctype_b;
|
||||
}
|
||||
#else
|
||||
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
|
||||
size_t __refs)
|
||||
: __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del),
|
||||
_M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower),
|
||||
_M_ctable(__ctype_b), _M_table(__table ? __table : __ctype_b)
|
||||
{ }
|
||||
{ _M_c_locale_ctype = NULL; }
|
||||
#endif
|
||||
|
||||
ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) :
|
||||
__ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del),
|
||||
_M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower),
|
||||
_M_ctable(__ctype_b), _M_table(__table == 0 ? _M_ctable : __table)
|
||||
{ }
|
||||
{ _M_c_locale_ctype = NULL; }
|
||||
|
||||
char
|
||||
ctype<char>::do_toupper(char __c) const
|
||||
|
1778
libstdc++-v3/configure
vendored
1778
libstdc++-v3/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -227,12 +227,13 @@ namespace std
|
||||
// Types:
|
||||
typedef char char_type;
|
||||
|
||||
private:
|
||||
protected:
|
||||
// Data Members:
|
||||
__c_locale _M_c_locale_ctype;
|
||||
bool _M_del;
|
||||
__to_type const& _M_toupper;
|
||||
__to_type const& _M_tolower;
|
||||
const mask* const& _M_ctable;
|
||||
__to_type _M_toupper;
|
||||
__to_type _M_tolower;
|
||||
const mask* _M_ctable;
|
||||
const mask* _M_table;
|
||||
|
||||
public:
|
||||
@ -259,9 +260,6 @@ namespace std
|
||||
scan_not(mask __m, const char* __lo, const char* __hi) const;
|
||||
|
||||
protected:
|
||||
virtual
|
||||
~ctype();
|
||||
|
||||
const mask*
|
||||
table() const throw()
|
||||
{ return _M_table; }
|
||||
@ -270,6 +268,9 @@ namespace std
|
||||
classic_table() throw()
|
||||
{ return _M_ctable; }
|
||||
|
||||
virtual
|
||||
~ctype();
|
||||
|
||||
virtual bool
|
||||
do_is(mask __m, char_type __c) const;
|
||||
|
||||
@ -323,6 +324,10 @@ namespace std
|
||||
typedef wchar_t char_type;
|
||||
typedef wctype_t __wmask_type;
|
||||
|
||||
protected:
|
||||
__c_locale _M_c_locale_ctype;
|
||||
|
||||
public:
|
||||
// Data Members:
|
||||
static locale::id id;
|
||||
|
||||
@ -395,22 +400,25 @@ namespace std
|
||||
typedef _CharT char_type;
|
||||
|
||||
explicit
|
||||
ctype_byname(const char*, size_t __refs = 0);
|
||||
ctype_byname(const char* __s, size_t __refs = 0);
|
||||
|
||||
protected:
|
||||
virtual
|
||||
~ctype_byname() { }
|
||||
~ctype_byname() { };
|
||||
};
|
||||
|
||||
// 22.2.1.4 Class ctype_byname specialization
|
||||
// 22.2.1.4 Class ctype_byname specializations.
|
||||
template<>
|
||||
ctype_byname<char>::ctype_byname(const char*, size_t refs);
|
||||
|
||||
template<>
|
||||
ctype_byname<wchar_t>::ctype_byname(const char*, size_t refs);
|
||||
|
||||
// 22.2.1.5 Template class codecvt
|
||||
#include <bits/codecvt.h>
|
||||
|
||||
|
||||
// 22.2.2 The numeric category.
|
||||
class __num_base
|
||||
{
|
||||
public:
|
||||
@ -815,17 +823,14 @@ namespace std
|
||||
|
||||
explicit
|
||||
collate(size_t __refs = 0)
|
||||
: locale::facet(__refs), _M_c_locale_collate(NULL)
|
||||
{ }
|
||||
: locale::facet(__refs)
|
||||
{ _M_c_locale_collate = _S_clone_c_locale(_S_c_locale); }
|
||||
|
||||
// Non-standard.
|
||||
explicit
|
||||
collate(__c_locale __cloc, size_t __refs = 0)
|
||||
: locale::facet(__refs)
|
||||
{
|
||||
if (__cloc)
|
||||
_M_c_locale_collate = _S_clone_c_locale(__cloc);
|
||||
}
|
||||
{ _M_c_locale_collate = _S_clone_c_locale(__cloc); }
|
||||
|
||||
int
|
||||
compare(const _CharT* __lo1, const _CharT* __hi1,
|
||||
@ -850,10 +855,7 @@ namespace std
|
||||
protected:
|
||||
virtual
|
||||
~collate()
|
||||
{
|
||||
if (_M_c_locale_collate)
|
||||
_S_destroy_c_locale(_M_c_locale_collate);
|
||||
}
|
||||
{ _S_destroy_c_locale(_M_c_locale_collate); }
|
||||
|
||||
virtual int
|
||||
do_compare(const _CharT* __lo1, const _CharT* __hi1,
|
||||
@ -899,7 +901,10 @@ namespace std
|
||||
explicit
|
||||
collate_byname(const char* __s, size_t __refs = 0)
|
||||
: collate<_CharT>(__refs)
|
||||
{ _S_create_c_locale(_M_c_locale_collate, __s); }
|
||||
{
|
||||
_S_destroy_c_locale(_M_c_locale_collate);
|
||||
_S_create_c_locale(_M_c_locale_collate, __s);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual
|
||||
@ -1609,9 +1614,8 @@ namespace std
|
||||
|
||||
explicit
|
||||
messages(size_t __refs = 0)
|
||||
: locale::facet(__refs), _M_c_locale_messages(NULL),
|
||||
_M_name_messages("C")
|
||||
{ }
|
||||
: locale::facet(__refs), _M_name_messages("C")
|
||||
{ _M_c_locale_messages = _S_clone_c_locale(_S_c_locale); }
|
||||
|
||||
// Non-standard.
|
||||
explicit
|
||||
@ -1619,7 +1623,6 @@ namespace std
|
||||
: locale::facet(__refs)
|
||||
{
|
||||
_M_name_messages = __name;
|
||||
if (__cloc)
|
||||
_M_c_locale_messages = _S_clone_c_locale(__cloc);
|
||||
}
|
||||
|
||||
@ -1641,7 +1644,8 @@ namespace std
|
||||
|
||||
protected:
|
||||
virtual
|
||||
~messages();
|
||||
~messages()
|
||||
{ _S_destroy_c_locale(_M_c_locale_messages); }
|
||||
|
||||
virtual catalog
|
||||
do_open(const basic_string<char>&, const locale&) const;
|
||||
@ -1723,8 +1727,9 @@ namespace std
|
||||
messages_byname(const char* __s, size_t __refs = 0)
|
||||
: messages<_CharT>(__refs)
|
||||
{
|
||||
_S_create_c_locale(_M_c_locale_messages, __s);
|
||||
_M_name_messages = __s;
|
||||
_S_destroy_c_locale(_M_c_locale_messages);
|
||||
_S_create_c_locale(_M_c_locale_messages, __s);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -282,7 +282,10 @@ namespace std
|
||||
|
||||
static inline void
|
||||
_S_initialize()
|
||||
{ if (!_S_classic) classic(); }
|
||||
{
|
||||
if (!_S_classic)
|
||||
classic();
|
||||
}
|
||||
|
||||
static category
|
||||
_S_normalize_category(category);
|
||||
@ -344,7 +347,7 @@ namespace std
|
||||
_Impl(string __name, size_t);
|
||||
~_Impl() throw();
|
||||
|
||||
bool
|
||||
inline bool
|
||||
_M_check_same_name()
|
||||
{
|
||||
bool __ret = true;
|
||||
@ -352,6 +355,7 @@ namespace std
|
||||
__ret &= _M_names[i] == _M_names[i + 1];
|
||||
return __ret;
|
||||
}
|
||||
|
||||
void
|
||||
_M_replace_categories(const _Impl*, category);
|
||||
|
||||
@ -387,11 +391,15 @@ namespace std
|
||||
friend class __enc_traits;
|
||||
|
||||
protected:
|
||||
// Contains data from the underlying "C" library for default "C"
|
||||
// and "POSIX" locales.
|
||||
static __c_locale _S_c_locale;
|
||||
|
||||
explicit
|
||||
facet(size_t __refs = 0) throw();
|
||||
|
||||
virtual
|
||||
~facet() { };
|
||||
~facet();
|
||||
|
||||
static void
|
||||
_S_create_c_locale(__c_locale& __cloc, const char* __s);
|
||||
@ -447,8 +455,7 @@ namespace std
|
||||
public:
|
||||
// NB: This class is always a static data member, and thus can be
|
||||
// counted on to be zero-initialized.
|
||||
// XXX id() : _M_index(0) { }
|
||||
id() { }
|
||||
id();
|
||||
};
|
||||
|
||||
template<typename _Facet>
|
||||
|
@ -60,13 +60,14 @@ INCLUDES = \
|
||||
$(TOPLEVEL_INCLUDES)
|
||||
|
||||
sources = \
|
||||
basic_file.cc bitset.cc c++locale.cc cmath.cc codecvt.cc \
|
||||
complex_io.cc functexcept.cc globals.cc ios.cc limits.cc \
|
||||
locale.cc locale-inst.cc localename.cc \
|
||||
collate.cc messages.cc moneypunct.cc numpunct.cc time.cc \
|
||||
vterminate.cc \
|
||||
misc-inst.cc stdexcept.cc stl-inst.cc string-inst.cc strstream.cc \
|
||||
valarray-inst.cc wstring-inst.cc concept-inst.cc ext-inst.cc
|
||||
globals.cc limits.cc \
|
||||
basic_file.cc complex_io.cc ios.cc strstream.cc \
|
||||
cmath.cc bitset.cc \
|
||||
functexcept.cc stdexcept.cc vterminate.cc \
|
||||
c++locale.cc locale.cc localename.cc codecvt.cc \
|
||||
collate.cc ctype.cc messages.cc moneypunct.cc numpunct.cc time.cc \
|
||||
concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \
|
||||
string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc
|
||||
|
||||
VPATH = $(top_srcdir)/src:$(top_srcdir)
|
||||
|
||||
|
@ -185,13 +185,14 @@ INCLUDES = \
|
||||
|
||||
|
||||
sources = \
|
||||
basic_file.cc bitset.cc c++locale.cc cmath.cc codecvt.cc \
|
||||
complex_io.cc functexcept.cc globals.cc ios.cc limits.cc \
|
||||
locale.cc locale-inst.cc localename.cc \
|
||||
collate.cc messages.cc moneypunct.cc numpunct.cc time.cc \
|
||||
vterminate.cc \
|
||||
misc-inst.cc stdexcept.cc stl-inst.cc string-inst.cc strstream.cc \
|
||||
valarray-inst.cc wstring-inst.cc concept-inst.cc ext-inst.cc
|
||||
globals.cc limits.cc \
|
||||
basic_file.cc complex_io.cc ios.cc strstream.cc \
|
||||
cmath.cc bitset.cc \
|
||||
functexcept.cc stdexcept.cc vterminate.cc \
|
||||
c++locale.cc locale.cc localename.cc codecvt.cc \
|
||||
collate.cc ctype.cc messages.cc moneypunct.cc numpunct.cc time.cc \
|
||||
concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \
|
||||
string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc
|
||||
|
||||
|
||||
VPATH = $(top_srcdir)/src:$(top_srcdir)
|
||||
@ -264,12 +265,12 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I..
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
libstdc___la_OBJECTS = basic_file.lo bitset.lo c++locale.lo cmath.lo \
|
||||
codecvt.lo complex_io.lo functexcept.lo globals.lo ios.lo limits.lo \
|
||||
locale.lo locale-inst.lo localename.lo collate.lo messages.lo \
|
||||
moneypunct.lo numpunct.lo time.lo vterminate.lo misc-inst.lo \
|
||||
stdexcept.lo stl-inst.lo string-inst.lo strstream.lo valarray-inst.lo \
|
||||
wstring-inst.lo concept-inst.lo ext-inst.lo
|
||||
libstdc___la_OBJECTS = globals.lo limits.lo basic_file.lo complex_io.lo \
|
||||
ios.lo strstream.lo cmath.lo bitset.lo functexcept.lo stdexcept.lo \
|
||||
vterminate.lo c++locale.lo locale.lo localename.lo codecvt.lo \
|
||||
collate.lo ctype.lo messages.lo moneypunct.lo numpunct.lo time.lo \
|
||||
concept-inst.lo locale-inst.lo misc-inst.lo stl-inst.lo string-inst.lo \
|
||||
wstring-inst.lo valarray-inst.lo ext-inst.lo
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
|
@ -348,9 +348,18 @@ namespace std
|
||||
return __ret;
|
||||
}
|
||||
|
||||
__c_locale
|
||||
locale::facet::_S_c_locale;
|
||||
|
||||
locale::facet::
|
||||
~facet() { }
|
||||
|
||||
locale::facet::
|
||||
facet(size_t __refs) throw() : _M_references(__refs)
|
||||
{ }
|
||||
{
|
||||
if (!_S_c_locale)
|
||||
_S_create_c_locale(_S_c_locale, "C");
|
||||
}
|
||||
|
||||
void
|
||||
locale::facet::
|
||||
@ -370,6 +379,8 @@ namespace std
|
||||
}
|
||||
}
|
||||
|
||||
locale::id::id() { }
|
||||
|
||||
// Definitions for static const data members of ctype_base.
|
||||
const ctype_base::mask ctype_base::space;
|
||||
const ctype_base::mask ctype_base::print;
|
||||
@ -389,7 +400,12 @@ namespace std
|
||||
const size_t ctype<char>::table_size;
|
||||
|
||||
ctype<char>::~ctype()
|
||||
{ if (_M_del) delete[] this->table(); }
|
||||
{
|
||||
if (_M_c_locale_ctype)
|
||||
_S_destroy_c_locale(_M_c_locale_ctype);
|
||||
if (_M_del)
|
||||
delete[] this->table();
|
||||
}
|
||||
|
||||
// These are dummy placeholders as these virtual functions are never called.
|
||||
bool
|
||||
@ -431,171 +447,26 @@ namespace std
|
||||
return __hi;
|
||||
}
|
||||
|
||||
template<>
|
||||
ctype_byname<char>::ctype_byname(const char* /*__s*/, size_t __refs)
|
||||
: ctype<char>(new mask[table_size], true, __refs)
|
||||
{ }
|
||||
|
||||
#ifdef _GLIBCPP_USE_WCHAR_T
|
||||
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;
|
||||
};
|
||||
|
||||
ctype<wchar_t>::~ctype() { }
|
||||
|
||||
// NB: These ctype<wchar_t> methods are not configuration-specific,
|
||||
// unlike the ctype<char> bits.
|
||||
ctype<wchar_t>::ctype(size_t __refs)
|
||||
: __ctype_abstract_base<wchar_t>(__refs) { }
|
||||
: __ctype_abstract_base<wchar_t>(__refs)
|
||||
{ _M_c_locale_ctype = _S_clone_c_locale(_S_c_locale); }
|
||||
|
||||
ctype<wchar_t>::ctype(__c_locale /*__cloc*/, size_t __refs)
|
||||
: __ctype_abstract_base<wchar_t>(__refs) { }
|
||||
ctype<wchar_t>::ctype(__c_locale __cloc, size_t __refs)
|
||||
: __ctype_abstract_base<wchar_t>(__refs)
|
||||
{ _M_c_locale_ctype = _S_clone_c_locale(__cloc); }
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::do_toupper(wchar_t __c) const
|
||||
{ return towupper(__c); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi)
|
||||
{
|
||||
*__lo = towupper(*__lo);
|
||||
++__lo;
|
||||
}
|
||||
return __hi;
|
||||
}
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::do_tolower(wchar_t __c) const
|
||||
{ return towlower(__c); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi)
|
||||
{
|
||||
*__lo = towlower(*__lo);
|
||||
++__lo;
|
||||
}
|
||||
return __hi;
|
||||
}
|
||||
|
||||
bool
|
||||
ctype<wchar_t>::
|
||||
do_is(mask __m, char_type __c) const
|
||||
{ return static_cast<bool>(iswctype(__c, _M_convert_to_wmask(__m))); }
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __m) const
|
||||
{
|
||||
while (__lo < __hi && !this->is(*__m, *__lo))
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
|
||||
{
|
||||
while (__lo < __hi && !this->is(__m, *__lo))
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
|
||||
{
|
||||
while (__lo < __hi && this->is(__m, *__lo) != 0)
|
||||
++__lo;
|
||||
return __lo;
|
||||
}
|
||||
|
||||
wchar_t
|
||||
ctype<wchar_t>::
|
||||
do_widen(char __c) const
|
||||
{ return btowc(__c); }
|
||||
|
||||
const char*
|
||||
ctype<wchar_t>::
|
||||
do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
|
||||
{
|
||||
mbstate_t __state;
|
||||
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
|
||||
mbsrtowcs(__dest, &__lo, __hi - __lo, &__state);
|
||||
return __hi;
|
||||
}
|
||||
|
||||
char
|
||||
ctype<wchar_t>::
|
||||
do_narrow(wchar_t __wc, char __dfault) const
|
||||
{
|
||||
int __c = wctob(__wc);
|
||||
return (__c == EOF ? __dfault : static_cast<char>(__c));
|
||||
}
|
||||
|
||||
const wchar_t*
|
||||
ctype<wchar_t>::
|
||||
do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
|
||||
char* __dest) const
|
||||
{
|
||||
mbstate_t __state;
|
||||
memset(static_cast<void*>(&__state), 0, sizeof(mbstate_t));
|
||||
size_t __len = __hi - __lo;
|
||||
size_t __conv = wcsrtombs(__dest, &__lo, __len, &__state);
|
||||
if (__conv == __len)
|
||||
*__dest = __dfault;
|
||||
return __hi;
|
||||
}
|
||||
ctype<wchar_t>::~ctype()
|
||||
{ _S_destroy_c_locale(_M_c_locale_ctype); }
|
||||
|
||||
template<>
|
||||
ctype_byname<wchar_t>::
|
||||
ctype_byname(const char* /*__s*/, size_t __refs)
|
||||
: ctype<wchar_t>(__refs) { }
|
||||
#endif // _GLIBCPP_USE_WCHAR_T
|
||||
ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
|
||||
: ctype<wchar_t>(__refs)
|
||||
{
|
||||
_S_destroy_c_locale(_M_c_locale_ctype);
|
||||
_S_create_c_locale(_M_c_locale_ctype, __s);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Definitions for static const data members of time_base
|
||||
template<>
|
||||
@ -708,12 +579,12 @@ namespace std
|
||||
}
|
||||
|
||||
template<>
|
||||
moneypunct_byname<char, false>::moneypunct_byname(const char* /*__s*/,
|
||||
moneypunct_byname<char, false>::moneypunct_byname(const char*,
|
||||
size_t __refs)
|
||||
: moneypunct<char, false>(__refs) { }
|
||||
|
||||
template<>
|
||||
moneypunct_byname<char, true>::moneypunct_byname(const char* /*__s*/,
|
||||
moneypunct_byname<char, true>::moneypunct_byname(const char*,
|
||||
size_t __refs)
|
||||
: moneypunct<char, true>(__refs) { }
|
||||
} // namespace std
|
||||
|
@ -72,10 +72,15 @@ namespace std
|
||||
{
|
||||
// Initialize the underlying locale model, which also checks to
|
||||
// see if the given name is valid.
|
||||
__c_locale __cloc = NULL;
|
||||
if (__str != "C" && __str != "POSIX")
|
||||
__c_locale __cloc;
|
||||
locale::facet::_S_create_c_locale(__cloc, __str.c_str());
|
||||
|
||||
// This is needed as presently "C" locales != required data in
|
||||
// __timepunct, numpunct, and moneypunct.
|
||||
__c_locale __cloc_c = NULL;
|
||||
if (__str != "C" && __str != "POSIX")
|
||||
__cloc_c = __cloc;
|
||||
|
||||
// Allocate facet container.
|
||||
try
|
||||
{ _M_facets = new __vec_facet(_S_num_facets, NULL); }
|
||||
@ -90,18 +95,17 @@ namespace std
|
||||
_M_names[i] = __str;
|
||||
|
||||
// Construct all standard facets and add them to _M_facets.
|
||||
// XXX How to deal cleanly, consistently with null ("C") __cloc?
|
||||
_M_init_facet(new std::collate<char>(__cloc));
|
||||
_M_init_facet(new std::ctype<char>(__cloc));
|
||||
_M_init_facet(new codecvt<char, char, mbstate_t>);
|
||||
_M_init_facet(new moneypunct<char, false>(__cloc));
|
||||
_M_init_facet(new moneypunct<char, true>(__cloc));
|
||||
_M_init_facet(new moneypunct<char, false>(__cloc_c));
|
||||
_M_init_facet(new moneypunct<char, true>(__cloc_c));
|
||||
_M_init_facet(new money_get<char>);
|
||||
_M_init_facet(new money_put<char>);
|
||||
_M_init_facet(new numpunct<char>(__cloc));
|
||||
_M_init_facet(new numpunct<char>(__cloc_c));
|
||||
_M_init_facet(new num_get<char>);
|
||||
_M_init_facet(new num_put<char>);
|
||||
_M_init_facet(new __timepunct<char>(__cloc, __str.c_str()));
|
||||
_M_init_facet(new __timepunct<char>(__cloc_c, __str.c_str()));
|
||||
_M_init_facet(new time_get<char>);
|
||||
_M_init_facet(new time_put<char>);
|
||||
_M_init_facet(new std::messages<char>(__cloc, __str.c_str()));
|
||||
@ -110,14 +114,14 @@ namespace std
|
||||
_M_init_facet(new std::collate<wchar_t>(__cloc));
|
||||
_M_init_facet(new std::ctype<wchar_t>(__cloc));
|
||||
_M_init_facet(new codecvt<wchar_t, char, mbstate_t>);
|
||||
_M_init_facet(new moneypunct<wchar_t, false>(__cloc));
|
||||
_M_init_facet(new moneypunct<wchar_t, true>(__cloc));
|
||||
_M_init_facet(new moneypunct<wchar_t, false>(__cloc_c));
|
||||
_M_init_facet(new moneypunct<wchar_t, true>(__cloc_c));
|
||||
_M_init_facet(new money_get<wchar_t>);
|
||||
_M_init_facet(new money_put<wchar_t>);
|
||||
_M_init_facet(new numpunct<wchar_t>(__cloc));
|
||||
_M_init_facet(new numpunct<wchar_t>(__cloc_c));
|
||||
_M_init_facet(new num_get<wchar_t>);
|
||||
_M_init_facet(new num_put<wchar_t>);
|
||||
_M_init_facet(new __timepunct<wchar_t>(__cloc, __str.c_str()));
|
||||
_M_init_facet(new __timepunct<wchar_t>(__cloc_c, __str.c_str()));
|
||||
_M_init_facet(new time_get<wchar_t>);
|
||||
_M_init_facet(new time_put<wchar_t>);
|
||||
_M_init_facet(new std::messages<wchar_t>(__cloc, __str.c_str()));
|
||||
|
@ -1,6 +1,6 @@
|
||||
// 2000-09-01 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
// Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2000, 2001 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -92,16 +92,17 @@ void test01()
|
||||
gctype.tolower(c_array, c_array + len);
|
||||
VERIFY( !std::char_traits<char_type>::compare(c_array, strlit02, len - 1) );
|
||||
|
||||
|
||||
#ifdef DEBUG_ASSERT
|
||||
assert(test);
|
||||
#endif
|
||||
}
|
||||
#endif /* !defined(_GLIBCPP_USE_WCHAR_T) */
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
#if _GLIBCPP_USE_WCHAR_T
|
||||
test01();
|
||||
#endif /* !defined(_GLIBCPP_USE_WCHAR_T) */
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// 2 or if it is a class deerived from locale:;facet and containing a
|
||||
// 2 or if it is a class derived from locale:;facet and containing a
|
||||
// publicly-accessible declaration as follows:
|
||||
class gnu_facet: public std::locale::facet
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user