(maybe even complain!)
SCCS-vsn: usr.bin/ex/ex3.7preserve/ex3.7preserve.c 7.16
#endif not lint
#ifndef lint
#endif not lint
#ifndef lint
-static char *sccsid = "@(#)ex3.7preserve.c 7.15 (Berkeley) %G%";
+static char *sccsid = "@(#)ex3.7preserve.c 7.16 (Berkeley) %G%";
#endif not lint
#include <sys/param.h>
#endif not lint
#include <sys/param.h>
register DIR *tf;
struct direct *dirent;
struct stat stbuf;
register DIR *tf;
struct direct *dirent;
struct stat stbuf;
+ int err = 0;
+ char path[MAXPATHLEN];
+
+ if (chdir(_PATH_PRESERVE) < 0) {
+ perror(_PATH_PRESERVE);
+ exit(1);
+ }
/*
* If only one argument, then preserve the standard input.
/*
* If only one argument, then preserve the standard input.
- * ... else preserve all the stuff in /tmp, removing
+ * ... else preserve all the stuff in /var/tmp, removing
- if (chdir(_PATH_VARTMP) < 0) {
- perror(_PATH_VARTMP);
- exit(1);
- }
+ tf = opendir(_PATH_VARTMP);
if (tf == NULL) {
perror(_PATH_VARTMP);
exit(1);
if (tf == NULL) {
perror(_PATH_VARTMP);
exit(1);
/* Ex temporaries must begin with Ex. */
if (dirent->d_name[0] != 'E' || dirent->d_name[1] != 'x')
continue;
/* Ex temporaries must begin with Ex. */
if (dirent->d_name[0] != 'E' || dirent->d_name[1] != 'x')
continue;
- if (stat(dirent->d_name, &stbuf))
+ sprintf(path, "%s/%s", _PATH_VARTMP, dirent->d_name);
+ if (stat(path, &stbuf))
continue;
if ((stbuf.st_mode & S_IFMT) != S_IFREG)
continue;
/*
* Save the bastard.
*/
continue;
if ((stbuf.st_mode & S_IFMT) != S_IFREG)
continue;
/*
* Save the bastard.
*/
- ignore(copyout(dirent->d_name));
-char pattern[MAXPATHLEN];
+char pattern[] = "Exaa`XXXXX";
/*
* Copy file name into pattern[].
/*
* Copy file name into pattern[].
static int reenter;
char buf[BUFSIZ];
static int reenter;
char buf[BUFSIZ];
- (void)sprintf(pattern, "%s/Exaa`XXXXX", _PATH_PRESERVE);
/*
* The first time we put in the digits of our
* process number at the end of the pattern.
/*
* The first time we put in the digits of our
* process number at the end of the pattern.
* (see below).
*/
if (open(name, 2) < 0)
* (see below).
*/
if (open(name, 2) < 0)
format:
if (name == 0)
fprintf(stderr, "Buffer format error\t");
format:
if (name == 0)
fprintf(stderr, "Buffer format error\t");
- * Consistency checsks so we don't copy out garbage.
+ * Consistency checks so we don't copy out garbage.
*/
if (H.Flines < 0) {
#ifdef DEBUG
*/
if (H.Flines < 0) {
#ifdef DEBUG
if (name)
perror("Buffer read error");
ignore(unlink(pattern));
if (name)
perror("Buffer read error");
ignore(unlink(pattern));
}
if (i == 0) {
if (name)
}
if (i == 0) {
if (name)
if (name == 0)
perror(pattern);
unlink(pattern);
if (name == 0)
perror(pattern);
unlink(pattern);