scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 6bc2930486765b080a04c22fdc380a1f985c67e9
parent d3d71beefae3f4c76b3f69284e1f54998dc5553a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  8 Mar 2017 15:16:26 +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.

Diffstat:
Mlibc/include/ctype.h | 26+++++++++++++-------------
Mlibc/src/ctype.c | 2+-
Mlibc/src/isalnum.c | 2+-
Mlibc/src/isalpha.c | 2+-
Mlibc/src/iscntrl.c | 2+-
Mlibc/src/isdigit.c | 2+-
Mlibc/src/isgraph.c | 2+-
Mlibc/src/islower.c | 2+-
Mlibc/src/isprint.c | 2+-
Mlibc/src/ispunct.c | 2+-
Mlibc/src/isspace.c | 2+-
Mlibc/src/isupper.c | 2+-
Mlibc/src/isxdigit.c | 2+-
13 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/libc/include/ctype.h b/libc/include/ctype.h @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -7,5 +7,5 @@ int isxdigit(int c) { - return _ctype[(unsigned char) c] & (_D|_X); + return __ctype[(unsigned char) c] & (_D|_X); }