diff options
author | bapt <bapt@FreeBSD.org> | 2016-06-04 14:57:25 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2016-06-04 14:57:25 +0000 |
commit | 169b6f53fec4f6b7e1f52e403612137c0632a974 (patch) | |
tree | e1c447042524d8eef8d5c8d4f8b4a9c52489721c /contrib/libucl/src/ucl_parser.c | |
parent | 86c919b7d71952f8f50701f269aa3485e7084629 (diff) | |
parent | 2d6424b082c4633bf5d115fabeb6620cf2a98f22 (diff) | |
download | FreeBSD-src-169b6f53fec4f6b7e1f52e403612137c0632a974.zip FreeBSD-src-169b6f53fec4f6b7e1f52e403612137c0632a974.tar.gz |
Import libucl snapshot 20160604
It replaces xxhash with mumhash
It fixes issues with msgpack on non x86
Diffstat (limited to 'contrib/libucl/src/ucl_parser.c')
-rw-r--r-- | contrib/libucl/src/ucl_parser.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/contrib/libucl/src/ucl_parser.c b/contrib/libucl/src/ucl_parser.c index 0aaa4dd..fc7cea0 100644 --- a/contrib/libucl/src/ucl_parser.c +++ b/contrib/libucl/src/ucl_parser.c @@ -2597,12 +2597,7 @@ ucl_parser_add_chunk_full (struct ucl_parser *parser, const unsigned char *data, return false; } - if (len == 0) { - parser->top_obj = ucl_object_new_full (UCL_OBJECT, priority); - return true; - } - - if (data == NULL) { + if (data == NULL && len != 0) { ucl_create_err (&parser->err, "invalid chunk added"); return false; } @@ -2613,6 +2608,7 @@ ucl_parser_add_chunk_full (struct ucl_parser *parser, const unsigned char *data, ucl_create_err (&parser->err, "cannot allocate chunk structure"); return false; } + chunk->begin = data; chunk->remain = len; chunk->pos = chunk->begin; @@ -2631,12 +2627,27 @@ ucl_parser_add_chunk_full (struct ucl_parser *parser, const unsigned char *data, return false; } - switch (parse_type) { - default: - case UCL_PARSE_UCL: - return ucl_state_machine (parser); - case UCL_PARSE_MSGPACK: - return ucl_parse_msgpack (parser); + if (len > 0) { + /* Need to parse something */ + switch (parse_type) { + default: + case UCL_PARSE_UCL: + return ucl_state_machine (parser); + case UCL_PARSE_MSGPACK: + return ucl_parse_msgpack (parser); + } + } + else { + /* Just add empty chunk and go forward */ + if (parser->top_obj == NULL) { + /* + * In case of empty object, create one to indicate that we've + * read something + */ + parser->top_obj = ucl_object_new_full (UCL_OBJECT, priority); + } + + return true; } } |