diff options
author | Max Kellermann <max@duempel.org> | 2009-06-19 09:02:13 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-06-25 08:39:53 +0200 |
commit | 093e900d4453a9f28d442c1c24a9ba59c36b349c (patch) | |
tree | 4592849e7f0707340703096a8735024ced2992b5 /src | |
parent | 8965b66ce4d9c4db1a8fabb386fdcad30f44b4e2 (diff) | |
download | mpd-093e900d4453a9f28d442c1c24a9ba59c36b349c.tar.gz mpd-093e900d4453a9f28d442c1c24a9ba59c36b349c.tar.xz mpd-093e900d4453a9f28d442c1c24a9ba59c36b349c.zip |
conf: moved code from get_bool() to string_array_contains()
Diffstat (limited to '')
-rw-r--r-- | src/conf.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/conf.c b/src/conf.c index 18dc1252b..df6a8c546 100644 --- a/src/conf.c +++ b/src/conf.c @@ -96,20 +96,27 @@ static struct config_entry config_entries[] = { { .name = CONF_GAPLESS_MP3_PLAYBACK, false, false }, }; +static bool +string_array_contains(const char *const* array, const char *value) +{ + for (const char *const* x = array; *x; x++) + if (g_ascii_strcasecmp(*x, value) == 0) + return true; + + return false; +} + static int get_bool(const char *value) { - const char **x; static const char *t[] = { "yes", "true", "1", NULL }; static const char *f[] = { "no", "false", "0", NULL }; - for (x = t; *x; x++) { - if (!g_ascii_strcasecmp(*x, value)) - return 1; - } - for (x = f; *x; x++) { - if (!g_ascii_strcasecmp(*x, value)) - return 0; - } + if (string_array_contains(t, value)) + return true; + + if (string_array_contains(f, value)) + return false; + return CONF_BOOL_INVALID; } |