Address review comments on parse_boolean

This commit is contained in:
Brian Ashworth 2018-07-23 21:37:53 -04:00
parent d56d62c1c0
commit 9ec1d6cf79
2 changed files with 10 additions and 9 deletions

View file

@ -124,17 +124,18 @@ uint32_t parse_color(const char *color) {
}
bool parse_boolean(const char *boolean, bool current) {
if (strcmp(boolean, "1") == 0
|| strcmp(boolean, "yes") == 0
|| strcmp(boolean, "on") == 0
|| strcmp(boolean, "true") == 0
|| strcmp(boolean, "enable") == 0
|| strcmp(boolean, "enabled") == 0
|| strcmp(boolean, "active") == 0) {
if (strcasecmp(boolean, "1") == 0
|| strcasecmp(boolean, "yes") == 0
|| strcasecmp(boolean, "on") == 0
|| strcasecmp(boolean, "true") == 0
|| strcasecmp(boolean, "enable") == 0
|| strcasecmp(boolean, "enabled") == 0
|| strcasecmp(boolean, "active") == 0) {
return true;
} else if (strcmp(boolean, "toggle") == 0) {
} else if (strcasecmp(boolean, "toggle") == 0) {
return !current;
}
// All other values are false to match i3
return false;
}

View file

@ -9,7 +9,7 @@ struct cmd_results *cmd_focus_wrapping(int argc, char **argv) {
return error;
}
if (strcmp(argv[0], "force") == 0) {
if (strcasecmp(argv[0], "force") == 0) {
config->focus_wrapping = WRAP_FORCE;
} else if (parse_boolean(argv[0], config->focus_wrapping == WRAP_YES)) {
config->focus_wrapping = WRAP_YES;