Fix hang for slurped inputs with trailing newline
This commit is contained in:
1 parent
f06deb828a
commit
79ece35981
2 files changed
+6
-4
No files matched your search
+4
-4
@@ -442,13 +442,13 @@ jv jq_util_input_next_input(jq_util_input_state *state) {
|
|||||||
}
|
}
|
||||||
value = jv_parser_next(state->parser);
|
value = jv_parser_next(state->parser);
|
||||||
if (jv_is_valid(state->slurped)) {
|
if (jv_is_valid(state->slurped)) {
|
||||||
|
// When slurping an input that doesn't have a trailing newline,
|
||||||
|
// we might have more than one value on the same line, so let's check
|
||||||
|
// to see if we have more data to parse.
|
||||||
|
has_more = jv_parser_remaining(state->parser);
|
||||||
if (jv_is_valid(value)) {
|
if (jv_is_valid(value)) {
|
||||||
state->slurped = jv_array_append(state->slurped, value);
|
state->slurped = jv_array_append(state->slurped, value);
|
||||||
value = jv_invalid();
|
value = jv_invalid();
|
||||||
// When slurping an input that doesn't have a trailing newline,
|
|
||||||
// we might have more than one value on the same line, so let's check
|
|
||||||
// to see if we have more data to parse.
|
|
||||||
has_more = jv_parser_remaining(state->parser);
|
|
||||||
} else if (jv_invalid_has_msg(jv_copy(value)))
|
} else if (jv_invalid_has_msg(jv_copy(value)))
|
||||||
return value; // Not slurped parsed input
|
return value; // Not slurped parsed input
|
||||||
} else if (jv_is_valid(value) || jv_invalid_has_msg(jv_copy(value))) {
|
} else if (jv_is_valid(value) || jv_invalid_has_msg(jv_copy(value))) {
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ fi
|
|||||||
echo "[1,2,3,4]" > $d/expected
|
echo "[1,2,3,4]" > $d/expected
|
||||||
printf "[1,2][3,4]" | $JQ -cs add > $d/out 2>&1
|
printf "[1,2][3,4]" | $JQ -cs add > $d/out 2>&1
|
||||||
cmp $d/out $d/expected
|
cmp $d/out $d/expected
|
||||||
|
printf "[1,2][3,4]\n" | $JQ -cs add > $d/out 2>&1
|
||||||
|
cmp $d/out $d/expected
|
||||||
|
|
||||||
|
|
||||||
## Test streaming parser
|
## Test streaming parser
|
||||||
|
|||||||
Reference in new issue
Block a user