diff options
Diffstat (limited to 'contrib/libucl')
-rw-r--r-- | contrib/libucl/lua/lua_ucl.c | 4 | ||||
-rw-r--r-- | contrib/libucl/src/ucl_parser.c | 77 |
2 files changed, 42 insertions, 39 deletions
diff --git a/contrib/libucl/lua/lua_ucl.c b/contrib/libucl/lua/lua_ucl.c index d6be69e42a71..1b3f9dfd111c 100644 --- a/contrib/libucl/lua/lua_ucl.c +++ b/contrib/libucl/lua/lua_ucl.c @@ -30,6 +30,8 @@ #include "lua_ucl.h" #include <strings.h> +#include "bootstrap.h" + /*** * @module ucl * This lua module allows to parse objects from strings and to store data into @@ -1571,3 +1573,5 @@ ucl_object_toclosure (const ucl_object_t *obj) return (struct ucl_lua_funcdata*)obj->value.ud; } + +FLUA_MODULE(ucl); diff --git a/contrib/libucl/src/ucl_parser.c b/contrib/libucl/src/ucl_parser.c index 6be16d12169c..728cd6381056 100644 --- a/contrib/libucl/src/ucl_parser.c +++ b/contrib/libucl/src/ucl_parser.c @@ -164,51 +164,50 @@ start: } } } - else if (chunk->remain >= 2 && *p == '/') { - if (p[1] == '*') { - beg = p; - ucl_chunk_skipc (chunk, p); - comments_nested ++; - ucl_chunk_skipc (chunk, p); - - while (p < chunk->end) { - if (*p == '"' && *(p - 1) != '\\') { - quoted = !quoted; - } - - if (!quoted) { - if (*p == '*') { - ucl_chunk_skipc (chunk, p); - if (chunk->remain > 0 && *p == '/') { - comments_nested --; - if (comments_nested == 0) { - if (parser->flags & UCL_PARSER_SAVE_COMMENTS) { - ucl_save_comment (parser, beg, p - beg + 1); - beg = NULL; - } - - ucl_chunk_skipc (chunk, p); - goto start; - } - } - ucl_chunk_skipc (chunk, p); - } - else if (p[0] == '/' && chunk->remain >= 2 && p[1] == '*') { - comments_nested ++; - ucl_chunk_skipc (chunk, p); - ucl_chunk_skipc (chunk, p); - continue; + else if (chunk->remain >= 2 && *p == '/' && p[1] == '*') { + beg = p; + comments_nested ++; + ucl_chunk_skipc (chunk, p); + ucl_chunk_skipc (chunk, p); + while (p < chunk->end) { + if (*p == '"' && *(p - 1) != '\\') { + /* begin or end double-quoted string */ + quoted = !quoted; + ucl_chunk_skipc (chunk, p); + } + else if (quoted) { + /* quoted character */ + ucl_chunk_skipc (chunk, p); + } + else if (chunk->remain >= 2 && *p == '*' && p[1] == '/') { + /* end of comment */ + ucl_chunk_skipc (chunk, p); + ucl_chunk_skipc (chunk, p); + comments_nested --; + if (comments_nested == 0) { + if (parser->flags & UCL_PARSER_SAVE_COMMENTS) { + ucl_save_comment (parser, beg, p - beg + 1); + beg = NULL; } + goto start; } - + } + else if (chunk->remain >= 2 && *p == '/' && p[1] == '*') { + /* start of nested comment */ + comments_nested ++; + ucl_chunk_skipc (chunk, p); ucl_chunk_skipc (chunk, p); } - if (comments_nested != 0) { - ucl_set_err (parser, UCL_ENESTED, - "unfinished multiline comment", &parser->err); - return false; + else { + /* anything else */ + ucl_chunk_skipc (chunk, p); } } + if (comments_nested != 0) { + ucl_set_err (parser, UCL_ENESTED, + "unfinished multiline comment", &parser->err); + return false; + } } if (beg && p > beg && (parser->flags & UCL_PARSER_SAVE_COMMENTS)) { |