Warning: That file was not part of the compilation database. It may have many parsing errors.
| 1 | /* SPDX-License-Identifier: LGPL-2.1 OR MIT */ |
|---|---|
| 2 | /* |
| 3 | * ctype function definitions for NOLIBC |
| 4 | * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu> |
| 5 | */ |
| 6 | |
| 7 | /* make sure to include all global symbols */ |
| 8 | #include "nolibc.h" |
| 9 | |
| 10 | #ifndef _NOLIBC_CTYPE_H |
| 11 | #define _NOLIBC_CTYPE_H |
| 12 | |
| 13 | #include "std.h" |
| 14 | |
| 15 | /* |
| 16 | * As much as possible, please keep functions alphabetically sorted. |
| 17 | */ |
| 18 | |
| 19 | static __attribute__((unused)) |
| 20 | int isascii(int c) |
| 21 | { |
| 22 | /* 0x00..0x7f */ |
| 23 | return (unsigned int)c <= 0x7f; |
| 24 | } |
| 25 | |
| 26 | static __attribute__((unused)) |
| 27 | int isblank(int c) |
| 28 | { |
| 29 | return c == '\t' || c == ' '; |
| 30 | } |
| 31 | |
| 32 | static __attribute__((unused)) |
| 33 | int iscntrl(int c) |
| 34 | { |
| 35 | /* 0x00..0x1f, 0x7f */ |
| 36 | return (unsigned int)c < 0x20 || c == 0x7f; |
| 37 | } |
| 38 | |
| 39 | static __attribute__((unused)) |
| 40 | int isdigit(int c) |
| 41 | { |
| 42 | return (unsigned int)(c - '0') < 10; |
| 43 | } |
| 44 | |
| 45 | static __attribute__((unused)) |
| 46 | int isgraph(int c) |
| 47 | { |
| 48 | /* 0x21..0x7e */ |
| 49 | return (unsigned int)(c - 0x21) < 0x5e; |
| 50 | } |
| 51 | |
| 52 | static __attribute__((unused)) |
| 53 | int islower(int c) |
| 54 | { |
| 55 | return (unsigned int)(c - 'a') < 26; |
| 56 | } |
| 57 | |
| 58 | static __attribute__((unused)) |
| 59 | int isprint(int c) |
| 60 | { |
| 61 | /* 0x20..0x7e */ |
| 62 | return (unsigned int)(c - 0x20) < 0x5f; |
| 63 | } |
| 64 | |
| 65 | static __attribute__((unused)) |
| 66 | int isspace(int c) |
| 67 | { |
| 68 | /* \t is 0x9, \n is 0xA, \v is 0xB, \f is 0xC, \r is 0xD */ |
| 69 | return ((unsigned int)c == ' ') || (unsigned int)(c - 0x09) < 5; |
| 70 | } |
| 71 | |
| 72 | static __attribute__((unused)) |
| 73 | int isupper(int c) |
| 74 | { |
| 75 | return (unsigned int)(c - 'A') < 26; |
| 76 | } |
| 77 | |
| 78 | static __attribute__((unused)) |
| 79 | int isxdigit(int c) |
| 80 | { |
| 81 | return isdigit(c) || (unsigned int)(c - 'A') < 6 || (unsigned int)(c - 'a') < 6; |
| 82 | } |
| 83 | |
| 84 | static __attribute__((unused)) |
| 85 | int isalpha(int c) |
| 86 | { |
| 87 | return islower(c) || isupper(c); |
| 88 | } |
| 89 | |
| 90 | static __attribute__((unused)) |
| 91 | int isalnum(int c) |
| 92 | { |
| 93 | return isalpha(c) || isdigit(c); |
| 94 | } |
| 95 | |
| 96 | static __attribute__((unused)) |
| 97 | int ispunct(int c) |
| 98 | { |
| 99 | return isgraph(c) && !isalnum(c); |
| 100 | } |
| 101 | |
| 102 | #endif /* _NOLIBC_CTYPE_H */ |
| 103 |
Warning: That file was not part of the compilation database. It may have many parsing errors.
