[xserver-commit] xserver/dix dixutils.c,3.16,3.17

Keith Packard xserver-commit@pdx.freedesktop.org
Thu, 15 Jan 2004 01:03:48 -0800


Committed by: keithp

Update of /cvs/xserver/xserver/dix
In directory pdx:/tmp/cvs-serv17870/dix

Modified Files:
	dixutils.c 
Log Message:
2004-01-15  Keith Packard  <keithp@keithp.com>
	* dix/dixutils.c: (ISOLatin1ToLower), (CompareISOLatin1Lowered):
	* include/dix.h:
	Add CompareISOLatin1Lowered.
	* include/picturestr.h:
	* render/filter.c: (PictureGetFilterId), (PictureAddFilter),
	(PictureSetDefaultFilters), (SetPictureFilter):
	Change filter management to permit varargs filters.
	Use CompareISOLatin1Lowered to make filter name tests
	case-insensitive (as required by spec).


Index: dixutils.c
===================================================================
RCS file: /cvs/xserver/xserver/dix/dixutils.c,v
retrieving revision 3.16
retrieving revision 3.17
diff -u -d -r3.16 -r3.17
--- dixutils.c	9 Oct 2003 06:36:26 -0000	3.16
+++ dixutils.c	15 Jan 2004 09:03:46 -0000	3.17
@@ -155,6 +155,21 @@
  * beware of too-small buffers
  */
 
+static unsigned char
+ISOLatin1ToLower (unsigned char source)
+{
+    unsigned char   dest;
+    if ((source >= XK_A) && (source <= XK_Z))
+	dest = source + (XK_a - XK_A);
+    else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis))
+	dest = source + (XK_agrave - XK_Agrave);
+    else if ((source >= XK_Ooblique) && (source <= XK_Thorn))
+	dest = source + (XK_oslash - XK_Ooblique);
+    else
+	dest = source;
+    return dest;
+}
+
 void
 CopyISOLatin1Lowered(dest, source, length)
     register unsigned char *dest, *source;
@@ -163,17 +178,27 @@
     register int i;
 
     for (i = 0; i < length; i++, source++, dest++)
+	*dest = ISOLatin1ToLower (*source);
+    *dest = '\0';
+}
+
+int
+CompareISOLatin1Lowered(unsigned char *s1, int s1len, 
+			unsigned char *s2, int s2len)
+{
+    unsigned char   c1, c2;
+    
+    for (;;) 
     {
-	if ((*source >= XK_A) && (*source <= XK_Z))
-	    *dest = *source + (XK_a - XK_A);
-	else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
-	    *dest = *source + (XK_agrave - XK_Agrave);
-	else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
-	    *dest = *source + (XK_oslash - XK_Ooblique);
-	else
-	    *dest = *source;
+	/* note -- compare against zero so that -1 ignores len */
+	c1 = s1len-- ? *s1++ : '\0';
+	c2 = s2len-- ? *s2++ : '\0';
+	if (!c1 || 
+	    (c1 != c2 && 
+	     (c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2))))
+	    break;
     }
-    *dest = '\0';
+    return (int) c1 - (int) c2;
 }
 
 #ifdef XCSECURITY