src/common/parse-bool.c: support on/off boolean values

This commit is contained in:
redtide 2023-09-13 01:06:29 +02:00
parent bd6efe4849
commit 2fc500168a
No known key found for this signature in database
2 changed files with 10 additions and 0 deletions

View file

@ -94,6 +94,12 @@ Elements at the same level can have the same name whereas attributes cannot.
Therefore, where multiple objects of the same kind are required (for example Therefore, where multiple objects of the same kind are required (for example
*<action>* and *<keybind>*) the top-node of the object has to be an element. *<action>* and *<keybind>*) the top-node of the object has to be an element.
## BOOLEANS
Note that in this manual, Boolean values are listed as [yes|no] for simplicity,
but it's also possible to use [true|false] and\/or [on|off];
this is for compatibility with Openbox.
## CORE ## CORE
``` ```

View file

@ -13,10 +13,14 @@ parse_bool(const char *str, int default_value)
return true; return true;
} else if (!strcasecmp(str, "true")) { } else if (!strcasecmp(str, "true")) {
return true; return true;
} else if (!strcasecmp(str, "on")) {
return true;
} else if (!strcasecmp(str, "no")) { } else if (!strcasecmp(str, "no")) {
return false; return false;
} else if (!strcasecmp(str, "false")) { } else if (!strcasecmp(str, "false")) {
return false; return false;
} else if (!strcasecmp(str, "off")) {
return false;
} }
error_not_a_boolean: error_not_a_boolean:
wlr_log(WLR_ERROR, "(%s) is not a boolean value", str); wlr_log(WLR_ERROR, "(%s) is not a boolean value", str);