]> mj.ucw.cz Git - xsv.git/commitdiff
Detect I/O errors
authorMartin Mares <mj@ucw.cz>
Tue, 24 Jul 2012 12:11:05 +0000 (14:11 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 24 Jul 2012 12:11:05 +0000 (14:11 +0200)
xsv.c

diff --git a/xsv.c b/xsv.c
index 8a84bb5bf84936ad177eef1dc14a4c1cbd1ea77d..56f558369089eebfd6e0eb606062587dd6323dd4 100644 (file)
--- 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");
        }
 }