2 * Copyright (c) 1989 The Regents of the University of California.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #if defined(LIBC_SCCS) && !defined(lint)
31 static char sccsid
[] = "@(#)ctype_.c 5.6 (Berkeley) 6/1/90";
32 #endif /* LIBC_SCCS and not lint */
35 #include "../locale/setlocale.h"
37 #define _CTYPE_DATA_0_127 \
38 _C, _C, _C, _C, _C, _C, _C, _C, \
39 _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, \
40 _C, _C, _C, _C, _C, _C, _C, _C, \
41 _C, _C, _C, _C, _C, _C, _C, _C, \
42 _S|_B, _P, _P, _P, _P, _P, _P, _P, \
43 _P, _P, _P, _P, _P, _P, _P, _P, \
44 _N, _N, _N, _N, _N, _N, _N, _N, \
45 _N, _N, _P, _P, _P, _P, _P, _P, \
46 _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, \
47 _U, _U, _U, _U, _U, _U, _U, _U, \
48 _U, _U, _U, _U, _U, _U, _U, _U, \
49 _U, _U, _U, _P, _P, _P, _P, _P, \
50 _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, \
51 _L, _L, _L, _L, _L, _L, _L, _L, \
52 _L, _L, _L, _L, _L, _L, _L, _L, \
53 _L, _L, _L, _P, _P, _P, _P, _C
55 #define _CTYPE_DATA_128_255 \
56 0, 0, 0, 0, 0, 0, 0, 0, \
57 0, 0, 0, 0, 0, 0, 0, 0, \
58 0, 0, 0, 0, 0, 0, 0, 0, \
59 0, 0, 0, 0, 0, 0, 0, 0, \
60 0, 0, 0, 0, 0, 0, 0, 0, \
61 0, 0, 0, 0, 0, 0, 0, 0, \
62 0, 0, 0, 0, 0, 0, 0, 0, \
63 0, 0, 0, 0, 0, 0, 0, 0, \
64 0, 0, 0, 0, 0, 0, 0, 0, \
65 0, 0, 0, 0, 0, 0, 0, 0, \
66 0, 0, 0, 0, 0, 0, 0, 0, \
67 0, 0, 0, 0, 0, 0, 0, 0, \
68 0, 0, 0, 0, 0, 0, 0, 0, \
69 0, 0, 0, 0, 0, 0, 0, 0, \
70 0, 0, 0, 0, 0, 0, 0, 0, \
71 0, 0, 0, 0, 0, 0, 0, 0
73 #if defined(_MB_CAPABLE)
74 #if defined(_MB_EXTENDED_CHARSETS_ISO)
75 #include "ctype_iso.h"
77 #if defined(_MB_EXTENDED_CHARSETS_WINDOWS)
82 #if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
83 /* No static const on Cygwin since it's referenced and potentially overwritten
84 for compatibility with older applications. */
88 char _ctype_b
[128 + 256] = {
95 /* For backward compatibility */
96 char __EXPORT
*__ctype_ptr__
= DEFAULT_CTYPE_PTR
;
102 .set _ctype_,_ctype_b+127 \n\
109 .set __ctype_,__ctype_b+127 \n\
113 # else /* !__CYGWIN__ */
115 const char _ctype_
[1 + 256] = {
120 # endif /* !__CYGWIN__ */
122 #else /* !ALLOW_NEGATIVE_CTYPE_INDEX */
124 const char _ctype_
[1 + 256] = {
130 #endif /* !ALLOW_NEGATIVE_CTYPE_INDEX */
132 #if defined(_MB_CAPABLE)
133 /* Cygwin has its own implementation which additionally maintains backward
134 compatibility with applications built under older Cygwin releases. */
137 __set_ctype (struct __locale_t
*loc
, const char *charset
)
139 #if defined(_MB_EXTENDED_CHARSETS_ISO) || defined(_MB_EXTENDED_CHARSETS_WINDOWS)
142 char *ctype_ptr
= NULL
;
146 #if defined(_MB_EXTENDED_CHARSETS_ISO)
148 idx
= __iso_8859_index (charset
+ 9);
149 /* The ctype table has a leading ISO-8859-1 element so we have to add
150 1 to the index returned by __iso_8859_index. If __iso_8859_index
151 returns < 0, it's ISO-8859-1. */
156 ctype_ptr
= __ctype_iso
[idx
];
159 #if defined(_MB_EXTENDED_CHARSETS_WINDOWS)
161 idx
= __cp_index (charset
+ 2);
164 ctype_ptr
= __ctype_cp
[idx
];
172 # if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
173 ctype_ptr
= _ctype_b
;
178 # if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
179 loc
->ctype_ptr
= ctype_ptr
+ 127;
181 loc
->ctype_ptr
= ctype_ptr
;
184 #endif /* !__CYGWIN__ */
185 #endif /* _MB_CAPABLE */