Initial revision
authoreck <none@none>
Wed, 10 May 1989 09:39:49 +0000 (09:39 +0000)
committereck <none@none>
Wed, 10 May 1989 09:39:49 +0000 (09:39 +0000)
lang/cem/libcc.ansi/ctype/ctype.c [new file with mode: 0644]

diff --git a/lang/cem/libcc.ansi/ctype/ctype.c b/lang/cem/libcc.ansi/ctype/ctype.c
new file mode 100644 (file)
index 0000000..7392fc2
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ctype.c - character handling
+ */
+/* $Header$ */
+
+int    isalnum(c) {            /* Alpha numeric character */
+        return  isdigit(c) || isalpha(c);
+}
+
+int    isalpha(c) {            /* Alpha character */
+        return  isupper(c) || islower(c);
+}
+
+int    iscntrl(c) {            /* Control character */
+        return  (c >= 0 && c <= 0x1f) || c == 0x7f;
+}
+
+int    isdigit(c) {            /* Digit character */
+        return  (unsigned)(c - '0') < 10;
+}
+
+int    isgraph(c) {            /* Graphical character */
+        return  isprint(c) && c != ' ';
+}
+
+int    islower(c) {            /* Lower case character */
+        return  (unsigned)(c - 'a') < 26;
+}
+
+int    isprint(c) {            /* Printable character */
+        return  c > ' ' && c < 0x7f;
+}
+
+int    ispunct(c) {            /* Punctuation character */
+        return  isprint(c) && !(c == ' ' || isalnum(c));
+}
+
+int    isspace(c) {            /* Space character */
+        return  c == ' ' || c == '\f' || c == '\n' ||
+               c == '\r' || c == '\t' || c == '\v';
+}
+
+int    isupper(c) {            /* Upper case character */
+       return  (unsigned)(c - 'A') < 26;
+}
+
+int    isxdigit(c) {           /* Hexdecimal digit character */
+       return  isdigit(c) ||
+               (c >= 'A' && c <= 'F') ||
+               (c >= 'a' && c <= 'f');
+}
+
+int    tolower(c) {            /* Convert to lower case character */
+       if (!isupper(c)) return c;
+       else return c - 'A' + 'a';
+}
+
+int    toupper(c) {            /* Convert to upper case character */
+       if (!islower(c)) return c;
+       else return c - 'a' + 'A';
+}