From fa914bf8ab6b2c93a02f1a915cc22c2e21d68f76 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Mon, 21 Jul 2008 21:28:34 +0000 Subject: 2008-07-21 Jeff Johnston * libc/ctype/ctype_.c: Add new pointer __ctype_ptr__ which is one less than the old __ctype_ptr. * libc/ctype/isalnum.c: Use __ctype_ptr__. * libc/ctype/isalpha.c: Ditto. * libc/ctype/iscntrl.c: Ditto. * libc/ctype/isdigit.c: Ditto. * libc/ctype/islower.c: Ditto. * libc/ctype/isprint.c: Ditto. * libc/ctype/ispunct.c: Ditto. * libc/ctype/isspace.c: Ditto. * libc/ctype/isupper.c: Ditto. * libc/ctype/isxdigit.c: Ditto. * libc/include/ctype.h: Change ctype macros to use new __ctype_ptr__ and add declaration of __ctype_ptr__. Remove older ctype table pointers from here even though they can still work. --- newlib/ChangeLog | 18 ++++++++++++++++++ newlib/libc/ctype/ctype_.c | 3 +++ newlib/libc/ctype/isalnum.c | 2 +- newlib/libc/ctype/isalpha.c | 2 +- newlib/libc/ctype/iscntrl.c | 2 +- newlib/libc/ctype/isdigit.c | 2 +- newlib/libc/ctype/islower.c | 2 +- newlib/libc/ctype/isprint.c | 4 ++-- newlib/libc/ctype/ispunct.c | 2 +- newlib/libc/ctype/isspace.c | 2 +- newlib/libc/ctype/isupper.c | 2 +- newlib/libc/ctype/isxdigit.c | 2 +- newlib/libc/include/ctype.h | 25 ++++++++++++------------- 13 files changed, 44 insertions(+), 24 deletions(-) (limited to 'newlib') diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 88206eb0c..f8f45ae38 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,21 @@ +2008-07-21 Jeff Johnston + + * libc/ctype/ctype_.c: Add new pointer __ctype_ptr__ which is one + less than the old __ctype_ptr. + * libc/ctype/isalnum.c: Use __ctype_ptr__. + * libc/ctype/isalpha.c: Ditto. + * libc/ctype/iscntrl.c: Ditto. + * libc/ctype/isdigit.c: Ditto. + * libc/ctype/islower.c: Ditto. + * libc/ctype/isprint.c: Ditto. + * libc/ctype/ispunct.c: Ditto. + * libc/ctype/isspace.c: Ditto. + * libc/ctype/isupper.c: Ditto. + * libc/ctype/isxdigit.c: Ditto. + * libc/include/ctype.h: Change ctype macros to use new __ctype_ptr__ + and add declaration of __ctype_ptr__. Remove older ctype table pointers + from here even though they can still work. + 2008-07-18 Ken Werner * libc/machine/spu/strcpy.h: Fix error in previous patch. diff --git a/newlib/libc/ctype/ctype_.c b/newlib/libc/ctype/ctype_.c index 5551dbdc9..6fa30b207 100644 --- a/newlib/libc/ctype/ctype_.c +++ b/newlib/libc/ctype/ctype_.c @@ -86,8 +86,10 @@ static _CONST char _ctype_b[128 + 256] = { # if defined(__CYGWIN__) _CONST char __declspec(dllexport) *__ctype_ptr = _ctype_b + 128; +_CONST char __declspec(dllexport) *__ctype_ptr__ = _ctype_b + 127; # else _CONST char *__ctype_ptr = _ctype_b + 128; +_CONST char *__ctype_ptr__ = _ctype_b + 127; # endif # if defined(_HAVE_ARRAY_ALIASING) @@ -124,4 +126,5 @@ _CONST char _ctype_[1 + 256] = { }; _CONST char *__ctype_ptr = _ctype_ + 1; +_CONST char *__ctype_ptr__ = _ctype_; #endif diff --git a/newlib/libc/ctype/isalnum.c b/newlib/libc/ctype/isalnum.c index 7e05bd1a2..3fd5f9515 100644 --- a/newlib/libc/ctype/isalnum.c +++ b/newlib/libc/ctype/isalnum.c @@ -41,6 +41,6 @@ No OS subroutines are required. int _DEFUN(isalnum,(c),int c) { - return((_ctype_ + 1)[c] & (_U|_L|_N)); + return(__ctype_ptr__[c+1] & (_U|_L|_N)); } diff --git a/newlib/libc/ctype/isalpha.c b/newlib/libc/ctype/isalpha.c index 35f14d396..a30ca9e19 100644 --- a/newlib/libc/ctype/isalpha.c +++ b/newlib/libc/ctype/isalpha.c @@ -39,6 +39,6 @@ No supporting OS subroutines are required. int _DEFUN(isalpha,(c),int c) { - return((_ctype_ + 1)[c] & (_U|_L)); + return(__ctype_ptr__[c+1] & (_U|_L)); } diff --git a/newlib/libc/ctype/iscntrl.c b/newlib/libc/ctype/iscntrl.c index 7b6da349d..a4fdff178 100644 --- a/newlib/libc/ctype/iscntrl.c +++ b/newlib/libc/ctype/iscntrl.c @@ -42,7 +42,7 @@ No supporting OS subroutines are required. int _DEFUN(iscntrl,(c),int c) { - return((_ctype_ + 1)[c] & _C); + return(__ctype_ptr__[c+1] & _C); } diff --git a/newlib/libc/ctype/isdigit.c b/newlib/libc/ctype/isdigit.c index 5c21898e6..18383ee45 100644 --- a/newlib/libc/ctype/isdigit.c +++ b/newlib/libc/ctype/isdigit.c @@ -39,5 +39,5 @@ No supporting OS subroutines are required. int _DEFUN(isdigit,(c),int c) { - return((_ctype_ + 1)[c] & _N); + return(__ctype_ptr__[c+1] & _N); } diff --git a/newlib/libc/ctype/islower.c b/newlib/libc/ctype/islower.c index cda484367..098e56c54 100644 --- a/newlib/libc/ctype/islower.c +++ b/newlib/libc/ctype/islower.c @@ -38,6 +38,6 @@ No supporting OS subroutines are required. int _DEFUN(islower,(c),int c) { - return((_ctype_ + 1)[c] & _L); + return(__ctype_ptr__[c+1] & _L); } diff --git a/newlib/libc/ctype/isprint.c b/newlib/libc/ctype/isprint.c index 2ff00f4e3..2f317a291 100644 --- a/newlib/libc/ctype/isprint.c +++ b/newlib/libc/ctype/isprint.c @@ -47,7 +47,7 @@ No supporting OS subroutines are required. int _DEFUN(isgraph,(c),int c) { - return((_ctype_ + 1)[c] & (_P|_U|_L|_N)); + return(__ctype_ptr__[c+1] & (_P|_U|_L|_N)); } @@ -55,6 +55,6 @@ _DEFUN(isgraph,(c),int c) int _DEFUN(isprint,(c),int c) { - return((_ctype_ + 1)[c] & (_P|_U|_L|_N|_B)); + return(__ctype_ptr__[c+1] & (_P|_U|_L|_N|_B)); } diff --git a/newlib/libc/ctype/ispunct.c b/newlib/libc/ctype/ispunct.c index c5679323c..9b9c9c0bc 100644 --- a/newlib/libc/ctype/ispunct.c +++ b/newlib/libc/ctype/ispunct.c @@ -41,6 +41,6 @@ No supporting OS subroutines are required. int _DEFUN(ispunct,(c),int c) { - return((_ctype_ + 1)[c] & _P); + return(__ctype_ptr__[c+1] & _P); } diff --git a/newlib/libc/ctype/isspace.c b/newlib/libc/ctype/isspace.c index 1bc0798a2..36582415c 100644 --- a/newlib/libc/ctype/isspace.c +++ b/newlib/libc/ctype/isspace.c @@ -39,6 +39,6 @@ No supporting OS subroutines are required. int _DEFUN(isspace,(c),int c) { - return((_ctype_ + 1)[c] & _S); + return(__ctype_ptr__[c+1] & _S); } diff --git a/newlib/libc/ctype/isupper.c b/newlib/libc/ctype/isupper.c index 4cf9e9a2d..d6cc6ecc4 100644 --- a/newlib/libc/ctype/isupper.c +++ b/newlib/libc/ctype/isupper.c @@ -38,6 +38,6 @@ No supporting OS subroutines are required. int _DEFUN(isupper,(c),int c) { - return((_ctype_ + 1)[c] & _U); + return(__ctype_ptr__[c+1] & _U); } diff --git a/newlib/libc/ctype/isxdigit.c b/newlib/libc/ctype/isxdigit.c index f8a035f37..9748eb4b5 100644 --- a/newlib/libc/ctype/isxdigit.c +++ b/newlib/libc/ctype/isxdigit.c @@ -40,6 +40,6 @@ No supporting OS subroutines are required. int _DEFUN(isxdigit,(c),int c) { - return((_ctype_ + 1)[c] & ((_X)|(_N))); + return(__ctype_ptr__[c+1] & ((_X)|(_N))); } diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h index c1ace5077..9014dbe4f 100644 --- a/newlib/libc/include/ctype.h +++ b/newlib/libc/include/ctype.h @@ -36,21 +36,20 @@ int _EXFUN(_toupper, (int __c)); #define _X 0100 #define _B 0200 -extern __IMPORT _CONST char *__ctype_ptr; -extern __IMPORT _CONST char _ctype_[]; /* For backward compatibility. */ +extern __IMPORT _CONST char *__ctype_ptr__; #ifndef __cplusplus -#define isalpha(c) ((__ctype_ptr)[(unsigned)(c)]&(_U|_L)) -#define isupper(c) ((__ctype_ptr)[(unsigned)(c)]&_U) -#define islower(c) ((__ctype_ptr)[(unsigned)(c)]&_L) -#define isdigit(c) ((__ctype_ptr)[(unsigned)(c)]&_N) -#define isxdigit(c) ((__ctype_ptr)[(unsigned)(c)]&(_X|_N)) -#define isspace(c) ((__ctype_ptr)[(unsigned)(c)]&_S) -#define ispunct(c) ((__ctype_ptr)[(unsigned)(c)]&_P) -#define isalnum(c) ((__ctype_ptr)[(unsigned)(c)]&(_U|_L|_N)) -#define isprint(c) ((__ctype_ptr)[(unsigned)(c)]&(_P|_U|_L|_N|_B)) -#define isgraph(c) ((__ctype_ptr)[(unsigned)(c)]&(_P|_U|_L|_N)) -#define iscntrl(c) ((__ctype_ptr)[(unsigned)(c)]&_C) +#define isalpha(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&(_U|_L)) +#define isupper(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&_U) +#define islower(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&_L) +#define isdigit(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&_N) +#define isxdigit(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&(_X|_N)) +#define isspace(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&_S) +#define ispunct(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&_P) +#define isalnum(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&(_U|_L|_N)) +#define isprint(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&(_P|_U|_L|_N|_B)) +#define isgraph(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&(_P|_U|_L|_N)) +#define iscntrl(c) ((__ctype_ptr__)[(unsigned)((c)+1)]&_C) /* Non-gcc versions will get the library versions, and will be -- cgit v1.2.3