From: Kirk McKusick Date: Mon, 8 Jun 1981 15:39:53 +0000 (-0800) Subject: do not try to close or deallocate buffers for tmp files which X-Git-Tag: BSD-4_1_snap-Snapshot-Development~1226 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/5eec5550c453b5137f7960ca2fd17ba56926fac5 do not try to close or deallocate buffers for tmp files which are initially opened for reading (and hence do not exist) SCCS-vsn: usr.bin/pascal/libpc/GETNAME.c 1.5 --- diff --git a/usr/src/usr.bin/pascal/libpc/GETNAME.c b/usr/src/usr.bin/pascal/libpc/GETNAME.c index 381d09ec07..ed76fc3519 100644 --- a/usr/src/usr.bin/pascal/libpc/GETNAME.c +++ b/usr/src/usr.bin/pascal/libpc/GETNAME.c @@ -1,6 +1,6 @@ /* Copyright (c) 1979 Regents of the University of California */ -static char sccsid[] = "@(#)GETNAME.c 1.4 %G%"; +static char sccsid[] = "@(#)GETNAME.c 1.5 %G%"; #include "h00vars.h" #include "h01errs.h" @@ -71,7 +71,7 @@ GETNAME(filep, name, namlim, datasize) filep->fchain = next; prev->fchain = filep; } else { - if ((filep->funit & FDEF) == 0) { + if ((filep->funit & FDEF) == 0 && filep->fbuf != NULL) { /* * have a previous buffer, close associated file */ @@ -87,11 +87,11 @@ GETNAME(filep, name, namlim, datasize) /* * renamed temporary files are discarded */ - if ((filep->funit & TEMP) && - (name != NULL) && - (unlink(filep->pfname))) { - ERROR(EREMOVE, filep->pfname); - return; + if ((filep->funit & TEMP) && name != NULL) { + if (unlink(filep->pfname)) { + ERROR(EREMOVE, filep->pfname); + return; + } } } filep->funit &= (TEMP | FTEXT); @@ -105,10 +105,10 @@ GETNAME(filep, name, namlim, datasize) } /* * no name given and no previous name, so generate - * a new one of the form tmp.xxxxxx + * a new one of the form #tmp.xxxxxx */ filep->funit |= TEMP; - sprintf(filep->fname, "tmp.%c%d", 'a' + filep->fblk, getpid()); + sprintf(filep->fname, "#tmp.%c%d", 'a' + filep->fblk, getpid()); filep->pfname = &filep->fname[0]; return(filep); }