are initially opened for reading (and hence do not exist)
SCCS-vsn: usr.bin/pascal/libpc/GETNAME.c 1.5
/* Copyright (c) 1979 Regents of the University of California */
/* 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"
#include "h00vars.h"
#include "h01errs.h"
filep->fchain = next;
prev->fchain = filep;
} else {
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
*/
/*
* have a previous buffer, close associated file
*/
/*
* renamed temporary files are discarded
*/
/*
* 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);
}
}
filep->funit &= (TEMP | FTEXT);
}
/*
* no name given and no previous name, so generate
}
/*
* 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
- 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);
}
filep->pfname = &filep->fname[0];
return(filep);
}