aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2020-02-06 22:38:30 +0200
committerArnold D. Robbins <arnold@skeeve.com>2020-02-06 22:38:30 +0200
commite6fe674b404151c66440fd76bca7708cf3a2fe37 (patch)
treecb86d1b8f61a2faf95376a98dac6ad779efc4d4f
parentcd552112a7c9d4d8892190fef4b45c646d43ad5d (diff)
downloadone-true-awk-e6fe674b404151c66440fd76bca7708cf3a2fe37.tar.gz
Restore zoulas fixes, stage 3.
-rw-r--r--run.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/run.c b/run.c
index 0354ed2..4270e54 100644
--- a/run.c
+++ b/run.c
@@ -1850,23 +1850,24 @@ const char *filename(FILE *fp)
void closeall(void)
{
- int i, stat;
-
- for (i = 0; i < FOPEN_MAX; i++) {
- if (files[i].fp) {
- if (ferror(files[i].fp))
- FATAL( "i/o error occurred on %s", files[i].fname );
- if (files[i].mode == '|' || files[i].mode == LE)
- stat = pclose(files[i].fp);
- else
- stat = fclose(files[i].fp);
- if (stat == EOF)
- FATAL( "i/o error occurred while closing %s", files[i].fname );
- }
+ size_t i;
+ bool stat = false;
+
+ for (i = 0; i < nfiles; i++) {
+ if (! files[i].fp)
+ continue;
+ if (ferror(files[i].fp))
+ FATAL( "i/o error occurred on %s", files[i].fname );
+ if (files[i].mode == '|' || files[i].mode == LE)
+ stat = pclose(files[i].fp) == -1;
+ else
+ stat = fclose(files[i].fp) == EOF;
+ if (stat)
+ FATAL( "i/o error occurred while closing %s", files[i].fname );
}
}
-void flush_all(void)
+static void flush_all(void)
{
int i;