From dab5711bd39487bf8daf85eb5fed239d559c04a3 Mon Sep 17 00:00:00 2001 From: Eddy Ashton Date: Tue, 23 Nov 2021 18:39:13 +0000 Subject: [PATCH 1/2] Hack in a fix --- src/util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util.c b/src/util.c index 9af5471df5..4555efbedf 100644 --- a/src/util.c +++ b/src/util.c @@ -411,6 +411,11 @@ jv jq_util_input_next_input(jq_util_input_state *state) { is_last = jq_util_input_read_more(state); if (state->buf_valid_len == 0) continue; + if (state->current_input && feof(state->current_input)) + { + state->current_line++; + is_last = 1; + } if (jv_is_valid(state->slurped)) { // Slurped raw input state->slurped = jv_string_concat(state->slurped, jv_string_sized(state->buf, state->buf_valid_len)); From 5ab4b24e2be0d2260d0d45725b83706ef93b966f Mon Sep 17 00:00:00 2001 From: Eddy Ashton Date: Tue, 23 Nov 2021 18:39:32 +0000 Subject: [PATCH 2/2] Add a regression test --- tests/shtest | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/shtest b/tests/shtest index 8ed62b2213..34302d3328 100755 --- a/tests/shtest +++ b/tests/shtest @@ -150,6 +150,12 @@ cmp $d/out $d/expected printf "[1,2][3,4]\n" | $JQ -cs add > $d/out 2>&1 cmp $d/out $d/expected +# Regression test for #2374 +printf "Line 1\nLine 2\nLine 3" > $d/a +printf "Line 4\nLine 5" > $d/b +echo '{"'$d/a'":{"1":"Line 1","2":"Line 2","3":"Line 3"},"'$d/b'":{"1":"Line 4","2":"Line 5"}}' > $d/expected +$JQ -Rnc 'reduce inputs as $line ({}; .[input_filename] += {(input_line_number|tostring): $line})' $d/a $d/b > $d/out 2>&1 +cmp $d/out $d/expected ## Test streaming parser