summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-04-30 20:55:27 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-04-30 20:55:27 +0000
commitb8f461e6261c85b2b1180e5c9d50a4fc854e2bf1 (patch)
tree6f2978a40c36927e49424f62b5d16fca234168bb /pango
parent36270cf8e27b21c5581859eb99687ca81df2c57e (diff)
downloadpango-b8f461e6261c85b2b1180e5c9d50a4fc854e2bf1.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)