theme: Replace char array element comparisons with strncmp

https://bugzilla.gnome.org/show_bug.cgi?id=662962
This commit is contained in:
Jasper St. Pierre 2012-03-01 00:36:16 -05:00
parent d06600aeb0
commit 86dae6d4c7

View File

@ -1189,10 +1189,8 @@ meta_color_spec_new_from_string (const char *str,
MetaColorSpec *spec; MetaColorSpec *spec;
spec = NULL; spec = NULL;
if (str[0] == 'g' && str[1] == 't' && str[2] == 'k' && str[3] == ':' && if (strncmp (str, "gtk:custom", 10) == 0)
str[4] == 'c' && str[5] == 'u' && str[6] == 's' && str[7] == 't' &&
str[8] == 'o' && str[9] == 'm')
{ {
const char *color_name_start, *fallback_str_start, *end; const char *color_name_start, *fallback_str_start, *end;
char *color_name; char *color_name;
@ -1267,7 +1265,7 @@ meta_color_spec_new_from_string (const char *str,
spec->data.gtkcustom.color_name = color_name; spec->data.gtkcustom.color_name = color_name;
spec->data.gtkcustom.fallback = fallback; spec->data.gtkcustom.fallback = fallback;
} }
else if (str[0] == 'g' && str[1] == 't' && str[2] == 'k' && str[3] == ':') else if (strncmp (str, "gtk:", 4) == 0)
{ {
/* GTK color */ /* GTK color */
const char *bracket; const char *bracket;
@ -1334,8 +1332,7 @@ meta_color_spec_new_from_string (const char *str,
spec->data.gtk.component = component; spec->data.gtk.component = component;
g_assert (spec->data.gtk.component < META_GTK_COLOR_LAST); g_assert (spec->data.gtk.component < META_GTK_COLOR_LAST);
} }
else if (str[0] == 'b' && str[1] == 'l' && str[2] == 'e' && str[3] == 'n' && else if (strncmp (str, "blend/", 6) == 0)
str[4] == 'd' && str[5] == '/')
{ {
/* blend */ /* blend */
char **split; char **split;
@ -1403,8 +1400,7 @@ meta_color_spec_new_from_string (const char *str,
spec->data.blend.background = bg; spec->data.blend.background = bg;
spec->data.blend.foreground = fg; spec->data.blend.foreground = fg;
} }
else if (str[0] == 's' && str[1] == 'h' && str[2] == 'a' && str[3] == 'd' && else if (strncmp (str, "shade/", 6) == 0)
str[4] == 'e' && str[5] == '/')
{ {
/* shade */ /* shade */
char **split; char **split;
@ -1701,20 +1697,12 @@ op_from_string (const char *p,
return POS_OP_MOD; return POS_OP_MOD;
case '`': case '`':
if (p[0] == '`' && if (strncmp (p, "`max`", 5) == 0)
p[1] == 'm' &&
p[2] == 'a' &&
p[3] == 'x' &&
p[4] == '`')
{ {
*len = 5; *len = 5;
return POS_OP_MAX; return POS_OP_MAX;
} }
else if (p[0] == '`' && else if (strncmp (p, "`min`", 5) == 0)
p[1] == 'm' &&
p[2] == 'i' &&
p[3] == 'n' &&
p[4] == '`')
{ {
*len = 5; *len = 5;
return POS_OP_MIN; return POS_OP_MIN;