]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libstdc++-v3/contrib/libstdc++-v3-4.3.3/src/ctype.cc
update
[l4.git] / l4 / pkg / libstdc++-v3 / contrib / libstdc++-v3-4.3.3 / src / ctype.cc
1 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005,
2 // 2006, 2007
3 // Free Software Foundation, Inc.
4 //
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 2, or (at your option)
9 // any later version.
10
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.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING.  If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction.  Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License.  This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 #include <locale>
31 #include <cstdlib>
32 #include <cstring>
33
34 _GLIBCXX_BEGIN_NAMESPACE(std)
35
36   // Definitions for static const data members of ctype_base.
37   const ctype_base::mask ctype_base::space;
38   const ctype_base::mask ctype_base::print;
39   const ctype_base::mask ctype_base::cntrl;
40   const ctype_base::mask ctype_base::upper;
41   const ctype_base::mask ctype_base::lower;
42   const ctype_base::mask ctype_base::alpha;
43   const ctype_base::mask ctype_base::digit;
44   const ctype_base::mask ctype_base::punct;
45   const ctype_base::mask ctype_base::xdigit;
46   const ctype_base::mask ctype_base::alnum;
47   const ctype_base::mask ctype_base::graph;
48
49   // Definitions for locale::id of standard facets that are specialized.
50   locale::id ctype<char>::id;
51
52 #ifdef _GLIBCXX_USE_WCHAR_T  
53   locale::id ctype<wchar_t>::id;
54 #endif
55
56   template<>
57     const ctype<char>&
58     use_facet<ctype<char> >(const locale& __loc)
59     {
60       size_t __i = ctype<char>::id._M_id();
61       const locale::_Impl* __tmp = __loc._M_impl;
62       return static_cast<const ctype<char>&>(*(__tmp->_M_facets[__i]));
63     }
64
65 #ifdef _GLIBCXX_USE_WCHAR_T
66   template<>
67     const ctype<wchar_t>&
68     use_facet<ctype<wchar_t> >(const locale& __loc)
69     {
70       size_t __i = ctype<wchar_t>::id._M_id();
71       const locale::_Impl* __tmp = __loc._M_impl;
72       return static_cast<const ctype<wchar_t>&>(*(__tmp->_M_facets[__i]));
73     }
74 #endif
75
76   // XXX At some point, just rename this file to ctype_configure_char.cc
77   // and compile it as a separate file instead of including it here.
78   // Platform-specific initialization code for ctype tables.
79 #include <bits/ctype_noninline.h>
80
81   const size_t ctype<char>::table_size;
82
83   ctype<char>::~ctype()
84   { 
85     _S_destroy_c_locale(_M_c_locale_ctype);
86     if (_M_del) 
87       delete[] this->table(); 
88   }
89
90 #ifdef _GLIBCXX_USE_WCHAR_T
91   ctype<wchar_t>::ctype(size_t __refs) 
92   : __ctype_abstract_base<wchar_t>(__refs), 
93   _M_c_locale_ctype(_S_get_c_locale()), _M_narrow_ok(false)
94   { _M_initialize_ctype(); }
95
96   ctype<wchar_t>::ctype(__c_locale __cloc, size_t __refs) 
97   : __ctype_abstract_base<wchar_t>(__refs),
98   _M_c_locale_ctype(_S_clone_c_locale(__cloc)), _M_narrow_ok(false)
99   { _M_initialize_ctype(); }
100
101   ctype<wchar_t>::~ctype() 
102   { _S_destroy_c_locale(_M_c_locale_ctype); }
103
104   ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
105   : ctype<wchar_t>(__refs) 
106   {             
107     if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
108       {
109         this->_S_destroy_c_locale(this->_M_c_locale_ctype);
110         this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
111         this->_M_initialize_ctype();
112       }
113   }
114
115   ctype_byname<wchar_t>::~ctype_byname() 
116   { }
117
118 #endif
119
120 _GLIBCXX_END_NAMESPACE