partial handling of input errors
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
This commit is contained in:
1 parent
551d875be1
commit
5e0db6dd65
1 file changed
+7
-1
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user