config-parser: Make get_bool be bool

Wayland innovated a lot of cool things, but non-binary boolean values is
the great advances of our time.

Make config_parser_get_bool() work on boolean values, and switch all its
users.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone
2019-11-26 00:14:24 +00:00
committed by Daniel Stone
parent 0a4f6e7d6d
commit 51d995ad82
7 changed files with 83 additions and 75 deletions
+16 -12
View File
@@ -322,51 +322,55 @@ ZUC_TEST_F(config_test_t1, test009, data)
ZUC_TEST_F(config_test_t1, test010, data)
{
int r, b;
int r;
bool b;
struct weston_config_section *section;
struct weston_config *config = data;
section = weston_config_get_section(config, "bar", NULL, NULL);
r = weston_config_section_get_bool(section, "flag", &b, 600);
r = weston_config_section_get_bool(section, "flag", &b, true);
ZUC_ASSERT_EQ(0, r);
ZUC_ASSERT_EQ(0, b);
ZUC_ASSERT_EQ(false, b);
}
ZUC_TEST_F(config_test_t1, test011, data)
{
int r, b;
int r;
bool b;
struct weston_config_section *section;
struct weston_config *config = data;
section = weston_config_get_section(config, "stuff", NULL, NULL);
r = weston_config_section_get_bool(section, "flag", &b, -1);
r = weston_config_section_get_bool(section, "flag", &b, false);
ZUC_ASSERT_EQ(0, r);
ZUC_ASSERT_EQ(1, b);
ZUC_ASSERT_EQ(true, b);
}
ZUC_TEST_F(config_test_t1, test012, data)
{
int r, b;
int r;
bool b;
struct weston_config_section *section;
struct weston_config *config = data;
section = weston_config_get_section(config, "stuff", NULL, NULL);
r = weston_config_section_get_bool(section, "flag", &b, -1);
r = weston_config_section_get_bool(section, "flag", &b, false);
ZUC_ASSERT_EQ(0, r);
ZUC_ASSERT_EQ(1, b);
ZUC_ASSERT_EQ(true, b);
}
ZUC_TEST_F(config_test_t1, test013, data)
{
int r, b;
int r;
bool b;
struct weston_config_section *section;
struct weston_config *config = data;
section = weston_config_get_section(config, "stuff", NULL, NULL);
r = weston_config_section_get_bool(section, "bonk", &b, -1);
r = weston_config_section_get_bool(section, "bonk", &b, false);
ZUC_ASSERT_EQ(-1, r);
ZUC_ASSERT_EQ(ENOENT, errno);
ZUC_ASSERT_EQ(-1, b);
ZUC_ASSERT_EQ(false, b);
}
ZUC_TEST_F(config_test_t1, test014, data)