1 /* Character handling in C locale.
3 Copyright 2000-2003, 2006 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
22 #define NO_C_CTYPE_MACROS
25 /* The function isascii is not locale dependent. Its use in EBCDIC is
30 return (c
>= 0x00 && c
<= 0x7f);
36 #if C_CTYPE_CONSECUTIVE_DIGITS \
37 && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
39 return ((c
>= '0' && c
<= '9')
40 || ((c
& ~0x20) >= 'A' && (c
& ~0x20) <= 'Z'));
42 return ((c
>= '0' && c
<= '9')
43 || (c
>= 'A' && c
<= 'Z')
44 || (c
>= 'a' && c
<= 'z'));
49 case '0': case '1': case '2': case '3': case '4': case '5':
50 case '6': case '7': case '8': case '9':
51 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
52 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
53 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
54 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
56 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
57 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
58 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
59 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
71 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
73 return ((c
& ~0x20) >= 'A' && (c
& ~0x20) <= 'Z');
75 return ((c
>= 'A' && c
<= 'Z') || (c
>= 'a' && c
<= 'z'));
80 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
81 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
82 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
83 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
85 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
86 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
87 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
88 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
100 return (c
== ' ' || c
== '\t');
107 return ((c
& ~0x1f) == 0 || c
== 0x7f);
111 case ' ': case '!': case '"': case '#': case '$': case '%':
112 case '&': case '\'': case '(': case ')': case '*': case '+':
113 case ',': case '-': case '.': case '/':
114 case '0': case '1': case '2': case '3': case '4': case '5':
115 case '6': case '7': case '8': case '9':
116 case ':': case ';': case '<': case '=': case '>': case '?':
118 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
119 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
120 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
121 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
123 case '[': case '\\': case ']': case '^': case '_': case '`':
124 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
125 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
126 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
127 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
129 case '{': case '|': case '}': case '~':
140 #if C_CTYPE_CONSECUTIVE_DIGITS
141 return (c
>= '0' && c
<= '9');
145 case '0': case '1': case '2': case '3': case '4': case '5':
146 case '6': case '7': case '8': case '9':
157 #if C_CTYPE_CONSECUTIVE_LOWERCASE
158 return (c
>= 'a' && c
<= 'z');
162 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
163 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
164 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
165 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
178 return (c
>= '!' && c
<= '~');
182 case '!': case '"': case '#': case '$': case '%': case '&':
183 case '\'': case '(': case ')': case '*': case '+': case ',':
184 case '-': case '.': case '/':
185 case '0': case '1': case '2': case '3': case '4': case '5':
186 case '6': case '7': case '8': case '9':
187 case ':': case ';': case '<': case '=': case '>': case '?':
189 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
190 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
191 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
192 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
194 case '[': case '\\': case ']': case '^': case '_': case '`':
195 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
196 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
197 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
198 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
200 case '{': case '|': case '}': case '~':
212 return (c
>= ' ' && c
<= '~');
216 case ' ': case '!': case '"': case '#': case '$': case '%':
217 case '&': case '\'': case '(': case ')': case '*': case '+':
218 case ',': case '-': case '.': case '/':
219 case '0': case '1': case '2': case '3': case '4': case '5':
220 case '6': case '7': case '8': case '9':
221 case ':': case ';': case '<': case '=': case '>': case '?':
223 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
224 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
225 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
226 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
228 case '[': case '\\': case ']': case '^': case '_': case '`':
229 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
230 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
231 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
232 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
234 case '{': case '|': case '}': case '~':
246 return ((c
>= '!' && c
<= '~')
247 && !((c
>= '0' && c
<= '9')
248 || ((c
& ~0x20) >= 'A' && (c
& ~0x20) <= 'Z')));
252 case '!': case '"': case '#': case '$': case '%': case '&':
253 case '\'': case '(': case ')': case '*': case '+': case ',':
254 case '-': case '.': case '/':
255 case ':': case ';': case '<': case '=': case '>': case '?':
257 case '[': case '\\': case ']': case '^': case '_': case '`':
258 case '{': case '|': case '}': case '~':
269 return (c
== ' ' || c
== '\t'
270 || c
== '\n' || c
== '\v' || c
== '\f' || c
== '\r');
276 #if C_CTYPE_CONSECUTIVE_UPPERCASE
277 return (c
>= 'A' && c
<= 'Z');
281 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
282 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
283 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
284 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
296 #if C_CTYPE_CONSECUTIVE_DIGITS \
297 && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
299 return ((c
>= '0' && c
<= '9')
300 || ((c
& ~0x20) >= 'A' && (c
& ~0x20) <= 'F'));
302 return ((c
>= '0' && c
<= '9')
303 || (c
>= 'A' && c
<= 'F')
304 || (c
>= 'a' && c
<= 'f'));
309 case '0': case '1': case '2': case '3': case '4': case '5':
310 case '6': case '7': case '8': case '9':
311 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
312 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
323 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
324 return (c
>= 'A' && c
<= 'Z' ? c
- 'A' + 'a' : c
);
328 case 'A': return 'a';
329 case 'B': return 'b';
330 case 'C': return 'c';
331 case 'D': return 'd';
332 case 'E': return 'e';
333 case 'F': return 'f';
334 case 'G': return 'g';
335 case 'H': return 'h';
336 case 'I': return 'i';
337 case 'J': return 'j';
338 case 'K': return 'k';
339 case 'L': return 'l';
340 case 'M': return 'm';
341 case 'N': return 'n';
342 case 'O': return 'o';
343 case 'P': return 'p';
344 case 'Q': return 'q';
345 case 'R': return 'r';
346 case 'S': return 's';
347 case 'T': return 't';
348 case 'U': return 'u';
349 case 'V': return 'v';
350 case 'W': return 'w';
351 case 'X': return 'x';
352 case 'Y': return 'y';
353 case 'Z': return 'z';
362 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
363 return (c
>= 'a' && c
<= 'z' ? c
- 'a' + 'A' : c
);
367 case 'a': return 'A';
368 case 'b': return 'B';
369 case 'c': return 'C';
370 case 'd': return 'D';
371 case 'e': return 'E';
372 case 'f': return 'F';
373 case 'g': return 'G';
374 case 'h': return 'H';
375 case 'i': return 'I';
376 case 'j': return 'J';
377 case 'k': return 'K';
378 case 'l': return 'L';
379 case 'm': return 'M';
380 case 'n': return 'N';
381 case 'o': return 'O';
382 case 'p': return 'P';
383 case 'q': return 'Q';
384 case 'r': return 'R';
385 case 's': return 'S';
386 case 't': return 'T';
387 case 'u': return 'U';
388 case 'v': return 'V';
389 case 'w': return 'W';
390 case 'x': return 'X';
391 case 'y': return 'Y';
392 case 'z': return 'Z';