diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-06-28 19:43:15 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-06-28 19:43:15 +0200 |
commit | 8fef8185237b1acb8e2f45b3ee46a1386e340e9d (patch) | |
tree | 510c3b8b20c5388a01f03589fbd57771590b0e0b | |
parent | 0ae85f6545b1d4a64836b0a3a5676a0bed9854d5 (diff) | |
download | blogc-8fef8185237b1acb8e2f45b3ee46a1386e340e9d.tar.gz blogc-8fef8185237b1acb8e2f45b3ee46a1386e340e9d.tar.bz2 blogc-8fef8185237b1acb8e2f45b3ee46a1386e340e9d.zip |
allow source config keys without value
-rw-r--r-- | src/blogc/source-parser.c | 7 | ||||
-rw-r--r-- | tests/blogc/check_source_parser.c | 11 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/blogc/source-parser.c b/src/blogc/source-parser.c index 65ba982..cabc033 100644 --- a/src/blogc/source-parser.c +++ b/src/blogc/source-parser.c @@ -111,9 +111,10 @@ blogc_source_parse(const char *src, size_t src_len, bc_error_t **err) start = current; break; } - *err = bc_error_parser(BLOGC_ERROR_SOURCE_PARSER, src, src_len, - current, "Configuration value not provided for '%s'.", - key); + bc_trie_insert(rv, key, bc_strdup("")); + free(key); + key = NULL; + state = SOURCE_START; break; case SOURCE_CONFIG_VALUE: diff --git a/tests/blogc/check_source_parser.c b/tests/blogc/check_source_parser.c index e58981d..d40633f 100644 --- a/tests/blogc/check_source_parser.c +++ b/tests/blogc/check_source_parser.c @@ -296,16 +296,13 @@ test_source_parse_config_no_key2(void **state) static void test_source_parse_config_no_value(void **state) { + // this is a special case, not an error const char *a = "BOLA:\r\n"; bc_error_t *err = NULL; bc_trie_t *source = blogc_source_parse(a, strlen(a), &err); - assert_null(source); - assert_non_null(err); - assert_int_equal(err->type, BLOGC_ERROR_SOURCE_PARSER); - assert_string_equal(err->msg, - "Configuration value not provided for 'BOLA'.\n" - "Error occurred near line 1, position 6: BOLA:"); - bc_error_free(err); + assert_non_null(source); + assert_null(err); + assert_string_equal(bc_trie_lookup(source, "BOLA"), ""); bc_trie_free(source); } |