too much information...
[unix-history] / usr / src / usr.bin / pascal / libpc / PCLOSE.c
index 5c2d22c..3cfe9be 100644 (file)
@@ -1,9 +1,13 @@
 /* Copyright (c) 1979 Regents of the University of California */
 
 /* Copyright (c) 1979 Regents of the University of California */
 
-static char sccsid[] = "@(#)PCLOSE.c 1.3 %G%";
+static char sccsid[] = "@(#)PCLOSE.c 1.6 %G%";
+
+/*
+ * Close all files associated with the topmost stack frame.
+ */
 
 #include "h00vars.h"
 
 #include "h00vars.h"
-#include "h01errs.h"
+#include "libpc.h"
 
 PCLOSE(level)
 
 
 PCLOSE(level)
 
@@ -13,26 +17,7 @@ PCLOSE(level)
 
        next = _fchain.fchain;
        while(next != FILNIL && next->flev <= level) {
 
        next = _fchain.fchain;
        while(next != FILNIL && next->flev <= level) {
-               if (next->fbuf != 0) {
-                       if ((next->funit & FDEF) == 0) {
-                               if (next->fblk > PREDEF) {
-                                       fflush(next->fbuf);
-                                       setbuf(next->fbuf, NULL);
-                               }
-                               fclose(next->fbuf);
-                               if (ferror(next->fbuf)) {
-                                       ERROR(ECLOSE, next->pfname);
-                                       return;
-                               }
-                       }
-                       if ((next->funit & TEMP) != 0 &&
-                           unlink(next->pfname)) {
-                               ERROR(EREMOVE, next->pfname);
-                               return;
-                       }
-               }
-               _actfile[next->fblk] = FILNIL;
-               next = next->fchain;
+               next = PFCLOSE(next, TRUE);
        }
        _fchain.fchain = next;
 }
        }
        _fchain.fchain = next;
 }