aboutsummaryrefslogtreecommitdiffstats
path: root/myctype.h
diff options
context:
space:
mode:
Diffstat (limited to 'myctype.h')
-rw-r--r--myctype.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/myctype.h b/myctype.h
new file mode 100644
index 0000000..512e6e8
--- /dev/null
+++ b/myctype.h
@@ -0,0 +1,45 @@
+#ifndef _MYCTYPE_H
+#define _MYCTYPE_H
+
+#define MYCTYPE_CNTRL 1
+#define MYCTYPE_SPACE 2
+#define MYCTYPE_ALPHA 4
+#define MYCTYPE_DIGIT 8
+#define MYCTYPE_PRINT 16
+#define MYCTYPE_ALNUM (MYCTYPE_ALPHA|MYCTYPE_DIGIT)
+
+#define GET_MYCTYPE(x) (MYCTYPE_MAP[(int)(unsigned char)(x)])
+
+#define IS_CNTRL(x) (GET_MYCTYPE(x) & MYCTYPE_CNTRL)
+#define IS_SPACE(x) (GET_MYCTYPE(x) & MYCTYPE_SPACE)
+#define IS_ALPHA(x) (GET_MYCTYPE(x) & MYCTYPE_ALPHA)
+#define IS_DIGIT(x) (GET_MYCTYPE(x) & MYCTYPE_DIGIT)
+#define IS_PRINT(x) (GET_MYCTYPE(x) & MYCTYPE_PRINT)
+#define IS_ALNUM(x) (GET_MYCTYPE(x) & MYCTYPE_ALNUM)
+
+extern unsigned char MYCTYPE_MAP[];
+
+
+#define INTCTYPE_ASCII 1
+#define INTCTYPE_ISPACE 2
+#define INTCTYPE_LATIN1 4
+#define INTCTYPE_KANJI1 8
+#define INTCTYPE_KANJI2 16
+#define INTCTYPE_KANJI (INTCTYPE_KANJI1|INTCTYPE_KANJI2)
+#define INTCTYPE_INTRL INTCTYPE_ISPACE
+
+#define GET_INTCTYPE(x) (INTCTYPE_MAP[(int)(unsigned char)(x)])
+
+#define IS_ASCII(x) (GET_INTCTYPE(x) & INTCTYPE_ASCII)
+#define IS_INTSPACE(x) (GET_INTCTYPE(x) & INTCTYPE_ISPACE)
+#define IS_INTERNAL(x) (GET_INTCTYPE(x) & INTCTYPE_INTRL)
+#define IS_KANJI1(x) (GET_INTCTYPE(x) & INTCTYPE_KANJI1)
+#define IS_KANJI2(x) (GET_INTCTYPE(x) & INTCTYPE_KANJI2)
+#define IS_KANJI(x) (GET_INTCTYPE(x) & INTCTYPE_KANJI)
+#define IS_LATIN1(x) (GET_INTCTYPE(x) & INTCTYPE_LATIN1)
+
+extern unsigned char INTCTYPE_MAP[];
+
+#include <ctype.h>
+
+#endif