err(1, tempname);
err(1, "%s", tempname);
setfile(name)	char *name;{	FILE *ibuf;	int i, fd;	struct stat stb;	char isedit = *name != '%';	char *who = name[1] ? name + 1 : myname;	char tempname[PATHSIZE];	static int shudclob;	if ((name = expand(name)) == NULL)		return(-1);	if ((ibuf = Fopen(name, "r")) == NULL) {		if (!isedit && errno == ENOENT)			goto nomail;		warn(name);		return(-1);	}	if (fstat(fileno(ibuf), &stb) < 0) {		warn("fstat");		(void)Fclose(ibuf);		return(-1);	}	switch (stb.st_mode & S_IFMT) {	case S_IFDIR:		(void)Fclose(ibuf);		errno = EISDIR;		warn(name);		return(-1);	case S_IFREG:		break;	default:		(void)Fclose(ibuf);		errno = EINVAL;		warn(name);		return(-1);	}	/*	 * Looks like all will be well.  We must now relinquish our	 * hold on the current set of stuff.  Must hold signals	 * while we are reading the new file, else we will ruin	 * the message[] data structure.	 */	holdsigs();	if (shudclob)		quit();	/*	 * Copy the messages into /tmp	 * and set pointers.	 */	readonly = 0;	if ((i = open(name, 1)) < 0)		readonly++;	else		(void)close(i);	if (shudclob) {		(void)fclose(itf);		(void)fclose(otf);	}	shudclob = 1;	edit = isedit;	strcpy(prevfile, mailname);	if (name != mailname) {		strncpy(mailname, name, sizeof(mailname) - 1);		mailname[sizeof(mailname) - 1] = '\0';	}	mailsize = fsize(ibuf);	(void)snprintf(tempname, sizeof(tempname),	    "%s/mail.RxXXXXXXXXXX", tmpdir);	if ((fd = mkstemp(tempname)) == -1 ||	    (otf = fdopen(fd, "w")) == NULL)		err(1, tempname);	(void)fcntl(fileno(otf), F_SETFD, 1);	if ((itf = fopen(tempname, "r")) == NULL)		err(1, tempname);	(void)fcntl(fileno(itf), F_SETFD, 1);	(void)rm(tempname);	setptr(ibuf, 0);	setmsize(msgCount);	/*	 * New mail may have arrived while we were reading	 * the mail file, so reset mailsize to be where	 * we really are in the file...	 */	mailsize = ftell(ibuf);	(void)Fclose(ibuf);	relsesigs();	sawcom = 0;	if (!edit && msgCount == 0) {nomail:		fprintf(stderr, "No mail for %s\n", who);		return(-1);	}	return(0);}