[pango] Ignore spaces when parsing colors
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] Ignore spaces when parsing colors
- Date: Sat, 25 Aug 2012 20:08:21 +0000 (UTC)
commit acb9dc98034fcaaac2ba2d4b4e3a2b1e9a4ca4d0
Author: Behdad Esfahbod <behdad behdad org>
Date: Sat Aug 25 15:59:53 2012 -0400
Ignore spaces when parsing colors
pango/pango-color.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/pango/pango-color.c b/pango/pango-color.c
index e057729..382dca1 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]