* target-def.h (TARGET_HAVE_SRODATA_SECTION): New macro.
[official-gcc.git] / include / safe-ctype.h
blobb2ad8490bd0454abadb28f1ad694c6a242bf36f4
1 /* <ctype.h> replacement macros.
3 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4 Contributed by Zack Weinberg <zackw@stanford.edu>.
6 This file is part of the libiberty library.
7 Libiberty is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 Libiberty is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with libiberty; see the file COPYING.LIB. If
19 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* This is a compatible replacement of the standard C library's <ctype.h>
23 with the following properties:
25 - Implements all isxxx() macros required by C99.
26 - Also implements some character classes useful when
27 parsing C-like languages.
28 - Does not change behavior depending on the current locale.
29 - Behaves properly for all values in the range of a signed or
30 unsigned char.
32 To avoid conflicts, this header defines the isxxx functions in upper
33 case, e.g. ISALPHA not isalpha. */
35 #ifndef SAFE_CTYPE_H
36 #define SAFE_CTYPE_H
38 #ifdef isalpha
39 #error "safe-ctype.h and ctype.h may not be used simultaneously"
40 #else
42 /* Categories. */
44 enum {
45 /* In C99 */
46 _sch_isblank = 0x0001, /* space \t */
47 _sch_iscntrl = 0x0002, /* nonprinting characters */
48 _sch_isdigit = 0x0004, /* 0-9 */
49 _sch_islower = 0x0008, /* a-z */
50 _sch_isprint = 0x0010, /* any printing character including ' ' */
51 _sch_ispunct = 0x0020, /* all punctuation */
52 _sch_isspace = 0x0040, /* space \t \n \r \f \v */
53 _sch_isupper = 0x0080, /* A-Z */
54 _sch_isxdigit = 0x0100, /* 0-9A-Fa-f */
56 /* Extra categories useful to cpplib. */
57 _sch_isidst = 0x0200, /* A-Za-z_ */
58 _sch_isvsp = 0x0400, /* \n \r */
59 _sch_isnvsp = 0x0800, /* space \t \f \v \0 */
61 /* Combinations of the above. */
62 _sch_isalpha = _sch_isupper|_sch_islower, /* A-Za-z */
63 _sch_isalnum = _sch_isalpha|_sch_isdigit, /* A-Za-z0-9 */
64 _sch_isidnum = _sch_isidst|_sch_isdigit, /* A-Za-z0-9_ */
65 _sch_isgraph = _sch_isalnum|_sch_ispunct, /* isprint and not space */
66 _sch_iscppsp = _sch_isvsp|_sch_isnvsp, /* isspace + \0 */
67 _sch_isbasic = _sch_isprint|_sch_iscppsp /* basic charset of ISO C
68 (plus ` and @) */
71 /* Character classification. */
72 extern const unsigned short _sch_istable[256];
74 #define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit))
76 #define ISALPHA(c) _sch_test(c, _sch_isalpha)
77 #define ISALNUM(c) _sch_test(c, _sch_isalnum)
78 #define ISBLANK(c) _sch_test(c, _sch_isblank)
79 #define ISCNTRL(c) _sch_test(c, _sch_iscntrl)
80 #define ISDIGIT(c) _sch_test(c, _sch_isdigit)
81 #define ISGRAPH(c) _sch_test(c, _sch_isgraph)
82 #define ISLOWER(c) _sch_test(c, _sch_islower)
83 #define ISPRINT(c) _sch_test(c, _sch_isprint)
84 #define ISPUNCT(c) _sch_test(c, _sch_ispunct)
85 #define ISSPACE(c) _sch_test(c, _sch_isspace)
86 #define ISUPPER(c) _sch_test(c, _sch_isupper)
87 #define ISXDIGIT(c) _sch_test(c, _sch_isxdigit)
89 #define ISIDNUM(c) _sch_test(c, _sch_isidnum)
90 #define ISIDST(c) _sch_test(c, _sch_isidst)
91 #define IS_ISOBASIC(c) _sch_test(c, _sch_isbasic)
92 #define IS_VSPACE(c) _sch_test(c, _sch_isvsp)
93 #define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp)
94 #define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp)
96 /* Character transformation. */
97 extern const unsigned char _sch_toupper[256];
98 extern const unsigned char _sch_tolower[256];
99 #define TOUPPER(c) _sch_toupper[(c) & 0xff]
100 #define TOLOWER(c) _sch_tolower[(c) & 0xff]
102 #endif /* no ctype.h */
103 #endif /* SAFE_CTYPE_H */