summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-04-30 20:55:45 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-04-30 20:55:45 +0000
commit6f95799d449bd193f77ea6c24bc77bc80f071717 (patch)
treeb4ce0388b987572bbefc34d80f2ba900f190a8a7 /pango
parentf6a418ee9a9b35c1e4eff002853779c269107ad5 (diff)
downloadpango-6f95799d449bd193f77ea6c24bc77bc80f071717.tar.gz
Hash case insensitively (#106942, Morten Welinder)
Wed Apr 30 16:46:52 2003 Owen Taylor <otaylor@redhat.com> * pango/fonts.c (pango_font_description_hash): Hash case insensitively (#106942, Morten Welinder)
Diffstat (limited to 'pango')
-rw-r--r--pango/fonts.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index 4e67e17c..89e65573 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -618,6 +618,24 @@ pango_font_description_equal (const PangoFontDescription *desc1,
(desc1->family_name && desc2->family_name && g_ascii_strcasecmp (desc1->family_name, desc2->family_name) == 0)));
}
+#define TOLOWER(c) \
+ (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))
+
+static guint
+case_insensitive_hash (const char *key)
+{
+ const char *p = key;
+ guint h = TOLOWER (*p);
+
+ if (h)
+ {
+ for (p += 1; *p != '\0'; p++)
+ h = (h << 5) - h + TOLOWER (*p);
+ }
+
+ return h;
+}
+
/**
* pango_font_description_hash:
* @desc: a #PangoFontDescription
@@ -635,7 +653,7 @@ pango_font_description_hash (const PangoFontDescription *desc)
hash = desc->mask;
if (desc->mask & PANGO_FONT_MASK_FAMILY)
- hash = g_str_hash (desc->family_name);
+ hash = case_insensitive_hash (desc->family_name);
if (desc->mask & PANGO_FONT_MASK_SIZE)
hash ^= desc->size;
if (desc->mask & PANGO_FONT_MASK_STYLE)