// Copyright (c) 2025, Zak Fenton // Zak Fenton's libc is licensed under the Mulan PSL v2. You can use this // software according to the terms and conditions of the Mulan PSL v2. // You may obtain a copy of Mulan PSL v2 at: // http://license.coscl.org.cn/MulanPSL2 // THIS SOFTWARE IS PROVIDED ON AN “AS IS” BASIS, WITHOUT warranties of // any kind, either express or implied, including but not limited to // non-infringement, merchantability or fit for a particular purpose. // See the Mulan PSL v2 for more details. #include int isspace(int ch) { return (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'); } int isdigit(int ch) { return (ch >= '0') && (ch <= '9'); } int isxdigit(int ch) { return isdigit(ch) || ((ch >= 'a') && (ch <= 'f')) || ((ch >= 'A') && (ch <= 'F')); } int isalpha(int ch) { return ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')); } int isalnum(int ch) { return isalpha(ch) || isdigit(ch); } int isprint(int ch) { return isalnum(ch) || isspace(ch) || ispunct(ch); } int ispunct(int ch) { switch (ch) { case ',': case '<': case '.': case '>': case '/': case '?': case ';': case ':': case '\'': case '\"': case '[': case ']': case '{': case '}': case '`': case '~': case '@': case '#': case '$': case '%': case '^': case '&': case '*': case '(': case ')': case '-': case '_': case '=': case '+': return 1; default: return 0; } } int isupper(int ch) { if (ch >= 'A' && ch <= 'Z') { return 1; } else { return 0; } } int islower(int ch) { if (ch >= 'a' && ch <= 'a') { return 1; } else { return 0; } } int toupper(int ch) { if (ch >= 'a' && ch <= 'z') { return ((int)'A') + (ch - ((int)'a')); } else { return ch; } } int tolower(int ch) { if (ch >= 'A' && ch <= 'Z') { return ((int)'a') + (ch - ((int)'A')); } else { return ch; } } int isascii(int ch) { int ascii = ch & 0x7F; if (ch == ascii) { return 1; } else { return 0; } }