From 3fba18a9c6ffa24e7f31afd7bd6bb4ede464e51d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 13 Nov 2013 17:43:50 +0000 Subject: [PATCH] Sync with libucl. --- src/ucl/src/ucl_parser.c | 73 ++++++++++++++-------------------------- 1 file 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; } } -- 2.39.5