cvs commit: src/include ctype.h

YONETANI Tomokazu qhwt+dfly at les.ath.cx
Wed May 4 17:29:20 PDT 2005


On Mon, May 02, 2005 at 10:41:05AM -0700, Joerg Sonnenberger wrote:
> joerg       2005/05/02 10:41:05 PDT
> 
> DragonFly src repository
> 
>   Modified files:
>     include              ctype.h 
>   Log:
>   isprint() should be true only for characters in space, not blank.
>   blank might contain control chars, like TAB in the POSIX locale.
>   
>   Revision  Changes    Path
>   1.7       +1 -1      src/include/ctype.h
> http://www.dragonflybsd.org/cvsweb/src/include/ctype.h.diff?r1=1.6&r2=1.7&f=u

If nobody objects, I'm going to commit the following compromise
borrowed from NetBSD, because the above change breaks more tools relying
on isprint() than it fixes.

Index: include/ctype.h
===================================================================
RCS file: /home/source/dragonfly/cvs/src/include/ctype.h,v
retrieving revision 1.7
diff -u -r1.7 ctype.h
--- include/ctype.h	2 May 2005 17:41:05 -0000	1.7
+++ include/ctype.h	4 May 2005 13:04:34 -0000
@@ -92,7 +92,7 @@
 #define	isalpha(c)	((int)((__libc_ctype_ + 1)[(int)(c)] & (_U|_L)))
 #define	isxdigit(c)	((int)((__libc_ctype_ + 1)[(int)(c)] & (_N|_X)))
 #define	isalnum(c)	((int)((__libc_ctype_ + 1)[(int)(c)] & (_U|_L|_N)))
-#define	isprint(c)	((int)((__libc_ctype_ + 1)[(int)(c)] & (_P|_U|_L|_N|_S)))
+#define	isprint(c)	((int)((__libc_ctype_ + 1)[(int)(c)] & (_P|_U|_L|_N|_B)))
 #define	isgraph(c)	((int)((__libc_ctype_ + 1)[(int)(c)] & (_P|_U|_L|_N)))
 #define	iscntrl(c)	((int)((__libc_ctype_ + 1)[(int)(c)] & _C))
 #define	tolower(c)	((int)((__libc_tolower_tab_ + 1)[(int)(c)]))
@@ -107,8 +107,10 @@
 
 #if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 200112L || \
     __XSI_VISIBLE >= 600
+#if 0
 #define isblank(c)	((int)((__libc_ctype_ + 1)[(int)(c)] & _B))
 #endif
+#endif
 
 #ifdef _CTYPE_PRIVATE
 #include <machine/limits.h>	/* for CHAR_BIT */
Index: lib/libc/gen/ctype.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/lib/libc/gen/ctype.c,v
retrieving revision 1.1
diff -u -r1.1 ctype.c
--- lib/libc/gen/ctype.c	16 Mar 2005 06:54:41 -0000	1.1
+++ lib/libc/gen/ctype.c	4 May 2005 12:45:10 -0000
@@ -44,7 +44,7 @@
 const uint16_t __libc_C_ctype_[1 + _CTYPE_NUM_CHARS] = {
 	0,
 	_C,	_C,	_C,	_C,	_C,	_C,	_C,	_C,
-	_C,	_C|_S|_B,	_C|_S,	_C|_S,	_C|_S,	_C|_S,	_C,	_C,
+	_C,	_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: lib/libc/gen/isctype.c
===================================================================
RCS file: /home/source/dragonfly/cvs/src/lib/libc/gen/isctype.c,v
retrieving revision 1.3
diff -u -r1.3 isctype.c
--- lib/libc/gen/isctype.c	21 Apr 2005 16:36:34 -0000	1.3
+++ lib/libc/gen/isctype.c	4 May 2005 12:46:08 -0000
@@ -56,7 +56,7 @@
 int
 isblank(int c)
 {
-	return((__libc_ctype_ + 1)[c] & _B);
+	return(c == ' ' || c == '\t');
 }
 
 #undef iscntrl





More information about the Commits mailing list