Remove explicit int casts for the array index. While it doesn't
[dragonfly.git] / include / ctype.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * 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.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
21 *
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
32 * SUCH DAMAGE.
33 *
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.13 2005/07/07 05:55:05 joerg Exp $
37 */
38
39#ifndef _CTYPE_H_
40#define _CTYPE_H_
41
42#include <sys/cdefs.h>
43#include <machine/stdint.h>
44
45#define _U 0x0001
46#define _L 0x0002
47#define _D 0x0004
48#define _S 0x0008
49#define _P 0x0010
50#define _C 0x0020
51#define _X 0x0040
52#define _B 0x0080
53#define _A 0x0100
54#define _G 0x0200
55#define _R 0x0400
56
57extern const __uint16_t *__libc_ctype_;
58extern const __int16_t *__libc_tolower_tab_;
59extern const __int16_t *__libc_toupper_tab_;
60
61__BEGIN_DECLS
62int isalnum(int);
63int isalpha(int);
64int iscntrl(int);
65int isdigit(int);
66int isgraph(int);
67int islower(int);
68int isprint(int);
69int ispunct(int);
70int isspace(int);
71int isupper(int);
72int isxdigit(int);
73int tolower(int);
74int toupper(int);
75
76#if defined(__XSI_VISIBLE)
77int isascii(int);
78int toascii(int);
79int _tolower(int);
80int _toupper(int);
81#endif
82
83#if _ISO_C_VISIBLE >= 1999 || _POSIX_VISIBLE >= 200112L || \
84 __XSI_VISIBLE >= 600
85int isblank(int);
86#endif
87__END_DECLS
88
89#if !defined(_CTYPE_H_DISABLE_MACROS_)
90
91#define isdigit(c) ((int)((__libc_ctype_ + 1)[(c)] & _D))
92#define islower(c) ((int)((__libc_ctype_ + 1)[(c)] & _L))
93#define isspace(c) ((int)((__libc_ctype_ + 1)[(c)] & _S))
94#define ispunct(c) ((int)((__libc_ctype_ + 1)[(c)] & _P))
95#define isupper(c) ((int)((__libc_ctype_ + 1)[(c)] & _U))
96#define isalpha(c) ((int)((__libc_ctype_ + 1)[(c)] & _A))
97#define isxdigit(c) ((int)((__libc_ctype_ + 1)[(c)] & _X))
98#define isalnum(c) ((int)((__libc_ctype_ + 1)[(c)] & (_A|_D)))
99#define isprint(c) ((int)((__libc_ctype_ + 1)[(c)] & _R))
100#define isgraph(c) ((int)((__libc_ctype_ + 1)[(c)] & _G))
101#define iscntrl(c) ((int)((__libc_ctype_ + 1)[(c)] & _C))
102#define tolower(c) ((int)((__libc_tolower_tab_ + 1)[(c)]))
103#define toupper(c) ((int)((__libc_toupper_tab_ + 1)[(c)]))
104
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')
110#endif
111
112#if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 200112L || \
113 __XSI_VISIBLE >= 600
114#define isblank(c) ((int)((__libc_ctype_ + 1)[(c)] & _B))
115#endif
116
117#ifdef _CTYPE_PRIVATE
118#include <machine/limits.h> /* for CHAR_BIT */
119
120#define _CTYPE_NUM_CHARS (1 << CHAR_BIT)
121
122extern const __uint16_t __libc_C_ctype_[];
123extern const __int16_t __libc_C_toupper_[];
124extern const __int16_t __libc_C_tolower_[];
125#endif
126
127#endif /* !_CTYPE_H_DISABLE_MACROS_ */
128
129#endif /* !_CTYPE_H_ */