OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [config/] [os/] [gnu-linux/] [ctype_noninline.h] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 20 jlechner
// Locale support -*- C++ -*-
2
 
3
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
4
// Free Software Foundation, Inc.
5
//
6
// This file is part of the GNU ISO C++ Library.  This library is free
7
// software; you can redistribute it and/or modify it under the
8
// terms of the GNU General Public License as published by the
9
// Free Software Foundation; either version 2, or (at your option)
10
// any later version.
11
 
12
// This library is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
// GNU General Public License for more details.
16
 
17
// You should have received a copy of the GNU General Public License along
18
// with this library; see the file COPYING.  If not, write to the Free
19
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
// USA.
21
 
22
// As a special exception, you may use this file as part of a free software
23
// library without restriction.  Specifically, if other files instantiate
24
// templates or use macros or inline functions from this file, or you compile
25
// this file and link it with other files to produce an executable, this
26
// file does not by itself cause the resulting executable to be covered by
27
// the GNU General Public License.  This exception does not however
28
// invalidate any other reasons why the executable file might be covered by
29
// the GNU General Public License.
30
 
31
//
32
// ISO C++ 14882: 22.1  Locales
33
//
34
 
35
// Information as gleaned from /usr/include/ctype.h
36
 
37
#if _GLIBCXX_C_LOCALE_GNU
38
  const ctype_base::mask*
39
  ctype<char>::classic_table() throw()
40
  { return _S_get_c_locale()->__ctype_b; }
41
#else
42
  const ctype_base::mask*
43
  ctype<char>::classic_table() throw()
44
  {
45
    const ctype_base::mask* __ret;
46
    char* __old = strdup(setlocale(LC_CTYPE, NULL));
47
    setlocale(LC_CTYPE, "C");
48
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
49
    __ret = *__ctype_b_loc();
50
#else
51
    __ret = __ctype_b;
52
#endif
53
    setlocale(LC_CTYPE, __old);
54
    free(__old);
55
    return __ret;
56
  }
57
#endif
58
 
59
#if _GLIBCXX_C_LOCALE_GNU
60
  ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
61
                     size_t __refs)
62
  : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
63
  _M_del(__table != 0 && __del),
64
  _M_toupper(_M_c_locale_ctype->__ctype_toupper),
65
  _M_tolower(_M_c_locale_ctype->__ctype_tolower),
66
  _M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
67
  _M_widen_ok(0), _M_narrow_ok(0)
68
  {
69
    memset(_M_widen, 0, sizeof(_M_widen));
70
    memset(_M_narrow, 0, sizeof(_M_narrow));
71
  }
72
#else
73
  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
74
                     size_t __refs)
75
  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
76
  _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
77
  {
78
    char* __old=strdup(setlocale(LC_CTYPE, NULL));
79
    setlocale(LC_CTYPE, "C");
80
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
81
    _M_toupper = *__ctype_toupper_loc();
82
    _M_tolower = *__ctype_tolower_loc();
83
    _M_table = __table ? __table : *__ctype_b_loc();
84
#else
85
    _M_toupper = __ctype_toupper;
86
    _M_tolower = __ctype_tolower;
87
    _M_table = __table ? __table : __ctype_b;
88
#endif
89
    setlocale(LC_CTYPE, __old);
90
    free(__old);
91
    memset(_M_widen, 0, sizeof(_M_widen));
92
    memset(_M_narrow, 0, sizeof(_M_narrow));
93
  }
94
#endif
95
 
96
#if _GLIBCXX_C_LOCALE_GNU
97
  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
98
  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
99
  _M_del(__table != 0 && __del),
100
  _M_toupper(_M_c_locale_ctype->__ctype_toupper),
101
  _M_tolower(_M_c_locale_ctype->__ctype_tolower),
102
  _M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
103
  _M_widen_ok(0), _M_narrow_ok(0)
104
  {
105
    memset(_M_widen, 0, sizeof(_M_widen));
106
    memset(_M_narrow, 0, sizeof(_M_narrow));
107
  }
108
#else
109
  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
110
  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
111
  _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
112
  {
113
    char* __old=strdup(setlocale(LC_CTYPE, NULL));
114
    setlocale(LC_CTYPE, "C");
115
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
116
    _M_toupper = *__ctype_toupper_loc();
117
    _M_tolower = *__ctype_tolower_loc();
118
    _M_table = __table ? __table : *__ctype_b_loc();
119
#else
120
    _M_toupper = __ctype_toupper;
121
    _M_tolower = __ctype_tolower;
122
    _M_table = __table ? __table : __ctype_b;
123
#endif
124
    setlocale(LC_CTYPE, __old);
125
    free(__old);
126
    memset(_M_widen, 0, sizeof(_M_widen));
127
    memset(_M_narrow, 0, sizeof(_M_narrow));
128
  }
129
#endif
130
 
131
  char
132
  ctype<char>::do_toupper(char __c) const
133
  { return _M_toupper[static_cast<unsigned char>(__c)]; }
134
 
135
  const char*
136
  ctype<char>::do_toupper(char* __low, const char* __high) const
137
  {
138
    while (__low < __high)
139
      {
140
        *__low = _M_toupper[static_cast<unsigned char>(*__low)];
141
        ++__low;
142
      }
143
    return __high;
144
  }
145
 
146
  char
147
  ctype<char>::do_tolower(char __c) const
148
  { return _M_tolower[static_cast<unsigned char>(__c)]; }
149
 
150
  const char*
151
  ctype<char>::do_tolower(char* __low, const char* __high) const
152
  {
153
    while (__low < __high)
154
      {
155
        *__low = _M_tolower[static_cast<unsigned char>(*__low)];
156
        ++__low;
157
      }
158
    return __high;
159
  }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.