1 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005,
2 // 2006, 2007, 2008, 2009
3 // Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
29 _GLIBCXX_BEGIN_NAMESPACE(std
)
31 // Definitions for static const data members of ctype_base.
32 const ctype_base::mask
ctype_base::space
;
33 const ctype_base::mask
ctype_base::print
;
34 const ctype_base::mask
ctype_base::cntrl
;
35 const ctype_base::mask
ctype_base::upper
;
36 const ctype_base::mask
ctype_base::lower
;
37 const ctype_base::mask
ctype_base::alpha
;
38 const ctype_base::mask
ctype_base::digit
;
39 const ctype_base::mask
ctype_base::punct
;
40 const ctype_base::mask
ctype_base::xdigit
;
41 const ctype_base::mask
ctype_base::alnum
;
42 const ctype_base::mask
ctype_base::graph
;
44 // Definitions for locale::id of standard facets that are specialized.
45 locale::id ctype
<char>::id
;
47 #ifdef _GLIBCXX_USE_WCHAR_T
48 locale::id ctype
<wchar_t>::id
;
51 // XXX At some point, just rename this file to ctype_configure_char.cc
52 // and compile it as a separate file instead of including it here.
53 // Platform-specific initialization code for ctype tables.
54 #include <bits/ctype_noninline.h>
56 const size_t ctype
<char>::table_size
;
60 _S_destroy_c_locale(_M_c_locale_ctype
);
62 delete[] this->table();
65 // Fill in the narrowing cache and flag whether all values are
66 // valid or not. _M_narrow_ok is set to 2 if memcpy can't
70 _M_narrow_init() const
72 char __tmp
[sizeof(_M_narrow
)];
73 for (size_t __i
= 0; __i
< sizeof(_M_narrow
); ++__i
)
75 do_narrow(__tmp
, __tmp
+ sizeof(__tmp
), 0, _M_narrow
);
78 if (__builtin_memcmp(__tmp
, _M_narrow
, sizeof(_M_narrow
)))
82 // Deal with the special case of zero: renarrow with a
83 // different default and compare.
85 do_narrow(__tmp
, __tmp
+ 1, 1, &__c
);
95 char __tmp
[sizeof(_M_widen
)];
96 for (size_t __i
= 0; __i
< sizeof(_M_widen
); ++__i
)
98 do_widen(__tmp
, __tmp
+ sizeof(__tmp
), _M_widen
);
101 // Set _M_widen_ok to 2 if memcpy can't be used.
102 if (__builtin_memcmp(__tmp
, _M_widen
, sizeof(_M_widen
)))
106 #ifdef _GLIBCXX_USE_WCHAR_T
107 ctype
<wchar_t>::ctype(size_t __refs
)
108 : __ctype_abstract_base
<wchar_t>(__refs
),
109 _M_c_locale_ctype(_S_get_c_locale()), _M_narrow_ok(false)
110 { _M_initialize_ctype(); }
112 ctype
<wchar_t>::ctype(__c_locale __cloc
, size_t __refs
)
113 : __ctype_abstract_base
<wchar_t>(__refs
),
114 _M_c_locale_ctype(_S_clone_c_locale(__cloc
)), _M_narrow_ok(false)
115 { _M_initialize_ctype(); }
117 ctype
<wchar_t>::~ctype()
118 { _S_destroy_c_locale(_M_c_locale_ctype
); }
120 ctype_byname
<wchar_t>::ctype_byname(const char* __s
, size_t __refs
)
121 : ctype
<wchar_t>(__refs
)
123 if (std::strcmp(__s
, "C") != 0 && std::strcmp(__s
, "POSIX") != 0)
125 this->_S_destroy_c_locale(this->_M_c_locale_ctype
);
126 this->_S_create_c_locale(this->_M_c_locale_ctype
, __s
);
127 this->_M_initialize_ctype();
131 ctype_byname
<wchar_t>::~ctype_byname()
136 _GLIBCXX_END_NAMESPACE