1 /* Character handling in C locale.
3 Copyright 2000-2003, 2006, 2009-2013 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, see <http://www.gnu.org/licenses/>. */
21 #define NO_C_CTYPE_MACROS
24 /* The function isascii is not locale dependent. Its use in EBCDIC is
29 return (c
>= 0x00 && c
<= 0x7f);
35 #if C_CTYPE_CONSECUTIVE_DIGITS \
36 && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
38 return ((c
>= '0' && c
<= '9')
39 || ((c
& ~0x20) >= 'A' && (c
& ~0x20) <= 'Z'));
41 return ((c
>= '0' && c
<= '9')
42 || (c
>= 'A' && c
<= 'Z')
43 || (c
>= 'a' && c
<= 'z'));
48 case '0': case '1': case '2': case '3': case '4': case '5':
49 case '6': case '7': case '8': case '9':
50 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
51 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
52 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
53 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
55 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
56 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
57 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
58 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
70 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
72 return ((c
& ~0x20) >= 'A' && (c
& ~0x20) <= 'Z');
74 return ((c
>= 'A' && c
<= 'Z') || (c
>= 'a' && c
<= 'z'));
79 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
80 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
81 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
82 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
84 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
85 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
86 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
87 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
99 return (c
== ' ' || c
== '\t');
106 return ((c
& ~0x1f) == 0 || c
== 0x7f);
110 case ' ': case '!': case '"': case '#': case '$': case '%':
111 case '&': case '\'': case '(': case ')': case '*': case '+':
112 case ',': case '-': case '.': case '/':
113 case '0': case '1': case '2': case '3': case '4': case '5':
114 case '6': case '7': case '8': case '9':
115 case ':': case ';': case '<': case '=': case '>': case '?':
117 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
118 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
119 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
120 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
122 case '[': case '\\': case ']': case '^': case '_': case '`':
123 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
124 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
125 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
126 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
128 case '{': case '|': case '}': case '~':
139 #if C_CTYPE_CONSECUTIVE_DIGITS
140 return (c
>= '0' && c
<= '9');
144 case '0': case '1': case '2': case '3': case '4': case '5':
145 case '6': case '7': case '8': case '9':
156 #if C_CTYPE_CONSECUTIVE_LOWERCASE
157 return (c
>= 'a' && c
<= 'z');
161 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
162 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
163 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
164 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
177 return (c
>= '!' && c
<= '~');
181 case '!': case '"': case '#': case '$': case '%': case '&':
182 case '\'': case '(': case ')': case '*': case '+': case ',':
183 case '-': case '.': case '/':
184 case '0': case '1': case '2': case '3': case '4': case '5':
185 case '6': case '7': case '8': case '9':
186 case ':': case ';': case '<': case '=': case '>': case '?':
188 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
189 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
190 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
191 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
193 case '[': case '\\': case ']': case '^': case '_': case '`':
194 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
195 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
196 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
197 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
199 case '{': case '|': case '}': case '~':
211 return (c
>= ' ' && c
<= '~');
215 case ' ': case '!': case '"': case '#': case '$': case '%':
216 case '&': case '\'': case '(': case ')': case '*': case '+':
217 case ',': case '-': case '.': case '/':
218 case '0': case '1': case '2': case '3': case '4': case '5':
219 case '6': case '7': case '8': case '9':
220 case ':': case ';': case '<': case '=': case '>': case '?':
222 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
223 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
224 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
225 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
227 case '[': case '\\': case ']': case '^': case '_': case '`':
228 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
229 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
230 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
231 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
233 case '{': case '|': case '}': case '~':
245 return ((c
>= '!' && c
<= '~')
246 && !((c
>= '0' && c
<= '9')
247 || ((c
& ~0x20) >= 'A' && (c
& ~0x20) <= 'Z')));
251 case '!': case '"': case '#': case '$': case '%': case '&':
252 case '\'': case '(': case ')': case '*': case '+': case ',':
253 case '-': case '.': case '/':
254 case ':': case ';': case '<': case '=': case '>': case '?':
256 case '[': case '\\': case ']': case '^': case '_': case '`':
257 case '{': case '|': case '}': case '~':
268 return (c
== ' ' || c
== '\t'
269 || c
== '\n' || c
== '\v' || c
== '\f' || c
== '\r');
275 #if C_CTYPE_CONSECUTIVE_UPPERCASE
276 return (c
>= 'A' && c
<= 'Z');
280 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
281 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
282 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
283 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
295 #if C_CTYPE_CONSECUTIVE_DIGITS \
296 && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
298 return ((c
>= '0' && c
<= '9')
299 || ((c
& ~0x20) >= 'A' && (c
& ~0x20) <= 'F'));
301 return ((c
>= '0' && c
<= '9')
302 || (c
>= 'A' && c
<= 'F')
303 || (c
>= 'a' && c
<= 'f'));
308 case '0': case '1': case '2': case '3': case '4': case '5':
309 case '6': case '7': case '8': case '9':
310 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
311 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
322 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
323 return (c
>= 'A' && c
<= 'Z' ? c
- 'A' + 'a' : c
);
327 case 'A': return 'a';
328 case 'B': return 'b';
329 case 'C': return 'c';
330 case 'D': return 'd';
331 case 'E': return 'e';
332 case 'F': return 'f';
333 case 'G': return 'g';
334 case 'H': return 'h';
335 case 'I': return 'i';
336 case 'J': return 'j';
337 case 'K': return 'k';
338 case 'L': return 'l';
339 case 'M': return 'm';
340 case 'N': return 'n';
341 case 'O': return 'o';
342 case 'P': return 'p';
343 case 'Q': return 'q';
344 case 'R': return 'r';
345 case 'S': return 's';
346 case 'T': return 't';
347 case 'U': return 'u';
348 case 'V': return 'v';
349 case 'W': return 'w';
350 case 'X': return 'x';
351 case 'Y': return 'y';
352 case 'Z': return 'z';
361 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
362 return (c
>= 'a' && c
<= 'z' ? c
- 'a' + 'A' : c
);
366 case 'a': return 'A';
367 case 'b': return 'B';
368 case 'c': return 'C';
369 case 'd': return 'D';
370 case 'e': return 'E';
371 case 'f': return 'F';
372 case 'g': return 'G';
373 case 'h': return 'H';
374 case 'i': return 'I';
375 case 'j': return 'J';
376 case 'k': return 'K';
377 case 'l': return 'L';
378 case 'm': return 'M';
379 case 'n': return 'N';
380 case 'o': return 'O';
381 case 'p': return 'P';
382 case 'q': return 'Q';
383 case 'r': return 'R';
384 case 's': return 'S';
385 case 't': return 'T';
386 case 'u': return 'U';
387 case 'v': return 'V';
388 case 'w': return 'W';
389 case 'x': return 'X';
390 case 'y': return 'Y';
391 case 'z': return 'Z';