WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] ctype.h

To: Xen Mailing List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] ctype.h
From: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Date: Tue, 20 Dec 2005 14:31:21 +1100
Delivery-date: Tue, 20 Dec 2005 03:34:02 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
While writing the unit tests for xen/common/lib.c, I found a bug in
islower and isupper.  Character 223 ('ß') should not become 255 ('ÿ')
when lower-cased, or vice versa.  ISO C says in the C locale, nothing
above 127 should be upper or lower case.  However, it's not completely
useless to regard these characters as iso_8859-1, which seems to be the
intent.  Either way, if (islower(c)), then isupper(toupper(c)) must be
true.  This is fixed by regarding both 223 and 255 as alpha, but neither
upper nor lower.  We have to use both bits, since all 8 bits are taken.

Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>

diff -r f1b7a73b9457 xen/common/lib.c
--- a/xen/common/lib.c  Tue Dec 13 06:17:07 2005
+++ b/xen/common/lib.c  Tue Dec 20 14:19:01 2005
@@ -26,9 +26,9 @@
 _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,   /* 160-175 */
 _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,       /* 176-191 */
 _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
-_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
+_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L|_U,    /* 208-223 */
 _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
-_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
+_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L|_U};   /* 240-255 */
 
 
 /* a couple of 64 bit operations ported from freebsd */
diff -r f1b7a73b9457 xen/include/xen/ctype.h
--- a/xen/include/xen/ctype.h   Tue Dec 13 06:17:07 2005
+++ b/xen/include/xen/ctype.h   Tue Dec 20 14:19:01 2005
@@ -24,11 +24,11 @@
 #define iscntrl(c)     ((__ismask(c)&(_C)) != 0)
 #define isdigit(c)     ((__ismask(c)&(_D)) != 0)
 #define isgraph(c)     ((__ismask(c)&(_P|_U|_L|_D)) != 0)
-#define islower(c)     ((__ismask(c)&(_L)) != 0)
+#define islower(c)     ((__ismask(c)&(_U|_L)) == _L)
 #define isprint(c)     ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
 #define ispunct(c)     ((__ismask(c)&(_P)) != 0)
 #define isspace(c)     ((__ismask(c)&(_S)) != 0)
-#define isupper(c)     ((__ismask(c)&(_U)) != 0)
+#define isupper(c)     ((__ismask(c)&(_U|_L)) == _U)
 #define isxdigit(c)    ((__ismask(c)&(_D|_X)) != 0)
 
 #define isascii(c) (((unsigned char)(c))<=0x7f)

-- 
 ccontrol: http://ozlabs.org/~rusty/ccontrol


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>