Backout the last commit. _S is also true for a few control codes for which
[dragonfly.git] / include / ctype.h
blob4ba0abb845f44c843d7dbbc555b5c0a2795cff4d
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.8 2005/05/06 14:25:17 y0netan1 Exp $ */
4 /*
5 * Copyright (c) 1989 The Regents of the University of California.
6 * All rights reserved.
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
15 * are met:
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
35 * SUCH DAMAGE.
37 * @(#)ctype.h 5.3 (Berkeley) 4/3/91
40 #ifndef _CTYPE_H_
41 #define _CTYPE_H_
43 #include <sys/cdefs.h>
44 #include <machine/stdint.h>
46 #define _U 0x01
47 #define _L 0x02
48 #define _N 0x04
49 #define _S 0x08
50 #define _P 0x10
51 #define _C 0x20
52 #define _X 0x40
53 #define _B 0x80
55 extern const __uint16_t *__libc_ctype_;
56 extern const __int16_t *__libc_tolower_tab_;
57 extern const __int16_t *__libc_toupper_tab_;
59 __BEGIN_DECLS
60 int isalnum(int);
61 int isalpha(int);
62 int iscntrl(int);
63 int isdigit(int);
64 int isgraph(int);
65 int islower(int);
66 int isprint(int);
67 int ispunct(int);
68 int isspace(int);
69 int isupper(int);
70 int isxdigit(int);
71 int tolower(int);
72 int toupper(int);
74 #if defined(__XSI_VISIBLE)
75 int isascii(int);
76 int toascii(int);
77 int _tolower(int);
78 int _toupper(int);
79 #endif
81 #if _ISO_C_VISIBLE >= 1999 || _POSIX_VISIBLE >= 200112L || \
82 __XSI_VISIBLE >= 600
83 int isblank(int);
84 #endif
85 __END_DECLS
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|_B)))
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')
106 #endif
108 #if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 200112L || \
109 __XSI_VISIBLE >= 600
110 #define isblank(c) ((int)((__libc_ctype_ + 1)[(int)(c)] & _B))
111 #endif
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"
119 #define _CTYPE_REV 3
121 extern const __uint16_t __libc_C_ctype_[];
122 extern const __int16_t __libc_C_toupper_[];
123 extern const __int16_t __libc_C_tolower_[];
124 #endif
126 #endif /* !_CTYPE_H_ */