diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-03-11 15:10:14 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-03-11 15:10:14 +0000 |
| commit | 5a89ac67eb7ee7713034f39a27ce31eb15bc481f (patch) | |
| tree | 3f8bfe945e9e18acd2b031b69fcc7115bdac4ef9 | |
| parent | changelog: updated to mention fix for #3 (diff) | |
config: add str_to_bool()
| -rw-r--r-- | config.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -111,6 +111,15 @@ get_config_path(void) } 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) { if (s == NULL) @@ -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) { |
