config: add str_to_bool()

This commit is contained in:
Daniel Eklöf 2020-03-11 16:10:14 +01:00
parent 57fe26955f
commit 5a89ac67eb
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -110,6 +110,15 @@ get_config_path(void)
return NULL;
}
static bool
str_to_bool(const char *s)
{
return strcasecmp(s, "on") == 0 ||
strcasecmp(s, "true") == 0 ||
strcasecmp(s, "yes") == 0 ||
strtoul(s, NULL, 0) > 0;
}
static bool
str_to_ulong(const char *s, int base, unsigned long *res)
{
@ -169,11 +178,7 @@ parse_section_main(const char *key, const char *value, struct config *conf,
}
else if (strcmp(key, "login-shell") == 0) {
conf->login_shell = (
strcasecmp(value, "on") == 0 ||
strcasecmp(value, "true") == 0 ||
strcasecmp(value, "yes") == 0) ||
strtoul(value, NULL, 0) > 0;
conf->login_shell = str_to_bool(value);
}
else if (strcmp(key, "geometry") == 0) {