Revert "ctype: use less short names in public header"

This patch fixed a problem which isn't in newlib, but in projects
incorrectly using symbols from the reserved namespace.

This reverts commit 3ba1bd0d9d.
This commit is contained in:
Corinna Vinschen 2021-12-02 11:21:14 +01:00
parent 8dd641f236
commit dbc7d28ba9
24 changed files with 56 additions and 69 deletions

View File

@ -1,15 +1,5 @@
#include <ctype.h> #include <ctype.h>
/* Define some short names to keep internal files shorter. */
#define _U _ISupper
#define _L _ISlower
#define _N _ISdigit
#define _S _ISspace
#define _P _ISpunct
#define _C _IScntrl
#define _X _ISxdigit
#define _B _ISblank
#if (defined(__GNUC__) && !defined(__CHAR_UNSIGNED__) && !defined(COMPACT_CTYPE)) || defined (__CYGWIN__) #if (defined(__GNUC__) && !defined(__CHAR_UNSIGNED__) && !defined(COMPACT_CTYPE)) || defined (__CYGWIN__)
#define ALLOW_NEGATIVE_CTYPE_INDEX #define ALLOW_NEGATIVE_CTYPE_INDEX
#endif #endif

View File

@ -46,5 +46,5 @@ No OS subroutines are required.
int int
isalnum (int c) isalnum (int c)
{ {
return(__CTYPE_PTR[c+1] & (_ISupper|_ISlower|_ISdigit)); return(__CTYPE_PTR[c+1] & (_U|_L|_N));
} }

View File

@ -6,5 +6,5 @@
int int
isalnum_l (int c, struct __locale_t *locale) isalnum_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & (_ISupper|_ISlower|_ISdigit); return __locale_ctype_ptr_l (locale)[c+1] & (_U|_L|_N);
} }

View File

@ -45,5 +45,5 @@ No supporting OS subroutines are required.
int int
isalpha (int c) isalpha (int c)
{ {
return(__CTYPE_PTR[c+1] & (_ISupper|_ISlower)); return(__CTYPE_PTR[c+1] & (_U|_L));
} }

View File

@ -6,5 +6,5 @@
int int
isalpha_l (int c, struct __locale_t *locale) isalpha_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & (_ISupper|_ISlower); return __locale_ctype_ptr_l (locale)[c+1] & (_U|_L);
} }

View File

@ -44,5 +44,5 @@ No supporting OS subroutines are required.
int int
isblank (int c) isblank (int c)
{ {
return ((__CTYPE_PTR[c+1] & _ISblank) || (c == '\t')); return ((__CTYPE_PTR[c+1] & _B) || (c == '\t'));
} }

View File

@ -6,5 +6,5 @@
int int
isblank_l (int c, struct __locale_t *locale) isblank_l (int c, struct __locale_t *locale)
{ {
return (__locale_ctype_ptr_l (locale)[c+1] & _ISblank) || (c == '\t'); return (__locale_ctype_ptr_l (locale)[c+1] & _B) || (c == '\t');
} }

View File

@ -48,5 +48,5 @@ No supporting OS subroutines are required.
int int
iscntrl (int c) iscntrl (int c)
{ {
return(__CTYPE_PTR[c+1] & _IScntrl); return(__CTYPE_PTR[c+1] & _C);
} }

View File

@ -6,5 +6,5 @@
int int
iscntrl_l (int c, struct __locale_t *locale) iscntrl_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & _IScntrl; return __locale_ctype_ptr_l (locale)[c+1] & _C;
} }

View File

@ -47,5 +47,5 @@ No supporting OS subroutines are required.
int int
isdigit (int c) isdigit (int c)
{ {
return(__CTYPE_PTR[c+1] & _ISdigit); return(__CTYPE_PTR[c+1] & _N);
} }

View File

@ -6,5 +6,5 @@
int int
isdigit_l (int c, struct __locale_t *locale) isdigit_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & _ISdigit; return __locale_ctype_ptr_l (locale)[c+1] & _N;
} }

View File

@ -45,5 +45,5 @@ No supporting OS subroutines are required.
int int
islower (int c) islower (int c)
{ {
return ((__CTYPE_PTR[c+1] & (_ISupper|_ISlower)) == _ISlower); return ((__CTYPE_PTR[c+1] & (_U|_L)) == _L);
} }

View File

@ -6,5 +6,5 @@
int int
islower_l (int c, struct __locale_t *locale) islower_l (int c, struct __locale_t *locale)
{ {
return (__locale_ctype_ptr_l (locale)[c+1] & (_ISupper|_ISlower)) == _ISlower; return (__locale_ctype_ptr_l (locale)[c+1] & (_U|_L)) == _L;
} }

View File

@ -59,7 +59,7 @@ No supporting OS subroutines are required.
int int
isgraph (int c) isgraph (int c)
{ {
return(__CTYPE_PTR[c+1] & (_ISpunct|_ISupper|_ISlower|_ISdigit)); return(__CTYPE_PTR[c+1] & (_P|_U|_L|_N));
} }
@ -67,5 +67,5 @@ isgraph (int c)
int int
isprint (int c) isprint (int c)
{ {
return(__CTYPE_PTR[c+1] & (_ISpunct|_ISupper|_ISlower|_ISdigit|_ISblank)); return(__CTYPE_PTR[c+1] & (_P|_U|_L|_N|_B));
} }

View File

@ -6,7 +6,7 @@
int int
isgraph_l (int c, struct __locale_t *locale) isgraph_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & (_ISpunct|_ISupper|_ISlower|_ISdigit); return __locale_ctype_ptr_l (locale)[c+1] & (_P|_U|_L|_N);
} }
#undef isprint_l #undef isprint_l
@ -14,5 +14,5 @@ isgraph_l (int c, struct __locale_t *locale)
int int
isprint_l (int c, struct __locale_t *locale) isprint_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & (_ISpunct|_ISupper|_ISlower|_ISdigit|_ISblank); return __locale_ctype_ptr_l (locale)[c+1] & (_P|_U|_L|_N|_B);
} }

View File

@ -47,5 +47,5 @@ No supporting OS subroutines are required.
int int
ispunct (int c) ispunct (int c)
{ {
return(__CTYPE_PTR[c+1] & _ISpunct); return(__CTYPE_PTR[c+1] & _P);
} }

View File

@ -6,6 +6,6 @@
int int
ispunct_l (int c, struct __locale_t *locale) ispunct_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & _ISpunct; return __locale_ctype_ptr_l (locale)[c+1] & _P;
} }

View File

@ -46,5 +46,5 @@ No supporting OS subroutines are required.
int int
isspace (int c) isspace (int c)
{ {
return(__CTYPE_PTR[c+1] & _ISspace); return(__CTYPE_PTR[c+1] & _S);
} }

View File

@ -6,6 +6,6 @@
int int
isspace_l (int c, struct __locale_t *locale) isspace_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & _ISspace; return __locale_ctype_ptr_l (locale)[c+1] & _S;
} }

View File

@ -43,5 +43,5 @@ No supporting OS subroutines are required.
int int
isupper (int c) isupper (int c)
{ {
return ((__CTYPE_PTR[c+1] & (_ISupper|_ISlower)) == _ISupper); return ((__CTYPE_PTR[c+1] & (_U|_L)) == _U);
} }

View File

@ -6,6 +6,6 @@
int int
isupper_l (int c, struct __locale_t *locale) isupper_l (int c, struct __locale_t *locale)
{ {
return (__locale_ctype_ptr_l (locale)[c+1] & (_ISupper|_ISlower)) == _ISupper; return (__locale_ctype_ptr_l (locale)[c+1] & (_U|_L)) == _U;
} }

View File

@ -46,5 +46,5 @@ No supporting OS subroutines are required.
int int
isxdigit (int c) isxdigit (int c)
{ {
return(__CTYPE_PTR[c+1] & ((_ISxdigit)|(_ISdigit))); return(__CTYPE_PTR[c+1] & ((_X)|(_N)));
} }

View File

@ -6,6 +6,6 @@
int int
isxdigit_l (int c, struct __locale_t *locale) isxdigit_l (int c, struct __locale_t *locale)
{ {
return __locale_ctype_ptr_l (locale)[c+1] & ((_ISxdigit)|(_ISdigit)); return __locale_ctype_ptr_l (locale)[c+1] & ((_X)|(_N));
} }

View File

@ -57,17 +57,14 @@ extern int isascii_l (int __c, locale_t __l);
extern int toascii_l (int __c, locale_t __l); extern int toascii_l (int __c, locale_t __l);
#endif #endif
enum #define _U 01
{ #define _L 02
_ISupper = 01, #define _N 04
_ISlower = 02, #define _S 010
_ISdigit = 04, #define _P 020
_ISspace = 010, #define _C 040
_ISpunct = 020, #define _X 0100
_IScntrl = 040, #define _B 0200
_ISxdigit = 0100,
_ISblank = 0200,
};
/* For C++ backward-compatibility only. */ /* For C++ backward-compatibility only. */
extern __IMPORT const char _ctype_[]; extern __IMPORT const char _ctype_[];
@ -92,22 +89,22 @@ const char *__locale_ctype_ptr (void);
an out-of-bounds reference on a 64-bit machine. */ an out-of-bounds reference on a 64-bit machine. */
#define __ctype_lookup(__c) ((__CTYPE_PTR+sizeof(""[__c]))[(int)(__c)]) #define __ctype_lookup(__c) ((__CTYPE_PTR+sizeof(""[__c]))[(int)(__c)])
#define isalpha(__c) (__ctype_lookup(__c) & (_ISupper|_ISlower)) #define isalpha(__c) (__ctype_lookup(__c)&(_U|_L))
#define isupper(__c) ((__ctype_lookup(__c) & (_ISupper|_ISlower)) == _ISupper) #define isupper(__c) ((__ctype_lookup(__c)&(_U|_L))==_U)
#define islower(__c) ((__ctype_lookup(__c) & (_ISupper|_ISlower)) == _ISlower) #define islower(__c) ((__ctype_lookup(__c)&(_U|_L))==_L)
#define isdigit(__c) (__ctype_lookup(__c) & _ISdigit) #define isdigit(__c) (__ctype_lookup(__c)&_N)
#define isxdigit(__c) (__ctype_lookup(__c) & (_ISxdigit|_ISdigit)) #define isxdigit(__c) (__ctype_lookup(__c)&(_X|_N))
#define isspace(__c) (__ctype_lookup(__c) & _ISspace) #define isspace(__c) (__ctype_lookup(__c)&_S)
#define ispunct(__c) (__ctype_lookup(__c) & _ISpunct) #define ispunct(__c) (__ctype_lookup(__c)&_P)
#define isalnum(__c) (__ctype_lookup(__c) & (_ISupper|_ISlower|_ISdigit)) #define isalnum(__c) (__ctype_lookup(__c)&(_U|_L|_N))
#define isprint(__c) (__ctype_lookup(__c) & (_ISpunct|_ISupper|_ISlower|_ISdigit|_ISblank)) #define isprint(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N|_B))
#define isgraph(__c) (__ctype_lookup(__c) & (_ISpunct|_ISupper|_ISlower|_ISdigit)) #define isgraph(__c) (__ctype_lookup(__c)&(_P|_U|_L|_N))
#define iscntrl(__c) (__ctype_lookup(__c) & _IScntrl) #define iscntrl(__c) (__ctype_lookup(__c)&_C)
#if defined(__GNUC__) && __ISO_C_VISIBLE >= 1999 #if defined(__GNUC__) && __ISO_C_VISIBLE >= 1999
#define isblank(__c) \ #define isblank(__c) \
__extension__ ({ __typeof__ (__c) __x = (__c); \ __extension__ ({ __typeof__ (__c) __x = (__c); \
(__ctype_lookup(__x)&_ISblank) || (int) (__x) == '\t';}) (__ctype_lookup(__x)&_B) || (int) (__x) == '\t';})
#endif #endif
#if __POSIX_VISIBLE >= 200809 #if __POSIX_VISIBLE >= 200809
@ -123,22 +120,22 @@ __locale_ctype_ptr_l(locale_t _l)
#endif #endif
#define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)]) #define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)])
#define isalpha_l(__c,__l) (__ctype_lookup_l(__c,__l) & (_ISupper|_ISlower)) #define isalpha_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_U|_L))
#define isupper_l(__c,__l) ((__ctype_lookup_l(__c,__l) & (_ISupper|_ISlower)) == _ISupper) #define isupper_l(__c,__l) ((__ctype_lookup_l(__c,__l)&(_U|_L))==_U)
#define islower_l(__c,__l) ((__ctype_lookup_l(__c,__l) & (_ISupper|_ISlower)) == _ISlower) #define islower_l(__c,__l) ((__ctype_lookup_l(__c,__l)&(_U|_L))==_L)
#define isdigit_l(__c,__l) (__ctype_lookup_l(__c,__l) & _ISdigit) #define isdigit_l(__c,__l) (__ctype_lookup_l(__c,__l)&_N)
#define isxdigit_l(__c,__l) (__ctype_lookup_l(__c,__l) & (_ISxdigit|_ISdigit)) #define isxdigit_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_X|_N))
#define isspace_l(__c,__l) (__ctype_lookup_l(__c,__l) & _ISspace) #define isspace_l(__c,__l) (__ctype_lookup_l(__c,__l)&_S)
#define ispunct_l(__c,__l) (__ctype_lookup_l(__c,__l) & _ISpunct) #define ispunct_l(__c,__l) (__ctype_lookup_l(__c,__l)&_P)
#define isalnum_l(__c,__l) (__ctype_lookup_l(__c,__l) & (_ISupper|_ISlower|_ISdigit)) #define isalnum_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_U|_L|_N))
#define isprint_l(__c,__l) (__ctype_lookup_l(__c,__l) & (_ISpunct|_ISupper|_ISlower|_ISdigit|_ISblank)) #define isprint_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_P|_U|_L|_N|_B))
#define isgraph_l(__c,__l) (__ctype_lookup_l(__c,__l) & (_ISpunct|_ISupper|_ISlower|_ISdigit)) #define isgraph_l(__c,__l) (__ctype_lookup_l(__c,__l)&(_P|_U|_L|_N))
#define iscntrl_l(__c,__l) (__ctype_lookup_l(__c,__l) & _IScntrl) #define iscntrl_l(__c,__l) (__ctype_lookup_l(__c,__l)&_C)
#if defined(__GNUC__) #if defined(__GNUC__)
#define isblank_l(__c, __l) \ #define isblank_l(__c, __l) \
__extension__ ({ __typeof__ (__c) __x = (__c); \ __extension__ ({ __typeof__ (__c) __x = (__c); \
(__ctype_lookup_l(__x,__l)&_ISblank) || (int) (__x) == '\t';}) (__ctype_lookup_l(__x,__l)&_B) || (int) (__x) == '\t';})
#endif #endif
#endif /* __POSIX_VISIBLE >= 200809 */ #endif /* __POSIX_VISIBLE >= 200809 */