2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
10 * This code is derived from software contributed to Berkeley by
11 * Paul Borman at Krystal Technologies.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * @(#)ctype.h 8.4 (Berkeley) 1/21/94
48 * XXX <runetype.h> brings massive namespace pollution (rune_t and struct
53 #define _A 0x00000100L /* Alpha */
54 #define _C 0x00000200L /* Control */
55 #define _D 0x00000400L /* Digit */
56 #define _G 0x00000800L /* Graph */
57 #define _L 0x00001000L /* Lower */
58 #define _P 0x00002000L /* Punct */
59 #define _S 0x00004000L /* Space */
60 #define _U 0x00008000L /* Upper */
61 #define _X 0x00010000L /* X digit */
62 #define _B 0x00020000L /* Blank */
63 #define _R 0x00040000L /* Print */
64 #define _I 0x00080000L /* Ideogram */
65 #define _T 0x00100000L /* Special */
66 #define _Q 0x00200000L /* Phonogram */
69 int isalnum __P((int));
70 int isalpha __P((int));
71 int iscntrl __P((int));
72 int isdigit __P((int));
73 int isgraph __P((int));
74 int islower __P((int));
75 int isprint __P((int));
76 int ispunct __P((int));
77 int isspace __P((int));
78 int isupper __P((int));
79 int isxdigit __P((int));
80 int tolower __P((int));
81 int toupper __P((int));
83 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
84 int isascii __P((int));
85 int isblank __P((int));
86 int toascii __P((int));
90 #define isalnum(c) __istype((c), (_A|_D))
91 #define isalpha(c) __istype((c), _A)
92 #define iscntrl(c) __istype((c), _C)
93 #define isdigit(c) __isctype((c), _D) /* ANSI -- locale independent */
94 #define isgraph(c) __istype((c), _G)
95 #define islower(c) __istype((c), _L)
96 #define isprint(c) __istype((c), _R)
97 #define ispunct(c) __istype((c), _P)
98 #define isspace(c) __istype((c), _S)
99 #define isupper(c) __istype((c), _U)
100 #define isxdigit(c) __isctype((c), _X) /* ANSI -- locale independent */
101 #define tolower(c) __tolower(c)
102 #define toupper(c) __toupper(c)
104 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
105 #define isascii(c) (((c) & ~0x7F) == 0)
106 #define isblank(c) __istype((c), _B)
107 #define toascii(c) ((c) & 0x7F)
109 /* XXX the following macros are not backed up by functions. */
110 #define digittoint(c) __istype((c), 0xFF)
111 #define ishexnumber(c) __istype((c), _X)
112 #define isideogram(c) __istype((c), _I)
113 #define isnumber(c) __istype((c), _D)
114 #define isphonogram(c) __istype((c), _Q)
115 #define isrune(c) __istype((c), 0xFFFFFF00L)
116 #define isspecial(c) __istype((c), _T)
119 /* See comments in <machine/ansi.h> about _BSD_CT_RUNE_T_. */
121 unsigned long ___runetype __P((_BSD_CT_RUNE_T_));
122 _BSD_CT_RUNE_T_ ___tolower __P((_BSD_CT_RUNE_T_));
123 _BSD_CT_RUNE_T_ ___toupper __P((_BSD_CT_RUNE_T_));
127 * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us
128 * to generate code for extern versions of all our inline functions.
130 #ifdef _EXTERNALIZE_CTYPE_INLINES_
131 #define _USE_CTYPE_INLINE_
137 * Use inline functions if we are allowed to and the compiler supports them.
139 #if !defined(_DONT_USE_CTYPE_INLINE_) && \
140 (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
142 __istype(_BSD_CT_RUNE_T_ _c, unsigned long _f)
144 return (_c < 0 || _c >= _CACHED_RUNES) ? !!(___runetype(_c) & _f) :
145 !!(_CurrentRuneLocale->runetype[_c] & _f);
149 __isctype(_BSD_CT_RUNE_T_ _c, unsigned long _f)
151 return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
152 !!(_DefaultRuneLocale.runetype[_c] & _f);
155 static __inline _BSD_CT_RUNE_T_
156 __toupper(_BSD_CT_RUNE_T_ _c)
158 return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) :
159 _CurrentRuneLocale->mapupper[_c];
162 static __inline _BSD_CT_RUNE_T_
163 __tolower(_BSD_CT_RUNE_T_ _c)
165 return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
166 _CurrentRuneLocale->maplower[_c];
169 #else /* not using inlines */
172 int __istype __P((_BSD_CT_RUNE_T_, unsigned long));
173 int __isctype __P((_BSD_CT_RUNE_T_, unsigned long));
174 _BSD_CT_RUNE_T_ __toupper __P((_BSD_CT_RUNE_T_));
175 _BSD_CT_RUNE_T_ __tolower __P((_BSD_CT_RUNE_T_));
177 #endif /* using inlines */
179 #endif /* !_CTYPE_H_ */