tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Moving virecover to ~/
This is missing:
- Moving virecover to /usr/bin
- Regen'ing autoconf
- Adding it to default ~/.profile
- Removing virecover rc script
? test
? testcase
Index: dist/common/options.c
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/dist/common/options.c,v
retrieving revision 1.5
diff -u -r1.5 options.c
--- dist/common/options.c 6 Nov 2017 03:21:13 -0000 1.5
+++ dist/common/options.c 11 Nov 2017 00:42:55 -0000
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <pwd.h>
#include <unistd.h>
#include "common.h"
@@ -393,7 +394,13 @@
OI(O_PARAGRAPHS, L("paragraphs=IPLPPPQPP LIpplpipbp"));
(void)SPRINTF(b2, SIZE(b2), L("path=%s"), "");
OI(O_PATH, b2);
- (void)SPRINTF(b2, SIZE(b2), L("recdir=%s"), _PATH_PRESERVE);
+
+ if ((s = getenv("HOME")) == NULL) {
+ struct passwd *pw = getpwuid(getuid());
+ s = pw->pw_dir;
+ }
+
+ (void)SPRINTF(b2, SIZE(b2), L("recdir=%s/%s"), s, _PATH_PRESERVE);
OI(O_RECDIR, b2);
OI(O_SECTIONS, L("sections=NHSHH HUnhsh"));
(void)SPRINTF(b2, SIZE(b2),
Index: dist/common/recover.c
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/dist/common/recover.c,v
retrieving revision 1.9
diff -u -r1.9 recover.c
--- dist/common/recover.c 4 Nov 2017 14:20:12 -0000 1.9
+++ dist/common/recover.c 11 Nov 2017 00:42:56 -0000
@@ -37,6 +37,7 @@
#include <fcntl.h>
#include <limits.h>
#include <pwd.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -120,8 +121,36 @@
static char *rcv_gets(char *, size_t, int);
static int rcv_mailfile(SCR *, int, char *);
static int rcv_mktemp(SCR *, char *, const char *, int);
+static void rcv_mkpath(char *path);
/*
+ * rcv_mkpath --
+ * Create a directory
+ */
+static void
+rcv_mkpath(char *path)
+{
+ char *slash;
+ bool done = false;
+
+ slash = path;
+
+ for (;;) {
+ slash += strspn(slash, "/");
+ slash += strcspn(slash, "/");
+
+ done = (*slash == '\0');
+ *slash = '\0';
+
+ mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR);
+
+ if (done) {
+ break;
+ }
+ *slash = '/';
+ }
+}
+/*
* rcv_tmp --
* Build a file name that will be used as the recovery file.
*
@@ -150,10 +179,14 @@
goto err;
dp = O_STR(sp, O_RECDIR);
if (stat(dp, &sb)) {
- if (errno != ENOENT || mkdir(dp, 0)) {
+ if (errno != ENOENT) {
msgq(sp, M_SYSERR, "%s", dp);
goto err;
+ } else /* ENOENT, create the directory */ {
+ (void)snprintf(path, sizeof(path), "%s", dp);
+ rcv_mkpath(path);
}
+
(void)chmod(dp, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
}
Index: dist/dist/configure.ac
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/dist/dist/configure.ac,v
retrieving revision 1.2
diff -u -r1.2 configure.ac
--- dist/dist/configure.ac 25 Nov 2013 23:03:18 -0000 1.2
+++ dist/dist/configure.ac 11 Nov 2017 00:42:56 -0000
@@ -169,35 +169,8 @@
AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
dnl Check for the "preserve" path.
-dnl Historically, nvi has used /var/tmp/vi.recover. The Linux filesystem
-dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
-dnl beneath it so that we don't have name collisions with other editors.
-dnl Other systems have /var/preserve as well, so we test first for an already
-dnl existing name, and then use the first one that's writeable.
-AC_SUBST(vi_cv_path_preserve)
-AC_MSG_CHECKING(for preserve directory)
-AC_CACHE_VAL(vi_cv_path_preserve, [dnl
- dirlist="/var/preserve /var/tmp /usr/tmp"
- vi_cv_path_preserve=no
- for i in $dirlist; do
- if test -d $i/vi.recover; then
- vi_cv_path_preserve=$i/vi.recover
- break;
- fi
- done
- if test "$vi_cv_path_preserve" = no; then
- for i in $dirlist; do
- if test -d $i -a -w $i; then
- vi_cv_path_preserve=$i/vi.recover
- break;
- fi
- done
+AC_DEFINE(vi_cv_path_preserve, ".vi/recover/", [Directory in user homedir for recovery files])
- fi])
-if test "$vi_cv_path_preserve" = no; then
- AC_MSG_ERROR([No writeable preserve directory found.])
-fi
-AC_MSG_RESULT($vi_cv_path_preserve)
AC_PATH_PROG(vi_cv_path_fuser, fuser, no)
AC_PATH_PROG(vi_cv_path_lsof, lsof, no)
AC_SUBST(INUSE)
Index: usr.bin/nvi/pathnames.h
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/usr.bin/nvi/pathnames.h,v
retrieving revision 1.1
diff -u -r1.1 pathnames.h
--- usr.bin/nvi/pathnames.h 22 Nov 2013 16:00:45 -0000 1.1
+++ usr.bin/nvi/pathnames.h 11 Nov 2017 00:42:56 -0000
@@ -21,7 +21,7 @@
#endif
#ifndef _PATH_PRESERVE
-#define _PATH_PRESERVE "/var/tmp/vi.recover"
+#define _PATH_PRESERVE ".vi/recover/"
#endif
#ifndef _PATH_SYSV_PTY
Index: usr.bin/recover/virecover
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/usr.bin/recover/virecover,v
retrieving revision 1.4
diff -u -r1.4 virecover
--- usr.bin/recover/virecover 9 Nov 2017 15:03:01 -0000 1.4
+++ usr.bin/recover/virecover 11 Nov 2017 00:42:56 -0000
@@ -6,7 +6,7 @@
#
# Script to recover nvi edit sessions.
-RECDIR="/var/tmp/vi.recover"
+RECDIR="$HOME/.vi/recover"
SENDMAIL="/usr/sbin/sendmail"
# Check editor backup files.
Home |
Main Index |
Thread Index |
Old Index