summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2012-08-25 15:59:53 -0400
committerBehdad Esfahbod <behdad@behdad.org>2012-08-25 16:07:33 -0400
commitacb9dc98034fcaaac2ba2d4b4e3a2b1e9a4ca4d0 (patch)
tree195b742196bf876ee129a0e86d856178e10daf34
parent633466d81ce094f8aadd562a51d16e150bb4037d (diff)
downloadpango-acb9dc98034fcaaac2ba2d4b4e3a2b1e9a4ca4d0.tar.gz
Ignore spaces when parsing colors
-rw-r--r--pango/pango-color.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/pango/pango-color.c b/pango/pango-color.c
index e0577291..382dca18 100644
--- a/pango/pango-color.c
+++ b/pango/pango-color.c
@@ -144,10 +144,28 @@ pango_color_to_string (const PangoColor *color)
#include "pango-color-table.h"
+#define ISUPPER(c) ((c) >= 'A' && (c) <= 'Z')
+#define TOLOWER(c) (ISUPPER (c) ? (c) - 'A' + 'a' : (c))
+
static int
compare_xcolor_entries (const void *a, const void *b)
{
- return g_ascii_strcasecmp ((const char *) a, color_names + ((const ColorEntry *) b)->name_offset);
+ const guchar *s1 = (const guchar *) a;
+ const guchar *s2 = (const guchar *) (color_names + ((const ColorEntry *) b)->name_offset);
+
+ while (*s1 && *s2)
+ {
+ int c1, c2;
+ while (*s1 == ' ') s1++;
+ while (*s2 == ' ') s1++;
+ c1 = (gint)(guchar) TOLOWER (*s1);
+ c2 = (gint)(guchar) TOLOWER (*s2);
+ if (c1 != c2)
+ return (c1 - c2);
+ s1++; s2++;
+ }
+
+ return ((gint) *s1) - ((gint) *s2);
}
static gboolean