Module Name: src
Committed By: christos
Date: Sun Jun 14 21:05:40 UTC 2009
Modified Files:
src/dist/nawk: run.c
Log Message:
purge/flush 0,1,2 since we did not open them, we should not be closing them.
s/EOF/-1/ as the documentation for fclose/pclose states.
To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/dist/nawk/run.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/dist/nawk/run.c
diff -u src/dist/nawk/run.c:1.25 src/dist/nawk/run.c:1.26
--- src/dist/nawk/run.c:1.25 Sun Oct 19 15:33:47 2008
+++ src/dist/nawk/run.c Sun Jun 14 17:05:40 2009
@@ -1616,7 +1616,7 @@
flush_all(); /* fflush() or fflush("") -> all */
u = 0;
} else if ((fp = openfile(FFLUSH, getsval(x))) == NULL)
- u = EOF;
+ u = -1;
else
u = fflush(fp);
break;
@@ -1821,7 +1821,7 @@
stat = pclose(files[i].fp);
else
stat = fclose(files[i].fp);
- if (stat == EOF)
+ if (stat == -1)
WARNING( "i/o error occurred closing %s", files[i].fname );
if (i > 2) /* don't do /dev/std... */
xfree(files[i].fname);
@@ -1844,11 +1844,15 @@
if (files[i].fp) {
if (ferror(files[i].fp))
WARNING( "i/o error occurred on %s", files[i].fname );
- if (files[i].mode == '|' || files[i].mode == LE)
+ if (i == 0)
+ stat = fpurge(files[i].fp);
+ else if (i < 2)
+ stat = fflush(files[i].fp);
+ else if (files[i].mode == '|' || files[i].mode == LE)
stat = pclose(files[i].fp);
else
stat = fclose(files[i].fp);
- if (stat == EOF)
+ if (stat == -1)
WARNING( "i/o error occurred while closing %s", files[i].fname );
}
}