2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1989, 1993
27 * The Regents of the University of California. All rights reserved.
28 * (c) UNIX System Laboratories, Inc.
29 * All or some portions of this file are derived from material licensed
30 * to the University of California by American Telephone and Telegraph
31 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
32 * the permission of UNIX System Laboratories, Inc.
34 * This code is derived from software contributed to Berkeley by
35 * Paul Borman at Krystal Technologies.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Berkeley and its contributors.
49 * 4. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * @(#)ctype.h 8.4 (Berkeley) 1/21/94
73 #define _A 0x00000100L /* Alpha */
74 #define _C 0x00000200L /* Control */
75 #define _D 0x00000400L /* Digit */
76 #define _G 0x00000800L /* Graph */
77 #define _L 0x00001000L /* Lower */
78 #define _P 0x00002000L /* Punct */
79 #define _S 0x00004000L /* Space */
80 #define _U 0x00008000L /* Upper */
81 #define _X 0x00010000L /* X digit */
82 #define _B 0x00020000L /* Blank */
83 #define _R 0x00040000L /* Print */
84 #define _I 0x00080000L /* Ideogram */
85 #define _T 0x00100000L /* Special */
86 #define _Q 0x00200000L /* Phonogram */
104 int isalnum
__P((int));
105 int isalpha
__P((int));
106 int iscntrl
__P((int));
107 int isdigit
__P((int));
108 int isgraph
__P((int));
109 int islower
__P((int));
110 int isprint
__P((int));
111 int ispunct
__P((int));
112 int isspace
__P((int));
113 int isupper
__P((int));
114 int isxdigit
__P((int));
115 int tolower
__P((int));
116 int toupper
__P((int));
118 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
119 int digittoint
__P((int));
120 int isascii
__P((int));
121 int isblank
__P((int));
122 int ishexnumber
__P((int));
123 int isideogram
__P((int));
124 int isnumber
__P((int));
125 int isphonogram
__P((int));
126 int isrune
__P((int));
127 int isspecial
__P((int));
128 int toascii
__P((int));
133 #define isalnum(c) __istype((c), (_A|_D))
134 #define isalpha(c) __istype((c), _A)
135 #define iscntrl(c) __istype((c), _C)
136 #define isdigit(c) __isctype((c), _D) /* ANSI -- locale independent */
137 #define isgraph(c) __istype((c), _G)
138 #define islower(c) __istype((c), _L)
139 #define isprint(c) __istype((c), _R)
140 #define ispunct(c) __istype((c), _P)
141 #define isspace(c) __istype((c), _S)
142 #define isupper(c) __istype((c), _U)
143 #define isxdigit(c) __isctype((c), _X) /* ANSI -- locale independent */
144 #define tolower(c) __tolower(c)
145 #define toupper(c) __toupper(c)
147 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
148 #define digittoint(c) __maskrune((c), 0xFF)
149 #define isascii(c) ((c & ~0x7F) == 0)
150 #define isblank(c) __istype((c), _B)
151 #define ishexnumber(c) __istype((c), _X)
152 #define isideogram(c) __istype((c), _I)
153 #define isnumber(c) __istype((c), _D)
154 #define isphonogram(c) __istype((c), _T)
155 #define isrune(c) __istype((c), 0xFFFFFF00L)
156 #define isspecial(c) __istype((c), _Q)
157 #define toascii(c) ((c) & 0x7F)
160 /* See comments in <machine/ansi.h> about _BSD_RUNE_T_. */
162 unsigned long ___runetype
__P((_BSD_CT_RUNE_T_
));
163 _BSD_CT_RUNE_T_ ___tolower
__P((_BSD_CT_RUNE_T_
));
164 _BSD_CT_RUNE_T_ ___toupper
__P((_BSD_CT_RUNE_T_
));
168 * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us
169 * to generate code for extern versions of all our inline functions.
171 #ifdef _EXTERNALIZE_CTYPE_INLINES_
172 #define _USE_CTYPE_INLINE_
178 * Use inline functions if we are allowed to and the compiler supports them.
180 #if !defined(_DONT_USE_CTYPE_INLINE_) && \
181 (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
184 __maskrune(_BSD_CT_RUNE_T_ _c
, unsigned long _f
)
186 return ((_c
< 0 || _c
>= _CACHED_RUNES
) ? ___runetype(_c
) :
187 _CurrentRuneLocale
->runetype
[_c
]) & _f
;
191 __istype(_BSD_CT_RUNE_T_ c
, unsigned long f
)
193 return !!(__maskrune(c
, f
));
196 static __inline _BSD_CT_RUNE_T_
197 __isctype(_BSD_CT_RUNE_T_ _c
, unsigned long _f
)
199 return (_c
< 0 || _c
>= _CACHED_RUNES
) ? 0 :
200 !!(_DefaultRuneLocale
.runetype
[_c
] & _f
);
203 static __inline _BSD_CT_RUNE_T_
204 __toupper(_BSD_CT_RUNE_T_ _c
)
206 return (_c
< 0 || _c
>= _CACHED_RUNES
) ? ___toupper(_c
) :
207 _CurrentRuneLocale
->mapupper
[_c
];
210 static __inline _BSD_CT_RUNE_T_
211 __tolower(_BSD_CT_RUNE_T_ _c
)
213 return (_c
< 0 || _c
>= _CACHED_RUNES
) ? ___tolower(_c
) :
214 _CurrentRuneLocale
->maplower
[_c
];
217 #else /* not using inlines */
220 int __maskrune
__P((_BSD_CT_RUNE_T_
, unsigned long));
221 int __istype
__P((_BSD_CT_RUNE_T_
, unsigned long));
222 int __isctype
__P((_BSD_CT_RUNE_T_
, unsigned long));
223 _BSD_CT_RUNE_T_ __toupper
__P((_BSD_CT_RUNE_T_
));
224 _BSD_CT_RUNE_T_ __tolower
__P((_BSD_CT_RUNE_T_
));
226 #endif /* using inlines */
228 #endif /* !_CTYPE_H_ */