ref: 24e2f336e79216f6c8d91a74eb4cdf88a5749434
parent: 8e416b79aff3f1e84d5b6255f3bb3435e3e2352e
parent: fe896e5a49d5d6a1218f3389d2e6ca1a8b7c1228
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Sep 25 11:33:50 EDT 2017
Merge branch 'master' of ssh://bitreich.org/scm/scc
--- a/lib/c/include/ctype.h
+++ b/lib/c/include/ctype.h
@@ -28,18 +28,22 @@
#define _SP 0x80 /* hard space (0x20) */
extern unsigned char __ctype[];
+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 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)
--- 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 */