From: Assaf Gordon Date: Tue, 10 Mar 2015 21:02:02 +0000 (-0400) Subject: partial handling of input errors X-Git-Tag: jq-1.5rc2~128 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e0db6dd658f4f791d67de4a7b00d8fc159af15a;p=jq partial handling of input errors Signed-off-by: Nicolas Williams --- diff --git a/util.c b/util.c index 6e0ab27..31a1768 100644 --- a/util.c +++ b/util.c @@ -221,7 +221,13 @@ static jv next_file(jq_util_input_state state) { } int jq_util_input_read_more(jq_util_input_state state) { - if (!state->current_input || feof(state->current_input)) { + if (!state->current_input || feof(state->current_input) || ferror(state->current_input)) { + if (state->current_input && ferror(state->current_input)) { + // System-level input error on the stream. It will be closed (below). + // TODO: report it. Can't use 'state->err_cb()' as it is hard-coded for + // 'open' related problems. + fprintf(stderr,"Input error: %s\n", strerror(errno)); + } if (state->current_input) { if (state->current_input == stdin) { clearerr(stdin); // perhaps we can read again; anyways, we don't fclose(stdin)