aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-23 21:37:53 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-23 21:37:53 -0400
commit9ec1d6cf79e6f9c3233f577c6fddeaeb21bb1bfc (patch)
treebfc136252f81a5350f240c20161d2d0bfc2f80dd
parentRemove unneeded const (diff)
downloadsway-9ec1d6cf79e6f9c3233f577c6fddeaeb21bb1bfc.tar.gz
sway-9ec1d6cf79e6f9c3233f577c6fddeaeb21bb1bfc.tar.zst
sway-9ec1d6cf79e6f9c3233f577c6fddeaeb21bb1bfc.zip
Address review comments on parse_boolean
-rw-r--r--common/util.c17
-rw-r--r--sway/commands/focus_wrapping.c2
2 files changed, 10 insertions, 9 deletions
diff --git a/common/util.c b/common/util.c
index 3fa0c03f..467aa4b5 100644
--- a/common/util.c
+++ b/common/util.c
@@ -124,17 +124,18 @@ uint32_t parse_color(const char *color) {
124} 124}
125 125
126bool parse_boolean(const char *boolean, bool current) { 126bool parse_boolean(const char *boolean, bool current) {
127 if (strcmp(boolean, "1") == 0 127 if (strcasecmp(boolean, "1") == 0
128 || strcmp(boolean, "yes") == 0 128 || strcasecmp(boolean, "yes") == 0
129 || strcmp(boolean, "on") == 0 129 || strcasecmp(boolean, "on") == 0
130 || strcmp(boolean, "true") == 0 130 || strcasecmp(boolean, "true") == 0
131 || strcmp(boolean, "enable") == 0 131 || strcasecmp(boolean, "enable") == 0
132 || strcmp(boolean, "enabled") == 0 132 || strcasecmp(boolean, "enabled") == 0
133 || strcmp(boolean, "active") == 0) { 133 || strcasecmp(boolean, "active") == 0) {
134 return true; 134 return true;
135 } else if (strcmp(boolean, "toggle") == 0) { 135 } else if (strcasecmp(boolean, "toggle") == 0) {
136 return !current; 136 return !current;
137 } 137 }
138 // All other values are false to match i3
138 return false; 139 return false;
139} 140}
140 141
diff --git a/sway/commands/focus_wrapping.c b/sway/commands/focus_wrapping.c
index 15704228..562ee4f9 100644
--- a/sway/commands/focus_wrapping.c
+++ b/sway/commands/focus_wrapping.c
@@ -9,7 +9,7 @@ struct cmd_results *cmd_focus_wrapping(int argc, char **argv) {
9 return error; 9 return error;
10 } 10 }
11 11
12 if (strcmp(argv[0], "force") == 0) { 12 if (strcasecmp(argv[0], "force") == 0) {
13 config->focus_wrapping = WRAP_FORCE; 13 config->focus_wrapping = WRAP_FORCE;
14 } else if (parse_boolean(argv[0], config->focus_wrapping == WRAP_YES)) { 14 } else if (parse_boolean(argv[0], config->focus_wrapping == WRAP_YES)) {
15 config->focus_wrapping = WRAP_YES; 15 config->focus_wrapping = WRAP_YES;