This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newlib _ctype_ alias kludge now invalid due to PR middle-end/15700 fix.


On Mar 17 15:21, Jeff Johnston wrote:
> I have just checked in a patch to newlib that changes the ctype macros to 
> use __ctype_ptr instead of _ctype_.  In addition, a configuration check is 
> made to see whether the array aliasing trick can be used or not.

The patch to ctype.h is broken.

You're using `__ctype_ptr+1' in libc/include/ctype.h, replacing the formerly
used `_ctype_+1'.  Since __ctype_ptr is defined as _ctype_b + 128, while
_ctype_ is defined as _ctype_b + 127, we're now off by one.  The below patch
fixes that.


Corinna

	* libc/include/ctype.h: Fix off by one error.

Index: libc/include/ctype.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/ctype.h,v
retrieving revision 1.8
diff -u -p -r1.8 ctype.h
--- libc/include/ctype.h	17 Mar 2005 20:11:23 -0000	1.8
+++ libc/include/ctype.h	18 Mar 2005 12:51:52 -0000
@@ -37,21 +37,20 @@ int _EXFUN(_toupper, (int __c));
 #define	_B	0200
 
 extern	__IMPORT _CONST char	*__ctype_ptr;
+extern	__IMPORT _CONST char	_ctype_[];  /* Deprecated.  */
 
 #ifndef __cplusplus
-#define	isalpha(c)	((__ctype_ptr+1)[(unsigned)(c)]&(_U|_L))
-#define	isupper(c)	((__ctype_ptr+1)[(unsigned)(c)]&_U)
-#define	islower(c)	((__ctype_ptr+1)[(unsigned)(c)]&_L)
-#define	isdigit(c)	((__ctype_ptr+1)[(unsigned)(c)]&_N)
-#define	isxdigit(c)	((__ctype_ptr+1)[(unsigned)(c)]&(_X|_N))
-#define	isspace(c)	((__ctype_ptr+1)[(unsigned)(c)]&_S)
-#define ispunct(c)	((__ctype_ptr+1)[(unsigned)(c)]&_P)
-#define isalnum(c)	((__ctype_ptr+1)[(unsigned)(c)]&(_U|_L|_N))
-#define isprint(c)	((__ctype_ptr+1)[(unsigned)(c)]&(_P|_U|_L|_N|_B))
-#define	isgraph(c)	((__ctype_ptr+1)[(unsigned)(c)]&(_P|_U|_L|_N))
-#define iscntrl(c)	((__ctype_ptr+1)[(unsigned)(c)]&_C)
-
-extern	__IMPORT _CONST char	_ctype_[];  /* Deprecated.  */
+#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)
 
 /* Non-gcc versions will get the library versions, and will be
    slightly slower */


-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]