[hackers] [scc] [libc] Don't use _ctype symbol || Roberto E. Vargas Caballero
commit 6bc2930486765b080a04c22fdc380a1f985c67e9
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Mar 8 15:16:26 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Mar 8 15:16:26 2017 +0100
[libc] Don't use _ctype symbol
The tradicional implementation of ctype uses the symbol _ctype,
(for example V7 or plan9 implementations), but _ctype is a
name that can be used by local variables, and they can hide the
symbol used by ctype.h. The best solution is to use the __
namespace, which cannot be used in any case.
diff --git a/libc/include/ctype.h b/libc/include/ctype.h
index 1a8bd6e..e35e14d 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
_AT_@ -28,19 +28,19 @@ extern int toupper(int c);
#define _X 0x40 /* hex char */
#define _SP 0x80 /* hard space (0x20) */
-extern unsigned char _ctype[];
-
-#define isalnum(c) (_ctype[(unsigned char) c] & (_U|_L|_D))
-#define isalpha(c) (_ctype[(unsigned char) c] & (_U|_L))
-#define iscntrl(c) (_ctype[(unsigned char) c] & (_C))
-#define isdigit(c) (_ctype[(unsigned char) c] & (_D))
-#define isgraph(c) (_ctype[(unsigned char) c] & (_P|_U|_L|_D))
-#define islower(c) (_ctype[(unsigned char) c] & (_L))
-#define isprint(c) (_ctype[(unsigned char) c] & (_P|_U|_L|_D|_SP))
-#define ispunct(c) (_ctype[(unsigned char) c] & (_P))
-#define isspace(c) (_ctype[(unsigned char) c] & (_S))
-#define isupper(c) (_ctype[(unsigned char) c] & (_U))
-#define isxdigit(c) (_ctype[(unsigned char) c] & (_D|_X))
+extern unsigned char __ctype[];
+
+#define isalnum(c) (__ctype[(unsigned char) c] & (_U|_L|_D))
+#define isalpha(c) (__ctype[(unsigned char) c] & (_U|_L))
+#define iscntrl(c) (__ctype[(unsigned char) c] & (_C))
+#define isdigit(c) (__ctype[(unsigned char) c] & (_D))
+#define isgraph(c) (__ctype[(unsigned char) c] & (_P|_U|_L|_D))
+#define islower(c) (__ctype[(unsigned char) c] & (_L))
+#define isprint(c) (__ctype[(unsigned char) c] & (_P|_U|_L|_D|_SP))
+#define ispunct(c) (__ctype[(unsigned char) c] & (_P))
+#define isspace(c) (__ctype[(unsigned char) c] & (_S))
+#define isupper(c) (__ctype[(unsigned char) c] & (_U))
+#define isxdigit(c) (__ctype[(unsigned char) c] & (_D|_X))
#define isascii(c) (((unsigned) c)<=0x7f)
diff --git a/libc/src/ctype.c b/libc/src/ctype.c
index 836686a..90d853b 100644
--- a/libc/src/ctype.c
+++ b/libc/src/ctype.c
_AT_@ -4,7 +4,7 @@
#include <ctype.h>
#undef ctype
-unsigned char _ctype[255] = {
+unsigned char __ctype[255] = {
_C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */
_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */
_C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */
diff --git a/libc/src/isalnum.c b/libc/src/isalnum.c
index a2c5a24..474bab4 100644
--- a/libc/src/isalnum.c
+++ b/libc/src/isalnum.c
_AT_@ -7,5 +7,5 @@
int
isalnum(int c)
{
- return _ctype[(unsigned char) c] & (_U|_L|_D);
+ return __ctype[(unsigned char) c] & (_U|_L|_D);
}
diff --git a/libc/src/isalpha.c b/libc/src/isalpha.c
index d5b1f22..8b89a5b 100644
--- a/libc/src/isalpha.c
+++ b/libc/src/isalpha.c
_AT_@ -7,5 +7,5 @@
int
isalpha(int c)
{
- return _ctype[(unsigned char) c] & (_U|_L);
+ return __ctype[(unsigned char) c] & (_U|_L);
}
diff --git a/libc/src/iscntrl.c b/libc/src/iscntrl.c
index 82fd6e4..e04e0d0 100644
--- a/libc/src/iscntrl.c
+++ b/libc/src/iscntrl.c
_AT_@ -7,5 +7,5 @@
int
iscntrl(int c)
{
- return _ctype[(unsigned char) c] & (_C);
+ return __ctype[(unsigned char) c] & (_C);
}
diff --git a/libc/src/isdigit.c b/libc/src/isdigit.c
index a84042d..a23fa72 100644
--- a/libc/src/isdigit.c
+++ b/libc/src/isdigit.c
_AT_@ -7,5 +7,5 @@
int
isdigit(int c)
{
- return _ctype[(unsigned char) c] & (_D);
+ return __ctype[(unsigned char) c] & (_D);
}
diff --git a/libc/src/isgraph.c b/libc/src/isgraph.c
index fb31e64..caefd96 100644
--- a/libc/src/isgraph.c
+++ b/libc/src/isgraph.c
_AT_@ -7,5 +7,5 @@
int
isgraph(int c)
{
- return _ctype[(unsigned char) c] & (_P|_U|_L|_D);
+ return __ctype[(unsigned char) c] & (_P|_U|_L|_D);
}
diff --git a/libc/src/islower.c b/libc/src/islower.c
index ff10bda..faafd52 100644
--- a/libc/src/islower.c
+++ b/libc/src/islower.c
_AT_@ -7,5 +7,5 @@
int
islower(int c)
{
- return _ctype[(unsigned char) c] & _L;
+ return __ctype[(unsigned char) c] & _L;
}
diff --git a/libc/src/isprint.c b/libc/src/isprint.c
index 15a38d1..2d68107 100644
--- a/libc/src/isprint.c
+++ b/libc/src/isprint.c
_AT_@ -7,5 +7,5 @@
int
isprint(int c)
{
- return _ctype[(unsigned char) c] & (_P|_U|_L|_D|_SP);
+ return __ctype[(unsigned char) c] & (_P|_U|_L|_D|_SP);
}
diff --git a/libc/src/ispunct.c b/libc/src/ispunct.c
index d029c57..4a6186c 100644
--- a/libc/src/ispunct.c
+++ b/libc/src/ispunct.c
_AT_@ -7,5 +7,5 @@
int
ispunct(int c)
{
- return _ctype[(unsigned char) c] & (_P);
+ return __ctype[(unsigned char) c] & (_P);
}
diff --git a/libc/src/isspace.c b/libc/src/isspace.c
index c0e9895..f93b35c 100644
--- a/libc/src/isspace.c
+++ b/libc/src/isspace.c
_AT_@ -7,5 +7,5 @@
int
isspace(int c)
{
- return _ctype[(unsigned char) c] & _S;
+ return __ctype[(unsigned char) c] & _S;
}
diff --git a/libc/src/isupper.c b/libc/src/isupper.c
index 9feb6d6..dc4bdbc 100644
--- a/libc/src/isupper.c
+++ b/libc/src/isupper.c
_AT_@ -7,5 +7,5 @@
int
isupper(int c)
{
- return _ctype[(unsigned char) c] & _U;
+ return __ctype[(unsigned char) c] & _U;
}
diff --git a/libc/src/isxdigit.c b/libc/src/isxdigit.c
index b7277e2..16eaff0 100644
--- a/libc/src/isxdigit.c
+++ b/libc/src/isxdigit.c
_AT_@ -7,5 +7,5 @@
int
isxdigit(int c)
{
- return _ctype[(unsigned char) c] & (_D|_X);
+ return __ctype[(unsigned char) c] & (_D|_X);
}
Received on Wed Mar 08 2017 - 16:02:45 CET
This archive was generated by hypermail 2.3.0
: Wed Mar 08 2017 - 16:12:19 CET