return false;
}
+/* Match @needle out of @sep-seperated @haystack. */
static bool
-MatchOneOf(char *wanted, char *vals_defined)
+match_one_of(const char *haystack, const char *needle, char sep)
{
- char *str, *next;
- int want_len = strlen(wanted);
-
- for (str = vals_defined, next = NULL; str != NULL; str = next) {
- int len;
- next = strchr(str, ',');
- if (next) {
- len = next-str;
- next++;
- }
- else {
- len = strlen(str);
- }
+ const char *s = strstr(haystack, needle);
- if (len == want_len && strncmp(wanted, str, len) == 0)
- return true;
- }
+ if (s == NULL)
+ return false;
- return false;
+ if (s != haystack && *s != sep)
+ return false;
+
+ s += strlen(needle);
+ if (*s != '\0' && *s != sep)
+ return false;
+
+ return true;
}
static int
if (rule->option != NULL) {
if (mdefs->options == NULL)
return 0;
- if ((!MatchOneOf(rule->option,mdefs->options)))
+ if ((!match_one_of(mdefs->options, rule->option, ',')))
return 0;
}