aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/config-parser.c35
-rw-r--r--tests/common/check_config_parser.c18
2 files changed, 9 insertions, 44 deletions
diff --git a/src/common/config-parser.c b/src/common/config-parser.c
index 7c19d78..b890c6c 100644
--- a/src/common/config-parser.c
+++ b/src/common/config-parser.c
@@ -21,12 +21,10 @@ typedef enum {
CONFIG_SECTION_KEY,
CONFIG_SECTION_VALUE_START,
CONFIG_SECTION_VALUE_QUOTE,
- CONFIG_SECTION_VALUE_SQUOTE,
CONFIG_SECTION_VALUE_POST_QUOTED,
CONFIG_SECTION_VALUE,
CONFIG_SECTION_LIST_START,
CONFIG_SECTION_LIST_QUOTE,
- CONFIG_SECTION_LIST_SQUOTE,
CONFIG_SECTION_LIST_POST_QUOTED,
CONFIG_SECTION_LIST,
} bc_configparser_state_t;
@@ -199,10 +197,6 @@ bc_config_parse(const char *src, size_t src_len, const char *list_sections[],
state = CONFIG_SECTION_VALUE_QUOTE;
break;
}
- if (c == '\'') {
- state = CONFIG_SECTION_VALUE_SQUOTE;
- break;
- }
bc_string_append_c(value, c);
state = CONFIG_SECTION_VALUE;
break;
@@ -220,19 +214,6 @@ bc_config_parse(const char *src, size_t src_len, const char *list_sections[],
bc_string_append_c(value, c);
break;
- case CONFIG_SECTION_VALUE_SQUOTE:
- if (c == '\'') {
- bc_trie_insert(section->data, bc_str_strip(key),
- bc_string_free(value, false));
- free(key);
- key = NULL;
- value = NULL;
- state = CONFIG_SECTION_VALUE_POST_QUOTED;
- break;
- }
- bc_string_append_c(value, c);
- break;
-
case CONFIG_SECTION_VALUE_POST_QUOTED:
if (c == ' ' || c == '\t' || c == '\f' || c == '\v')
break;
@@ -268,10 +249,6 @@ bc_config_parse(const char *src, size_t src_len, const char *list_sections[],
state = CONFIG_SECTION_LIST_QUOTE;
break;
}
- if (c == '\'') {
- state = CONFIG_SECTION_LIST_SQUOTE;
- break;
- }
bc_string_append_c(value, c);
state = CONFIG_SECTION_LIST;
break;
@@ -288,18 +265,6 @@ bc_config_parse(const char *src, size_t src_len, const char *list_sections[],
bc_string_append_c(value, c);
break;
- case CONFIG_SECTION_LIST_SQUOTE:
- if (c == '\'') {
- section->data = bc_slist_append(section->data,
- bc_string_free(value, false));
- value = NULL;
- state = CONFIG_SECTION_LIST_POST_QUOTED;
- break;
-
- }
- bc_string_append_c(value, c);
- break;
-
case CONFIG_SECTION_LIST_POST_QUOTED:
if (c == ' ' || c == '\t' || c == '\f' || c == '\v')
break;
diff --git a/tests/common/check_config_parser.c b/tests/common/check_config_parser.c
index 7c3cb4a..f7197fe 100644
--- a/tests/common/check_config_parser.c
+++ b/tests/common/check_config_parser.c
@@ -537,12 +537,12 @@ test_config_quoted_values(void **state)
assert_string_equal(bc_config_get(c, "foo", "a"), "lol");
assert_string_equal(bc_config_get(c, "foo", "b"), "lo\"l");
assert_string_equal(bc_config_get(c, "foo", "c"), "lo'l");
- assert_string_equal(bc_config_get(c, "foo", "d"), "lol");
- assert_string_equal(bc_config_get(c, "foo", "e"), "lo'l");
- assert_string_equal(bc_config_get(c, "foo", "f"), "lo\"l");
+ assert_string_equal(bc_config_get(c, "foo", "d"), "'lol'");
+ assert_string_equal(bc_config_get(c, "foo", "e"), "'lo'l'");
+ assert_string_equal(bc_config_get(c, "foo", "f"), "'lo\"l'");
assert_string_equal(bc_config_get(c, "foo", "g"), "\\asd");
assert_string_equal(bc_config_get(c, "foo", "h"), "\\asd");
- assert_string_equal(bc_config_get(c, "foo", "i"), "\\asd");
+ assert_string_equal(bc_config_get(c, "foo", "i"), "'\\asd'");
bc_config_free(c);
a =
@@ -578,17 +578,17 @@ test_config_quoted_values(void **state)
assert_string_equal(bar[0], "lol");
assert_string_equal(bar[1], "lo\"l");
assert_string_equal(bar[2], "lo'l");
- assert_string_equal(bar[3], "lol");
- assert_string_equal(bar[4], "lo'l");
- assert_string_equal(bar[5], "lo\"l");
+ assert_string_equal(bar[3], "'lol'");
+ assert_string_equal(bar[4], "'lo'l'");
+ assert_string_equal(bar[5], "'lo\"l'");
assert_string_equal(bar[6], "\\asd");
assert_string_equal(bar[7], "\\asd");
- assert_string_equal(bar[8], "\\asd");
+ assert_string_equal(bar[8], "'\\asd'");
assert_null(bar[9]);
bc_strv_free(bar);
bar = bc_config_get_list(c, "bar");
assert_non_null(bar);
- assert_string_equal(bar[0], "lol = hehe");
+ assert_string_equal(bar[0], "'lol = hehe'");
assert_string_equal(bar[1], " asdasdadssad ");
assert_null(bar[2]);
bc_strv_free(bar);