2 * Copyright (c) 1989 The Regents of the University of California.
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 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)ctype.h 5.3 (Berkeley) 4/3/91
35 * $NetBSD: src/include/ctype.h,v 1.25 2003/10/22 15:51:18 kleink Exp $
36 * $DragonFly: src/include/ctype.h,v 1.12 2005/06/27 20:27:35 dillon Exp $
42 #include <sys/cdefs.h>
43 #include <machine/stdint.h>
57 extern const __uint16_t *__libc_ctype_;
58 extern const __int16_t *__libc_tolower_tab_;
59 extern const __int16_t *__libc_toupper_tab_;
76 #if defined(__XSI_VISIBLE)
83 #if _ISO_C_VISIBLE >= 1999 || _POSIX_VISIBLE >= 200112L || \
89 #if !defined(_CTYPE_H_DISABLE_MACROS_)
91 #define isdigit(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _D))
92 #define islower(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _L))
93 #define isspace(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _S))
94 #define ispunct(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _P))
95 #define isupper(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _U))
96 #define isalpha(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _A))
97 #define isxdigit(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _X))
98 #define isalnum(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & (_A|_D)))
99 #define isprint(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _R))
100 #define isgraph(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _G))
101 #define iscntrl(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _C))
102 #define tolower(c) ((int)((__libc_tolower_tab_ + 1)[(int)(c)]))
103 #define toupper(c) ((int)((__libc_toupper_tab_ + 1)[(int)(c)]))
105 #if defined(__XSI_VISIBLE)
106 #define isascii(c) ((unsigned)(c) <= 0177)
107 #define toascii(c) ((c) & 0177)
108 #define _tolower(c) ((c) - 'A' + 'a')
109 #define _toupper(c) ((c) - 'a' + 'A')
112 #if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 200112L || \
114 #define isblank(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _B))
117 #ifdef _CTYPE_PRIVATE
118 #include <machine/limits.h> /* for CHAR_BIT */
120 #define _CTYPE_NUM_CHARS (1 << CHAR_BIT)
122 extern const __uint16_t __libc_C_ctype_[];
123 extern const __int16_t __libc_C_toupper_[];
124 extern const __int16_t __libc_C_tolower_[];
127 #endif /* !_CTYPE_H_DISABLE_MACROS_ */
129 #endif /* !_CTYPE_H_ */