This is the mail archive of the newlib@sourceware.org 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]

[PATCH/RFA] Fix ctype table and isblank


Hi,

the below patch fixes isblank and adds a corresponding macro to ctype.h.

The problem is that isblank right now only checks for ASCII TAB (0x9)
and ASCII Space (0x20) character hardcoded.  This is wrong in an
environment supporting non-ASCI charsets.


Corinna


	* libc/ctype/ctype_.c (_CTYPE_DATA_0_127): Mark TAB as blank
	character.
	* libc/ctype/isblank.c: Replace hardcoded test with test for
	having _B marker in ctype array.
	* libc/include/ctype.h (isblank): Add macro.


Index: libc/ctype/ctype_.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/ctype/ctype_.c,v
retrieving revision 1.5
diff -u -p -r1.5 ctype_.c
--- libc/ctype/ctype_.c	21 Jul 2008 21:28:34 -0000	1.5
+++ libc/ctype/ctype_.c	24 Mar 2009 10:49:13 -0000
@@ -39,7 +39,7 @@ static char sccsid[] = "@(#)ctype_.c	5.6
 
 #define _CTYPE_DATA_0_127 \
 	_C,	_C,	_C,	_C,	_C,	_C,	_C,	_C, \
-	_C,	_C|_S,	_C|_S,	_C|_S,	_C|_S,	_C|_S,	_C,	_C, \
+	_C,	_B|_C|_S, _C|_S, _C|_S,	_C|_S,	_C|_S,	_C,	_C, \
 	_C,	_C,	_C,	_C,	_C,	_C,	_C,	_C, \
 	_C,	_C,	_C,	_C,	_C,	_C,	_C,	_C, \
 	_S|_B,	_P,	_P,	_P,	_P,	_P,	_P,	_P, \
Index: libc/ctype/isblank.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/ctype/isblank.c,v
retrieving revision 1.2
diff -u -p -r1.2 isblank.c
--- libc/ctype/isblank.c	15 Oct 2008 20:36:26 -0000	1.2
+++ libc/ctype/isblank.c	24 Mar 2009 10:49:13 -0000
@@ -37,5 +37,5 @@ No supporting OS subroutines are require
 int
 _DEFUN(isblank,(c),int c)
 {
-	return (c == ' ' || c == '\t');
+	return(__ctype_ptr__[c+1] & _B);
 }
Index: libc/include/ctype.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/ctype.h,v
retrieving revision 1.13
diff -u -p -r1.13 ctype.h
--- libc/include/ctype.h	15 Oct 2008 20:49:56 -0000	1.13
+++ libc/include/ctype.h	24 Mar 2009 10:49:14 -0000
@@ -54,6 +54,10 @@ extern	__IMPORT _CONST char	*__ctype_ptr
 #define	isgraph(c)	((__ctype_ptr__)[(unsigned)((c)+1)]&(_P|_U|_L|_N))
 #define iscntrl(c)	((__ctype_ptr__)[(unsigned)((c)+1)]&_C)
 
+#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
+#define isblank(c)      ((__ctype_ptr__)[(unsigned)((c)+1)]&_B)
+#endif
+
 
 /* Non-gcc versions will get the library versions, and will be
    slightly slower */


-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


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