* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)close.c 5.2 7/30/85
* f_clos(): f77 file close
* f_exit(): I/O library exit routines
static char FROM_OPEN
[] = "\2";
static char clse
[] = "close";
if(not_legal(lunit
)) return(OK
);
if(lunit
==STDERR
&& (!a
->csta
|| *a
->csta
!= FROM_OPEN
[0]))
err(errflag
,F_ERUNIT
,"can't close stderr");
if(a
->csta
&& *a
->csta
!= FROM_OPEN
[0])
if(b
->ufnm
) unlink(b
->ufnm
); /*SYSDEP*/
if(b
->uwrt
&& (n
=t_runc(b
,errflag
,clse
))) return(n
);
else if(b
->uscrtch
) goto delete;
if(b
->ufnm
) free(b
->ufnm
);
ftnint lu
, dofirst
= YES
;
for(lu
=STDOUT
; (dofirst
|| lu
!=STDOUT
); lu
= ++lu
% MXUNIT
)
if (b
->url
|| !b
->useek
|| !b
->ufnm
)
return (OK
); /* don't truncate direct access files, etc. */
if (truncate (b
->ufnm
, loc
) != 0)
if (b
->uwrt
&& ! nowreading(b
))