annotate lib/c-ctype.c @ 5459:e88a820ff3bb

Add log for human.h, xgetcwd.c (import from coreutils).
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 17 Nov 2004 07:32:27 +0000
parents 4665ee17573f
children a48fb0e98c8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4218
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Character handling in C locale.
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Copyright 2000-2003 Free Software Foundation, Inc.
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 the Free Software Foundation; either version 2 of the License, or
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 (at your option) any later version.
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 along with this program; if not, write to the Free Software
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 /* Specification. */
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #include "c-ctype.h"
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #undef c_isalnum
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #undef c_isalpha
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #undef c_isascii
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #undef c_isblank
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #undef c_iscntrl
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #undef c_isdigit
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #undef c_islower
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 #undef c_isgraph
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #undef c_isprint
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 #undef c_ispunct
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #undef c_isspace
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 #undef c_isupper
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #undef c_isxdigit
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 #undef c_tolower
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 #undef c_toupper
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 /* The function isascii is not locale dependent. Its use in EBCDIC is
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 questionable. */
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 c_isascii (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 {
4219
4665ee17573f Optimization and comments.
Bruno Haible <bruno@clisp.org>
parents: 4218
diff changeset
43 return (c >= 0x00 && c <= 0x7f);
4218
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 c_isalnum (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 #if C_CTYPE_CONSECUTIVE_DIGITS \
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 #if C_CTYPE_ASCII
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 return ((c >= '0' && c <= '9')
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'));
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 return ((c >= '0' && c <= '9')
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 || (c >= 'A' && c <= 'Z')
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 || (c >= 'a' && c <= 'z'));
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 case '0': case '1': case '2': case '3': case '4': case '5':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 case '6': case '7': case '8': case '9':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 case 'Y': case 'Z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 case 'y': case 'z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 c_isalpha (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 #if C_CTYPE_ASCII
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z');
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 case 'Y': case 'Z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 case 'y': case 'z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 c_isblank (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 return (c == ' ' || c == '\t');
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 c_iscntrl (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 #if C_CTYPE_ASCII
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 return ((c & ~0x1f) == 0 || c == 0x7f);
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 case ' ': case '!': case '"': case '#': case '$': case '%':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 case '&': case '\'': case '(': case ')': case '*': case '+':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 case ',': case '-': case '.': case '/':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 case '0': case '1': case '2': case '3': case '4': case '5':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 case '6': case '7': case '8': case '9':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 case ':': case ';': case '<': case '=': case '>': case '?':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 case '@':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 case 'Y': case 'Z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 case '[': case '\\': case ']': case '^': case '_': case '`':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 case 'y': case 'z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 case '{': case '|': case '}': case '~':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 c_isdigit (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 #if C_CTYPE_CONSECUTIVE_DIGITS
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 return (c >= '0' && c <= '9');
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 case '0': case '1': case '2': case '3': case '4': case '5':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 case '6': case '7': case '8': case '9':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168 c_islower (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
169 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
170 #if C_CTYPE_CONSECUTIVE_LOWERCASE
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
171 return (c >= 'a' && c <= 'z');
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
179 case 'y': case 'z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
187 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
188 c_isgraph (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
189 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190 #if C_CTYPE_ASCII
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191 return (c >= '!' && c <= '~');
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195 case '!': case '"': case '#': case '$': case '%': case '&':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 case '\'': case '(': case ')': case '*': case '+': case ',':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 case '-': case '.': case '/':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 case '0': case '1': case '2': case '3': case '4': case '5':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 case '6': case '7': case '8': case '9':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 case ':': case ';': case '<': case '=': case '>': case '?':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 case '@':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 case 'Y': case 'Z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207 case '[': case '\\': case ']': case '^': case '_': case '`':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
211 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 case 'y': case 'z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213 case '{': case '|': case '}': case '~':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
216 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
218 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
222 c_isprint (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
223 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
224 #if C_CTYPE_ASCII
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
225 return (c >= ' ' && c <= '~');
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
228 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
229 case ' ': case '!': case '"': case '#': case '$': case '%':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
230 case '&': case '\'': case '(': case ')': case '*': case '+':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231 case ',': case '-': case '.': case '/':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232 case '0': case '1': case '2': case '3': case '4': case '5':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 case '6': case '7': case '8': case '9':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 case ':': case ';': case '<': case '=': case '>': case '?':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 case '@':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240 case 'Y': case 'Z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 case '[': case '\\': case ']': case '^': case '_': case '`':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
243 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
244 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
245 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
246 case 'y': case 'z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
247 case '{': case '|': case '}': case '~':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
249 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
253 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 c_ispunct (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 #if C_CTYPE_ASCII
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
259 return ((c >= '!' && c <= '~')
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
260 && !((c >= '0' && c <= '9')
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
261 || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')));
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
262 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
263 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
264 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
265 case '!': case '"': case '#': case '$': case '%': case '&':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266 case '\'': case '(': case ')': case '*': case '+': case ',':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267 case '-': case '.': case '/':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268 case ':': case ';': case '<': case '=': case '>': case '?':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 case '@':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 case '[': case '\\': case ']': case '^': case '_': case '`':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271 case '{': case '|': case '}': case '~':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 c_isspace (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
282 return (c == ' ' || c == '\t'
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283 || c == '\n' || c == '\v' || c == '\f' || c == '\r');
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
287 c_isupper (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
288 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
289 #if C_CTYPE_CONSECUTIVE_UPPERCASE
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
290 return (c >= 'A' && c <= 'Z');
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
291 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
294 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
295 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
296 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
297 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
298 case 'Y': case 'Z':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
299 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
300 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
301 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
302 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
303 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
304 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
305
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
306 bool
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
307 c_isxdigit (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
308 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
309 #if C_CTYPE_CONSECUTIVE_DIGITS \
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
310 && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
311 #if C_CTYPE_ASCII
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
312 return ((c >= '0' && c <= '9')
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
313 || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F'));
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
314 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
315 return ((c >= '0' && c <= '9')
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
316 || (c >= 'A' && c <= 'F')
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
317 || (c >= 'a' && c <= 'f'));
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
318 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
319 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
320 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
321 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
322 case '0': case '1': case '2': case '3': case '4': case '5':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
323 case '6': case '7': case '8': case '9':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
324 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
325 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
326 return 1;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
327 default:
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
328 return 0;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
329 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
330 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
331 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
332
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
333 int
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
334 c_tolower (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
335 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
336 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
337 return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c);
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
338 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
339 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
340 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
341 case 'A': return 'a';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
342 case 'B': return 'b';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
343 case 'C': return 'c';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
344 case 'D': return 'd';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
345 case 'E': return 'e';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
346 case 'F': return 'f';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
347 case 'G': return 'g';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
348 case 'H': return 'h';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
349 case 'I': return 'i';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
350 case 'J': return 'j';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
351 case 'K': return 'k';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
352 case 'L': return 'l';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
353 case 'M': return 'm';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
354 case 'N': return 'n';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
355 case 'O': return 'o';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
356 case 'P': return 'p';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
357 case 'Q': return 'q';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
358 case 'R': return 'r';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
359 case 'S': return 's';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
360 case 'T': return 't';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
361 case 'U': return 'u';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
362 case 'V': return 'v';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
363 case 'W': return 'w';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
364 case 'X': return 'x';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
365 case 'Y': return 'y';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
366 case 'Z': return 'z';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
367 default: return c;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
368 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
369 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
370 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
371
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
372 int
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
373 c_toupper (int c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
374 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
375 #if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
376 return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
377 #else
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
378 switch (c)
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
379 {
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
380 case 'a': return 'A';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
381 case 'b': return 'B';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
382 case 'c': return 'C';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
383 case 'd': return 'D';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
384 case 'e': return 'E';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
385 case 'f': return 'F';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
386 case 'g': return 'G';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
387 case 'h': return 'H';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
388 case 'i': return 'I';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
389 case 'j': return 'J';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
390 case 'k': return 'K';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
391 case 'l': return 'L';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
392 case 'm': return 'M';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
393 case 'n': return 'N';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
394 case 'o': return 'O';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
395 case 'p': return 'P';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
396 case 'q': return 'Q';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
397 case 'r': return 'R';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
398 case 's': return 'S';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
399 case 't': return 'T';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
400 case 'u': return 'U';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
401 case 'v': return 'V';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
402 case 'w': return 'W';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
403 case 'x': return 'X';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
404 case 'y': return 'Y';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
405 case 'z': return 'Z';
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
406 default: return c;
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
407 }
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
408 #endif
c711c0a14205 New module c-ctype.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
409 }