diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-13 17:43:50 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-11-13 17:43:50 +0000 |
commit | 3fba18a9c6ffa24e7f31afd7bd6bb4ede464e51d (patch) | |
tree | 1bf690c83f4e3982000d20c7ab026cdcc50fb492 /src/ucl | |
parent | ac166ce78d09b02060babcb31b234f486551a15f (diff) | |
download | rspamd-3fba18a9c6ffa24e7f31afd7bd6bb4ede464e51d.tar.gz rspamd-3fba18a9c6ffa24e7f31afd7bd6bb4ede464e51d.zip |
Sync with libucl.
Diffstat (limited to 'src/ucl')
-rw-r--r-- | src/ucl/src/ucl_parser.c | 73 |
1 files changed, 25 insertions, 48 deletions
diff --git a/src/ucl/src/ucl_parser.c b/src/ucl/src/ucl_parser.c index dd0ac4896..450a41877 100644 --- a/src/ucl/src/ucl_parser.c +++ b/src/ucl/src/ucl_parser.c @@ -994,64 +994,41 @@ ucl_parse_value (struct ucl_parser *parser, struct ucl_chunk *chunk) if (parser->state == UCL_STATE_ERROR) { return false; } - if (!ucl_parse_string_value (parser, chunk)) { - return false; - } - if (!ucl_maybe_parse_boolean (obj, c, chunk->pos - c)) { - /* Cut trailing spaces */ - stripped_spaces = 0; - while (ucl_test_character (*(chunk->pos - 1 - stripped_spaces), - UCL_CHARACTER_WHITESPACE)) { - stripped_spaces ++; - } - str_len = chunk->pos - c - stripped_spaces; - if (str_len <= 0) { - ucl_set_err (chunk, 0, "string value must not be empty", &parser->err); - return false; - } - obj->type = UCL_STRING; - if ((str_len = ucl_copy_or_store_ptr (parser, c, &obj->trash_stack[UCL_TRASH_VALUE], - &obj->value.sv, str_len, false, false)) == -1) { - return false; - } - obj->len = str_len; - } - parser->state = UCL_STATE_AFTER_VALUE; - return true; } else { parser->state = UCL_STATE_AFTER_VALUE; return true; } + /* Fallback to normal string */ } - else { - if (!ucl_parse_string_value (parser, chunk)) { + + if (!ucl_parse_string_value (parser, chunk)) { + return false; + } + /* Cut trailing spaces */ + stripped_spaces = 0; + while (ucl_test_character (*(chunk->pos - 1 - stripped_spaces), + UCL_CHARACTER_WHITESPACE)) { + stripped_spaces ++; + } + str_len = chunk->pos - c - stripped_spaces; + if (str_len <= 0) { + ucl_set_err (chunk, 0, "string value must not be empty", &parser->err); + return false; + } + + if (!ucl_maybe_parse_boolean (obj, c, str_len)) { + obj->type = UCL_STRING; + if ((str_len = ucl_copy_or_store_ptr (parser, c, &obj->trash_stack[UCL_TRASH_VALUE], + &obj->value.sv, str_len, false, false)) == -1) { return false; } - if (!ucl_maybe_parse_boolean (obj, c, chunk->pos - c)) { - /* TODO: remove cut&paste */ - /* Cut trailing spaces */ - stripped_spaces = 0; - while (ucl_test_character (*(chunk->pos - 1 - stripped_spaces), - UCL_CHARACTER_WHITESPACE)) { - stripped_spaces ++; - } - str_len = chunk->pos - c - stripped_spaces; - if (str_len <= 0) { - ucl_set_err (chunk, 0, "string value must not be empty", &parser->err); - return false; - } - obj->type = UCL_STRING; - if ((str_len = ucl_copy_or_store_ptr (parser, c, &obj->trash_stack[UCL_TRASH_VALUE], - &obj->value.sv, str_len, false, false)) == -1) { - return false; - } - obj->len = str_len; - } - parser->state = UCL_STATE_AFTER_VALUE; - return true; + obj->len = str_len; } + parser->state = UCL_STATE_AFTER_VALUE; p = chunk->pos; + + return true; break; } } |