commit 05daa1d657c80dba6a7a3ea38ef9d94ac8d718e8
parent 6962e1b6402a3598d11c9600e8c2fcd3642c8037
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 25 Sep 2017 15:33:50 +0200
Merge branch 'master' of ssh://bitreich.org/scm/scc
Diffstat:
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/lib/c/include/ctype.h b/lib/c/include/ctype.h
@@ -28,18 +28,22 @@ extern int toupper(int c);
#define _SP 0x80 /* hard space (0x20) */
extern unsigned char __ctype[];
-
-#define isalnum(c) ((__ctype+1)[(c)] & (_U|_L|_D))
-#define isalpha(c) ((__ctype+1)[(c)] & (_U|_L))
-#define iscntrl(c) ((__ctype+1)[(c)] & (_C))
-#define isdigit(c) ((__ctype+1)[(c)] & (_D))
-#define isgraph(c) ((__ctype+1)[(c)] & (_P|_U|_L|_D))
-#define islower(c) ((__ctype+1)[(c)] & (_L))
-#define isprint(c) ((__ctype+1)[(c)] & (_P|_U|_L|_D|_SP))
-#define ispunct(c) ((__ctype+1)[(c)] & (_P))
-#define isspace(c) ((__ctype+1)[(c)] & (_S))
-#define isupper(c) ((__ctype+1)[(c)] & (_U))
-#define isxdigit(c) ((__ctype+1)[(c)] & (_D|_X))
+extern int __ctmp;
+
+#define isalnum(c) ((__ctype+1)[c] & (_U|_L|_D))
+#define isalpha(c) ((__ctype+1)[c] & (_U|_L))
+#define iscntrl(c) ((__ctype+1)[c] & (_C))
+#define isdigit(c) ((__ctype+1)[c] & (_D))
+#define isgraph(c) ((__ctype+1)[c] & (_P|_U|_L|_D))
+#define islower(c) ((__ctype+1)[c] & (_L))
+#define isprint(c) ((__ctype+1)[c] & (_P|_U|_L|_D|_SP))
+#define ispunct(c) ((__ctype+1)[c] & (_P))
+#define isspace(c) ((__ctype+1)[c] & (_S))
+#define isupper(c) ((__ctype+1)[c] & (_U))
+#define isxdigit(c) ((__ctype+1)[c] & (_D|_X))
+
+#define tolower(c) ((__ctmp=c, isupper(__ctmp) ? __ctmp | 0x20 : __ctmp))
+#define toupper(c) ((__ctmp=c, islower(__ctmp) ? __ctmp & ~0x20 : __ctmp))
#define isascii(c) ((unsigned)(c)<=0x7f)
diff --git a/lib/c/src/ctype.c b/lib/c/src/ctype.c
@@ -2,6 +2,8 @@
#include <ctype.h>
#undef ctype
+int __ctmp;
+
/* __ctype is shifted by one to match EOF */
unsigned char __ctype[257] = {
0, /* EOF */