1 /* $NetBSD: src/include/ctype.h,v 1.25 2003/10/22 15:51:18 kleink Exp $ */
2 /* $DragonFly: src/include/ctype.h,v 1.7 2005/05/02 17:41:05 joerg Exp $ */
5 * Copyright (c) 1989 The Regents of the University of California.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed
9 * to the University of California by American Telephone and Telegraph
10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11 * the permission of UNIX System Laboratories, Inc.
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. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * @(#)ctype.h 5.3 (Berkeley) 4/3/91
43 #include <sys/cdefs.h>
44 #include <machine/stdint.h>
55 extern const __uint16_t *__libc_ctype_;
56 extern const __int16_t *__libc_tolower_tab_;
57 extern const __int16_t *__libc_toupper_tab_;
74 #if defined(__XSI_VISIBLE)
81 #if _ISO_C_VISIBLE >= 1999 || _POSIX_VISIBLE >= 200112L || \
87 #define isdigit(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _N))
88 #define islower(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _L))
89 #define isspace(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _S))
90 #define ispunct(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _P))
91 #define isupper(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _U))
92 #define isalpha(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & (_U|_L)))
93 #define isxdigit(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & (_N|_X)))
94 #define isalnum(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & (_U|_L|_N)))
95 #define isprint(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & (_P|_U|_L|_N|_S)))
96 #define isgraph(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & (_P|_U|_L|_N)))
97 #define iscntrl(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _C))
98 #define tolower(c) ((int)((__libc_tolower_tab_ + 1)[(int)(c)]))
99 #define toupper(c) ((int)((__libc_toupper_tab_ + 1)[(int)(c)]))
101 #if defined(__XSI_VISIBLE)
102 #define isascii(c) ((unsigned)(c) <= 0177)
103 #define toascii(c) ((c) & 0177)
104 #define _tolower(c) ((c) - 'A' + 'a')
105 #define _toupper(c) ((c) - 'a' + 'A')
108 #if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 200112L || \
110 #define isblank(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _B))
113 #ifdef _CTYPE_PRIVATE
114 #include <machine/limits.h> /* for CHAR_BIT */
116 #define _CTYPE_NUM_CHARS (1 << CHAR_BIT)
118 #define _CTYPE_ID "DFCTYPE"
121 extern const __uint16_t __libc_C_ctype_[];
122 extern const __int16_t __libc_C_toupper_[];
123 extern const __int16_t __libc_C_tolower_[];
126 #endif /* !_CTYPE_H_ */