mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
parse-bool.c: add helpers to set bool/int iff valid boolean
This commit is contained in:
parent
ed8999456a
commit
ac1899ada5
3 changed files with 47 additions and 82 deletions
|
|
@ -23,3 +23,22 @@ error_not_a_boolean:
|
|||
return default_value;
|
||||
}
|
||||
|
||||
void
|
||||
set_bool(const char *str, bool *variable)
|
||||
{
|
||||
int ret = parse_bool(str, -1);
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
*variable = ret;
|
||||
}
|
||||
|
||||
void
|
||||
set_bool_as_int(const char *str, int *variable)
|
||||
{
|
||||
int ret = parse_bool(str, -1);
|
||||
if (ret < 0) {
|
||||
return;
|
||||
}
|
||||
*variable = ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue