]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Ctype/CClass.c
2 Character classification function implementations for <ctype.h>.
4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 #include <LibConfig.h>
15 #define NO_CTYPE_MACROS // So that we don't define the classification macros
18 /** Internal worker function for character classification.
20 Determines if a character is a member of a set of character classes.
22 @param[in] _c The character to be tested.
23 @param[in] mask A bitmapped specification of the character classes to
24 test the character against. These bits are defined
27 @retval 0 The character, _c, is NOT a member of the character classes specified by mask.
28 @retval nonZero The character, _c, IS a member of a specified character class.
36 return ((_c
< 0 || _c
> 127) ? 0 : (_cClass
[_c
] & mask
));
39 /** The isalnum function tests for any character for which isalpha or isdigit
42 @param[in] c The character to be tested.
44 @return Returns nonzero (true) if and only if the value of the parameter c
45 can be classified as specified in the description of the function.
52 return (__isCClass( c
, (_CD
| _CU
| _CL
| _XA
)));
55 /** The isalpha function tests for any character for which isupper or islower
56 is true, or any character that is one of a locale-specific set of
57 alphabetic characters for which none of iscntrl, isdigit, ispunct, or
58 isspace is true. In the "C" locale, isalpha returns true only for the
59 characters for which isupper or islower is true.
61 @param[in] c The character to be tested.
63 @return Returns nonzero (true) if and only if the value of the parameter c
64 can be classified as specified in the description of the function.
71 return (__isCClass( c
, (_CU
| _CL
| _XA
)));
74 /** The iscntrl function tests for any control character.
76 @param[in] c The character to be tested.
78 @return Returns nonzero (true) if and only if the value of the parameter c
79 can be classified as specified in the description of the function.
86 return (__isCClass( c
, (_CC
)));
89 /** The isdigit function tests for any decimal-digit character.
91 @param[in] c The character to be tested.
93 @return Returns nonzero (true) if and only if the value of the parameter c
94 can be classified as specified in the description of the function.
101 return (__isCClass( c
, (_CD
)));
104 /** The isgraph function tests for any printing character except space (' ').
106 @param[in] c The character to be tested.
108 @return Returns nonzero (true) if and only if the value of the parameter c
109 can be classified as specified in the description of the function.
116 return (__isCClass( c
, (_CG
)));
119 /** The islower function tests for any character that is a lowercase letter or
120 is one of a locale-specific set of characters for which none of iscntrl,
121 isdigit, ispunct, or isspace is true. In the "C" locale, islower returns
122 true only for the lowercase letters.
124 @param[in] c The character to be tested.
126 @return Returns nonzero (true) if and only if the value of the parameter c
127 can be classified as specified in the description of the function.
134 return (__isCClass( c
, (_CL
)));
137 /** The isprint function tests for any printing character including space (' ').
139 @param[in] c The character to be tested.
141 @return Returns nonzero (true) if and only if the value of the parameter c
142 can be classified as specified in the description of the function.
149 return (__isCClass( c
, (_CS
| _CG
)));
152 /** The ispunct function tests for any printing character that is one of a
153 locale-specific set of punctuation characters for which neither isspace nor
154 isalnum is true. In the "C" locale, ispunct returns true for every printing
155 character for which neither isspace nor isalnum is true.
157 @param[in] c The character to be tested.
159 @return Returns nonzero (true) if and only if the value of the parameter c
160 can be classified as specified in the description of the function.
167 return (__isCClass( c
, (_CP
)));
170 /** The isspace function tests for any character that is a standard white-space
171 character or is one of a locale-specific set of characters for which
172 isalnum is false. The standard white-space characters are the following:
173 space (' '), form feed ('\f'), new-line ('\n'), carriage return ('\r'),
174 horizontal tab ('\t'), and vertical tab ('\v'). In the "C" locale, isspace
175 returns true only for the standard white-space characters.
177 @param[in] c The character to be tested.
179 @return Returns nonzero (true) if and only if the value of the parameter c
180 can be classified as specified in the description of the function.
187 return (__isCClass( c
, (_CW
)));
190 /** The isupper function tests for any character that is an uppercase letter or
191 is one of a locale-specific set of characters for which none of iscntrl,
192 isdigit, ispunct, or isspace is true. In the "C" locale, isupper returns
193 true only for the uppercase letters.
195 @param[in] c The character to be tested.
197 @return Returns nonzero (true) if and only if the value of the parameter c
198 can be classified as specified in the description of the function.
205 return (__isCClass( c
, (_CU
)));
208 /** The isxdigit function tests for any hexadecimal-digit character.
210 @param[in] c The character to be tested.
212 @return Returns nonzero (true) if and only if the value of the parameter c
213 can be classified as specified in the description of the function.
220 return (__isCClass( c
, (_CD
| _CX
)));
223 /** The isblank function tests that a character is a white-space character that results
224 in a number of space (' ') characters being sent to the output device. In the C locale
225 this is either ' ' or '\t'.
227 @param[in] c The character to be tested.
229 @return Returns nonzero (true) if and only if the value of the parameter c
230 can be classified as specified in the description of the function.
237 return (__isCClass( c
, (_CB
)));
240 /** The isascii function tests that a character is one of the 128 7-bit ASCII characters.
242 @param[in] c The character to test.
244 @return Returns nonzero (true) if c is a valid ASCII character. Otherwize,
245 zero (false) is returned.
252 return ((c
>= 0) && (c
< 128));
255 /** Test whether a character is one of the characters used as a separator
256 between directory elements in a path.
258 Characters are '/', '\\'
260 This non-standard function is unique to this implementation.
262 @param[in] c The character to be tested.
264 @return Returns nonzero (true) if and only if the value of the parameter c
265 can be classified as specified in the description of the function.
270 return (__isCClass( c
, (_C0
)));