mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Fix #1534
This commit is contained in:
@@ -410,6 +410,7 @@ jv jq_util_input_get_current_line(jq_state* jq) {
|
|||||||
// When slurping, it returns just one value
|
// When slurping, it returns just one value
|
||||||
jv jq_util_input_next_input(jq_util_input_state *state) {
|
jv jq_util_input_next_input(jq_util_input_state *state) {
|
||||||
int is_last = 0;
|
int is_last = 0;
|
||||||
|
int has_more = 0;
|
||||||
jv value = jv_invalid(); // need more input
|
jv value = jv_invalid(); // need more input
|
||||||
do {
|
do {
|
||||||
if (state->parser == NULL) {
|
if (state->parser == NULL) {
|
||||||
@@ -444,13 +445,17 @@ jv jq_util_input_next_input(jq_util_input_state *state) {
|
|||||||
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))) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!is_last);
|
} while (!is_last || has_more);
|
||||||
|
|
||||||
if (jv_is_valid(state->slurped)) {
|
if (jv_is_valid(state->slurped)) {
|
||||||
value = state->slurped;
|
value = state->slurped;
|
||||||
|
@@ -122,6 +122,12 @@ if $VALGRIND $Q $JQ -e . $d/input; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Regression test for #1534
|
||||||
|
echo "[1,2,3,4]" > $d/expected
|
||||||
|
printf "[1,2][3,4]" | $JQ -cs add > $d/out 2>&1
|
||||||
|
cmp $d/out $d/expected
|
||||||
|
|
||||||
|
|
||||||
## Test streaming parser
|
## Test streaming parser
|
||||||
|
|
||||||
## If we add an option to stream to the `import ... as $symbol;` directive
|
## If we add an option to stream to the `import ... as $symbol;` directive
|
||||||
|
Reference in New Issue
Block a user