1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
3 * ctype function definitions for NOLIBC
4 * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
7 #ifndef _NOLIBC_CTYPE_H
8 #define _NOLIBC_CTYPE_H
13 * As much as possible, please keep functions alphabetically sorted.
16 static __attribute__((unused))
20 return (unsigned int)c <= 0x7f;
23 static __attribute__((unused))
26 return c == '\t' || c == ' ';
29 static __attribute__((unused))
32 /* 0x00..0x1f, 0x7f */
33 return (unsigned int)c < 0x20 || c == 0x7f;
36 static __attribute__((unused))
39 return (unsigned int)(c - '0') < 10;
42 static __attribute__((unused))
46 return (unsigned int)(c - 0x21) < 0x5e;
49 static __attribute__((unused))
52 return (unsigned int)(c - 'a') < 26;
55 static __attribute__((unused))
59 return (unsigned int)(c - 0x20) < 0x5f;
62 static __attribute__((unused))
65 /* \t is 0x9, \n is 0xA, \v is 0xB, \f is 0xC, \r is 0xD */
66 return ((unsigned int)c == ' ') || (unsigned int)(c - 0x09) < 5;
69 static __attribute__((unused))
72 return (unsigned int)(c - 'A') < 26;
75 static __attribute__((unused))
78 return isdigit(c) || (unsigned int)(c - 'A') < 6 || (unsigned int)(c - 'a') < 6;
81 static __attribute__((unused))
84 return islower(c) || isupper(c);
87 static __attribute__((unused))
90 return isalpha(c) || isdigit(c);
93 static __attribute__((unused))
96 return isgraph(c) && !isalnum(c);
99 /* make sure to include all global symbols */
102 #endif /* _NOLIBC_CTYPE_H */