aboutsummaryrefslogtreecommitdiff
path: root/include/musl/ctype.h
diff options
context:
space:
mode:
authorpk33 <pk33@pk33.space>2024-11-01 23:51:15 +0100
committerpk33 <pk33@pk33.space>2024-11-01 23:51:15 +0100
commit294b585994da4427ac98a8353ff41aed5f301d54 (patch)
treeaafcd885c1fe28819ef1a511da5e6344411b5597 /include/musl/ctype.h
parentf0958551b43959174d28b2056f584d2081494e6c (diff)
downloadengine33-294b585994da4427ac98a8353ff41aed5f301d54.tar.gz
Import and fix old code
Diffstat (limited to 'include/musl/ctype.h')
-rw-r--r--include/musl/ctype.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/include/musl/ctype.h b/include/musl/ctype.h
new file mode 100644
index 0000000..32bcef4
--- /dev/null
+++ b/include/musl/ctype.h
@@ -0,0 +1,77 @@
+#ifndef _CTYPE_H
+#define _CTYPE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+
+int isalnum(int);
+int isalpha(int);
+int isblank(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
+int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int tolower(int);
+int toupper(int);
+
+#ifndef __cplusplus
+static __inline int __isspace(int _c)
+{
+ return _c == ' ' || (unsigned)_c-'\t' < 5;
+}
+
+#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26)
+#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)
+#define islower(a) (0 ? islower(a) : ((unsigned)(a)-'a') < 26)
+#define isupper(a) (0 ? isupper(a) : ((unsigned)(a)-'A') < 26)
+#define isprint(a) (0 ? isprint(a) : ((unsigned)(a)-0x20) < 0x5f)
+#define isgraph(a) (0 ? isgraph(a) : ((unsigned)(a)-0x21) < 0x5e)
+#define isspace(a) __isspace(a)
+#endif
+
+
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
+
+#define __NEED_locale_t
+#include <bits/alltypes.h>
+
+int isalnum_l(int, locale_t);
+int isalpha_l(int, locale_t);
+int isblank_l(int, locale_t);
+int iscntrl_l(int, locale_t);
+int isdigit_l(int, locale_t);
+int isgraph_l(int, locale_t);
+int islower_l(int, locale_t);
+int isprint_l(int, locale_t);
+int ispunct_l(int, locale_t);
+int isspace_l(int, locale_t);
+int isupper_l(int, locale_t);
+int isxdigit_l(int, locale_t);
+int tolower_l(int, locale_t);
+int toupper_l(int, locale_t);
+
+int isascii(int);
+int toascii(int);
+#define _tolower(a) ((a)|0x20)
+#define _toupper(a) ((a)&0x5f)
+#ifndef __cplusplus
+#define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)
+#endif
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif