Skip to content

Commit 9b6f737

Browse files
magciusvkareh
authored andcommitted
theme: Replace char array element comparisons with strncmp
https://bugzilla.gnome.org/show_bug.cgi?id=662962
1 parent 48b0b11 commit 9b6f737

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

src/ui/theme.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,10 +1164,8 @@ meta_color_spec_new_from_string (const char *str,
11641164
MetaColorSpec *spec;
11651165

11661166
spec = NULL;
1167-
1168-
if (str[0] == 'g' && str[1] == 't' && str[2] == 'k' && str[3] == ':' &&
1169-
str[4] == 'c' && str[5] == 'u' && str[6] == 's' && str[7] == 't' &&
1170-
str[8] == 'o' && str[9] == 'm')
1167+
1168+
if (strncmp (str, "gtk:custom", 10) == 0)
11711169
{
11721170
const char *color_name_start, *fallback_str_start, *end;
11731171
char *color_name;
@@ -1241,7 +1239,7 @@ meta_color_spec_new_from_string (const char *str,
12411239
spec->data.gtkcustom.color_name = color_name;
12421240
spec->data.gtkcustom.fallback = fallback;
12431241
}
1244-
else if (str[0] == 'g' && str[1] == 't' && str[2] == 'k' && str[3] == ':')
1242+
else if (strncmp (str, "gtk:", 4) == 0)
12451243
{
12461244
/* GTK color */
12471245
const char *bracket;
@@ -1308,8 +1306,7 @@ meta_color_spec_new_from_string (const char *str,
13081306
spec->data.gtk.component = component;
13091307
g_assert (spec->data.gtk.component < META_GTK_COLOR_LAST);
13101308
}
1311-
else if (str[0] == 'b' && str[1] == 'l' && str[2] == 'e' && str[3] == 'n' &&
1312-
str[4] == 'd' && str[5] == '/')
1309+
else if (strncmp (str, "blend/", 6) == 0)
13131310
{
13141311
/* blend */
13151312
char **split;
@@ -1377,8 +1374,7 @@ meta_color_spec_new_from_string (const char *str,
13771374
spec->data.blend.background = bg;
13781375
spec->data.blend.foreground = fg;
13791376
}
1380-
else if (str[0] == 's' && str[1] == 'h' && str[2] == 'a' && str[3] == 'd' &&
1381-
str[4] == 'e' && str[5] == '/')
1377+
else if (strncmp (str, "shade/", 6) == 0)
13821378
{
13831379
/* shade */
13841380
char **split;
@@ -1717,20 +1713,12 @@ op_from_string (const char *p,
17171713
return POS_OP_MOD;
17181714

17191715
case '`':
1720-
if (p[0] == '`' &&
1721-
p[1] == 'm' &&
1722-
p[2] == 'a' &&
1723-
p[3] == 'x' &&
1724-
p[4] == '`')
1716+
if (strncmp (p, "`max`", 5) == 0)
17251717
{
17261718
*len = 5;
17271719
return POS_OP_MAX;
17281720
}
1729-
else if (p[0] == '`' &&
1730-
p[1] == 'm' &&
1731-
p[2] == 'i' &&
1732-
p[3] == 'n' &&
1733-
p[4] == '`')
1721+
else if (strncmp (p, "`min`", 5) == 0)
17341722
{
17351723
*len = 5;
17361724
return POS_OP_MIN;

0 commit comments

Comments
 (0)