[gs-cvs] rev 9378 - trunk/ghostpdl/xps

tor at ghostscript.com tor at ghostscript.com
Tue Jan 20 09:31:29 PST 2009


Author: tor
Date: 2009-01-20 09:31:28 -0800 (Tue, 20 Jan 2009)
New Revision: 9378

Modified:
   trunk/ghostpdl/xps/xpshash.c
Log:
Make the part name hash table case insensitive.

Modified: trunk/ghostpdl/xps/xpshash.c
===================================================================
--- trunk/ghostpdl/xps/xpshash.c	2009-01-19 18:04:56 UTC (rev 9377)
+++ trunk/ghostpdl/xps/xpshash.c	2009-01-20 17:31:28 UTC (rev 9378)
@@ -29,11 +29,18 @@
     xps_hash_entry_t *entries;
 };
 
-static unsigned int hash(char *s)
+static inline int xps_tolower(int c)
 {
+    if (c >= 'A' && c <= 'Z')
+	return c + 32;
+    return c;
+}
+
+static unsigned int xps_hash(char *s)
+{
     unsigned int h = 0;
     while (*s)
-	h = *s++ + (h << 6) + (h << 16) - h;
+	h = xps_tolower(*s++) + (h << 6) + (h << 16) - h;
     return h;
 }
 
@@ -111,14 +118,14 @@
 {
     xps_hash_entry_t *entries = table->entries;
     unsigned int size = table->size;
-    unsigned int pos = hash(key) % size;
+    unsigned int pos = xps_hash(key) % size;
 
     while (1)
     {
 	if (!entries[pos].value)
 	    return NULL;
 
-	if (strcmp(key, entries[pos].key) == 0)
+	if (xps_strcasecmp(key, entries[pos].key) == 0)
 	    return entries[pos].value;
 
 	pos = (pos + 1) % size;
@@ -139,7 +146,7 @@
 
     entries = table->entries;
     size = table->size;
-    pos = hash(key) % size;
+    pos = xps_hash(key) % size;
 
     while (1)
     {
@@ -151,7 +158,7 @@
 	    return 0;
 	}
 
-	if (strcmp(key, entries[pos].key) == 0)
+	if (xps_strcasecmp(key, entries[pos].key) == 0)
 	{
 	    return 0;
 	}



More information about the gs-cvs mailing list