Debian Codegraph @

include/system/ctype.h

raw
1 // SPDX-License-Identifier: BSD-2-Clause-Patent
2 /*
3 * ctype.h - standard ctype functions
4 */
5 #ifdef SHIM_UNIT_TEST
6 #include_next <ctype.h>
7 #else
8 #ifndef _CTYPE_H
9 #define _CTYPE_H
10
11 #define isprint(c) ((c) >= 0x20 && (c) <= 0x7e)
12
13 /* Determines if a particular character is a decimal-digit character */
14 static inline __attribute__((__unused__)) int
15 isdigit(int c)
16 {
17 //
18 // <digit> ::= [0-9]
19 //
20 return (('0' <= (c)) && ((c) <= '9'));
21 }
22
23 /* Determine if an integer represents character that is a hex digit */
24 static inline __attribute__((__unused__)) int
25 isxdigit(int c)
26 {
27 //
28 // <hexdigit> ::= [0-9] | [a-f] | [A-F]
29 //
30 return ((('0' <= (c)) && ((c) <= '9')) ||
31 (('a' <= (c)) && ((c) <= 'f')) ||
32 (('A' <= (c)) && ((c) <= 'F')));
33 }
34
35 /* Determines if a particular character represents a space character */
36 static inline __attribute__((__unused__)) int
37 isspace(int c)
38 {
39 //
40 // <space> ::= [ ]
41 //
42 return ((c) == ' ');
43 }
44
45 /* Determine if a particular character is an alphanumeric character */
46 static inline __attribute__((__unused__)) int
47 isalnum(int c)
48 {
49 //
50 // <alnum> ::= [0-9] | [a-z] | [A-Z]
51 //
52 return ((('0' <= (c)) && ((c) <= '9')) ||
53 (('a' <= (c)) && ((c) <= 'z')) ||
54 (('A' <= (c)) && ((c) <= 'Z')));
55 }
56
57 /* Determines if a particular character is in upper case */
58 static inline __attribute__((__unused__)) int
59 isupper(int c)
60 {
61 //
62 // <uppercase letter> := [A-Z]
63 //
64 return (('A' <= (c)) && ((c) <= 'Z'));
65 }
66
67 /* Convert character to lowercase */
68 static inline __attribute__((__unused__)) int
69 tolower(int c)
70 {
71 if (('A' <= (c)) && ((c) <= 'Z')) {
72 return (c - ('A' - 'a'));
73 }
74 return (c);
75 }
76
77 static inline __attribute__((__unused__)) int
78 toupper(int c)
79 {
80 return ((c >= 'a' && c <= 'z') ? c - ('a' - 'A') : c);
81 }
82
83 #endif /* !_CTYPE_H */
84 #endif /* !SHIM_UNIT_TEST */
85 // vim:fenc=utf-8:tw=75:noet