From 0d9976f4e5962990a5d3fba42cb6c2b6f9845683 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 24 Jul 2012 14:11:05 +0200 Subject: [PATCH] Detect I/O errors --- xsv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xsv.c b/xsv.c index 8a84bb5..56f5583 100644 --- a/xsv.c +++ b/xsv.c @@ -409,6 +409,9 @@ static int tmp_read(void) *line_push(&in_line) = x; } } + + if (ferror_unlocked(tf)) + die("I/O error when reading temporary file"); } static void tmp_write(void) @@ -439,6 +442,9 @@ static void tmp_write(void) *intarray_nth(w, i) = fw; } putc_unlocked(0xff, tf); + + if (ferror_unlocked(tf)) + die("I/O error when writing temporary file"); } /*** Transforms ***/ @@ -519,6 +525,8 @@ static void one_pass(void) in_field = NULL; if (!in_format->read_line()) break; + if (ferror_unlocked(stdin)) + die("I/O error when reading standard input"); if (want_trim) trim_fields(); @@ -527,6 +535,8 @@ static void one_pass(void) select_fields(); out_format->write_line(); + if (ferror_unlocked(stdout)) + die("I/O error when writing standard input"); } } -- 2.39.2