Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ucl_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ struct ucl_macro {

enum ucl_stack_flags {
UCL_STACK_HAS_OBRACE = (1u << 0),
UCL_STACK_MAX = (1u << 1),
UCL_STACK_AUTOMATIC = (1u << 1),
UCL_STACK_MAX = (1u << 2),
};

struct ucl_stack {
Expand Down
12 changes: 9 additions & 3 deletions src/ucl_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2060,8 +2060,12 @@ ucl_parse_after_value (struct ucl_parser *parser, struct ucl_chunk *chunk)
return false;
}

parser->stack = st->next;
UCL_FREE (sizeof (struct ucl_stack), st);
if ((st->e.params.flags & UCL_STACK_AUTOMATIC)) {
st->e.params.flags = 0;
} else {
parser->stack = st->next;
UCL_FREE (sizeof (struct ucl_stack), st);
}

if (parser->cur_obj) {
ucl_attach_comment (parser, parser->cur_obj, true);
Expand Down Expand Up @@ -2501,8 +2505,10 @@ ucl_state_machine (struct ucl_parser *parser)

}
break;
case UCL_STATE_KEY:
case UCL_STATE_KEY_OBRACE:
parser->stack->e.params.flags |= UCL_STACK_HAS_OBRACE | UCL_STACK_AUTOMATIC;
/* FALLTHROUGHT */
case UCL_STATE_KEY:
/* Skip any spaces */
while (p < chunk->end && ucl_test_character (*p, UCL_CHARACTER_WHITESPACE_UNSAFE)) {
ucl_chunk_skipc (chunk, p);
Expand Down
1 change: 1 addition & 0 deletions tests/basic/23-json-with-braces.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "a": "b" }
2 changes: 2 additions & 0 deletions tests/basic/23-json-without-braces.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Note: This is arguably not a valid JSON file, but it is supposed to be parsable UCL.
"b": "c"
1 change: 1 addition & 0 deletions tests/basic/23-ucl-with-braces.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ c = "d"; }
1 change: 1 addition & 0 deletions tests/basic/23-ucl-without-braces.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d = "e";
8 changes: 8 additions & 0 deletions tests/basic/23.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
a = 1;
b = 2;
.include() "${CURDIR}/23-json-with-braces.inc"
.include() "${CURDIR}/23-json-without-braces.inc"
.include() "${CURDIR}/23-ucl-with-braces.inc"
.include() "${CURDIR}/23-ucl-without-braces.inc"
c = 3;
d = 4;
9 changes: 9 additions & 0 deletions tests/basic/23.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
a = 1;
a = "b";
b = 2;
b = "c";
c = "d";
c = 3;
d = "e";
d = 4;