parse-xml.c: add get_bool() function

The boolean "autogroup" was parsed as an integer. In principle OK, but
let's make the type more explicit by introducing a get_bool() function.

Suggested-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-01-04 15:47:12 +01:00 committed by Dirk Hohndel
parent 40fa148548
commit 5960718075

View file

@ -457,6 +457,11 @@ static void get_index(char *buffer, int *i)
*i = atoi(buffer); *i = atoi(buffer);
} }
static void get_bool(char *buffer, bool *i)
{
*i = atoi(buffer);
}
static void get_uint8(char *buffer, uint8_t *i) static void get_uint8(char *buffer, uint8_t *i)
{ {
*i = atoi(buffer); *i = atoi(buffer);
@ -610,10 +615,10 @@ static void eventtime(char *buffer, duration_t *duration)
static void try_to_match_autogroup(const char *name, char *buf) static void try_to_match_autogroup(const char *name, char *buf)
{ {
int autogroupvalue; bool autogroupvalue;
start_match("autogroup", name, buf); start_match("autogroup", name, buf);
if (MATCH("state.autogroup", get_index, &autogroupvalue)) { if (MATCH("state.autogroup", get_bool, &autogroupvalue)) {
set_autogroup(autogroupvalue); set_autogroup(autogroupvalue);
return; return;
} }