Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. |
||
3 | |||
4 | The GNU C Library is free software; you can redistribute it and/or |
||
5 | modify it under the terms of the GNU Library General Public License as |
||
6 | published by the Free Software Foundation; either version 2 of the |
||
7 | License, or (at your option) any later version. |
||
8 | |||
9 | The GNU C Library is distributed in the hope that it will be useful, |
||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
12 | Library General Public License for more details. |
||
13 | |||
14 | You should have received a copy of the GNU Library General Public |
||
15 | License along with the GNU C Library; see the file COPYING.LIB. If |
||
16 | not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave, |
||
17 | Cambridge, MA 02139, USA. */ |
||
18 | |||
19 | /* |
||
20 | * ANSI Standard 4.3: CHARACTER HANDLING <ctype.h> |
||
21 | */ |
||
22 | |||
23 | #ifndef _CTYPE_H |
||
24 | |||
25 | #define _CTYPE_H 1 |
||
26 | #include <features.h> |
||
27 | |||
28 | __BEGIN_DECLS |
||
29 | |||
30 | /* These are all the characteristics of characters. All the |
||
31 | interdependencies (such as that an alphabetic is an uppercase or a |
||
32 | lowercase) are here. If there get to be more than |
||
33 | (sizeof (unsigned short int) * CHAR_BIT) distinct characteristics, |
||
34 | many things must be changed that use `unsigned short int's. */ |
||
35 | enum |
||
36 | { |
||
37 | _ISupper = 1 << 0, /* UPPERCASE. */ |
||
38 | _ISlower = 1 << 1, /* lowercase. */ |
||
39 | _IScntrl = 1 << 2, /* Control character. */ |
||
40 | _ISdigit = 1 << 3, /* Numeric. */ |
||
41 | _ISspace = 1 << 4, /* Whitespace. */ |
||
42 | _IShex = 1 << 5, /* A - F, a - f. */ |
||
43 | _ISpunct = 1 << 6, /* Punctuation. */ |
||
44 | _NOgraph = 1 << 7, /* Printing but nongraphical. */ |
||
45 | _ISblank = 1 << 8, /* Blank (usually SPC and TAB). */ |
||
46 | _ISalpha = _ISupper | _ISlower, /* Alphabetic. */ |
||
47 | _ISalnum = _ISalpha | _ISdigit, /* Alphanumeric. */ |
||
48 | _ISxdigit = _ISdigit | _IShex, /* Hexadecimal numeric. */ |
||
49 | _ISgraph = _ISalnum | _ISpunct, /* Graphical. */ |
||
50 | _ISprint = _ISgraph | _NOgraph /* Printing. */ |
||
51 | }; |
||
52 | |||
53 | /* These are defined in localeinfo.c. |
||
54 | The declarations here must match those in localeinfo.h. |
||
55 | |||
56 | These point to the second element ([1]) of arrays of size (UCHAR_MAX + 1). |
||
57 | EOF is -1, so [EOF] is the first element of the original array. |
||
58 | ANSI requires that the ctype functions work for `unsigned char' values |
||
59 | and for EOF. The case conversion arrays are of `short int's rather than |
||
60 | `unsigned char's because tolower (EOF) must be EOF, which doesn't fit |
||
61 | into an `unsigned char'. */ |
||
62 | extern __const unsigned short int *__ctype_b; /* Characteristics. */ |
||
63 | extern __const short int *__ctype_tolower; /* Case conversions. */ |
||
64 | extern __const short int *__ctype_toupper; /* Case conversions. */ |
||
65 | |||
66 | #define __isctype(c, type) \ |
||
67 | (__ctype_b[(int) (c)] & (unsigned short int) type) |
||
68 | |||
69 | #define __isascii(c) (((c) & (1 << 7)) == 0) /* If high bit is set. */ |
||
70 | #define __toascii(c) ((c) & 0x7f) /* Mask off high bit. */ |
||
71 | |||
72 | #define __tolower(c) ((int) __ctype_tolower[(int) (c)]) |
||
73 | #define __toupper(c) ((int) __ctype_toupper[(int) (c)]) |
||
74 | |||
75 | #define __exctype(name) extern int name __P ((int)) |
||
76 | |||
77 | /* The following names are all functions: |
||
78 | int isCHARACTERISTIC(int c); |
||
79 | which return nonzero iff C has CHARACTERISTIC. |
||
80 | For the meaning of the characteristic names, see the `enum' above. */ |
||
81 | __exctype (isalnum); |
||
82 | __exctype (isalpha); |
||
83 | __exctype (iscntrl); |
||
84 | __exctype (isdigit); |
||
85 | __exctype (islower); |
||
86 | __exctype (isgraph); |
||
87 | __exctype (isprint); |
||
88 | __exctype (ispunct); |
||
89 | __exctype (isspace); |
||
90 | __exctype (isupper); |
||
91 | __exctype (isxdigit); |
||
92 | |||
93 | #ifdef __USE_GNU |
||
94 | __exctype (isblank); |
||
95 | #endif |
||
96 | |||
97 | |||
98 | /* Return the lowercase version of C. */ |
||
99 | extern int tolower __P ((int __c)); |
||
100 | |||
101 | /* Return the uppercase version of C. */ |
||
102 | extern int toupper __P ((int __c)); |
||
103 | |||
104 | |||
105 | #if defined(__USE_SVID) || defined(__USE_MISC) |
||
106 | |||
107 | /* Return nonzero iff C is in the ASCII set |
||
108 | (i.e., is no more than 7 bits wide). */ |
||
109 | extern int isascii __P ((int __c)); |
||
110 | |||
111 | /* Return the part of C that is in the ASCII set |
||
112 | (i.e., the low-order 7 bits of C). */ |
||
113 | extern int toascii __P ((int __c)); |
||
114 | |||
115 | #endif /* Use SVID or use misc. */ |
||
116 | |||
117 | #ifdef __USE_SVID |
||
118 | /* These are the same as `toupper' and and `tolower'. */ |
||
119 | __exctype (_toupper); |
||
120 | __exctype (_tolower); |
||
121 | #endif |
||
122 | |||
123 | #ifndef __NO_CTYPE |
||
124 | #define isalnum(c) __isctype((c), _ISalnum) |
||
125 | #define isalpha(c) __isctype((c), _ISalpha) |
||
126 | #define iscntrl(c) __isctype((c), _IScntrl) |
||
127 | #define isdigit(c) __isctype((c), _ISdigit) |
||
128 | #define islower(c) __isctype((c), _ISlower) |
||
129 | #define isgraph(c) __isctype((c), _ISgraph) |
||
130 | #define isprint(c) __isctype((c), _ISprint) |
||
131 | #define ispunct(c) __isctype((c), _ISpunct) |
||
132 | #define isspace(c) __isctype((c), _ISspace) |
||
133 | #define isupper(c) __isctype((c), _ISupper) |
||
134 | #define isxdigit(c) __isctype((c), _ISxdigit) |
||
135 | |||
136 | #ifdef __USE_GNU |
||
137 | #define isblank(c) __isctype((c), _ISblank) |
||
138 | #endif |
||
139 | |||
140 | #define tolower(c) __tolower(c) |
||
141 | #define toupper(c) __toupper(c) |
||
142 | |||
143 | #if defined(__USE_SVID) || defined(__USE_MISC) |
||
144 | #define isascii(c) __isascii(c) |
||
145 | #define toascii(c) __toascii(c) |
||
146 | #endif |
||
147 | |||
148 | #endif /* Not __NO_CTYPE. */ |
||
149 | |||
150 | __END_DECLS |
||
151 | |||
152 | #endif /* ctype.h */ |