From c9804734b01c608cf174f9dc64296c26ebe4a85a Mon Sep 17 00:00:00 2001 From: bentley Date: Mon, 1 Aug 2016 18:27:35 +0000 Subject: [PATCH] Remove vi's "directory" option and TMPDIR support. ok jung@ --- usr.bin/vi/common/exf.c | 8 +- usr.bin/vi/common/options.c | 16 +- usr.bin/vi/docs/USD.doc/vi.man/vi.1 | 10 +- usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff | 10 +- usr.bin/vi/ex/ex_filter.c | 8 +- usr.bin/vi/include/options_def.h | 159 ++++++++++---------- 6 files changed, 88 insertions(+), 123 deletions(-) diff --git a/usr.bin/vi/common/exf.c b/usr.bin/vi/common/exf.c index 4a9e7d01010..619a80ff128 100644 --- a/usr.bin/vi/common/exf.c +++ b/usr.bin/vi/common/exf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exf.c,v 1.43 2016/05/27 09:18:11 martijn Exp $ */ +/* $OpenBSD: exf.c,v 1.44 2016/08/01 18:27:35 bentley Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -124,7 +124,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) struct stat sb; size_t psize; int fd, exists, open_err, readonly; - char *oname, tname[PATH_MAX]; + char *oname, tname[] = "/tmp/vi.XXXXXXXXXX"; open_err = readonly = 0; @@ -180,10 +180,6 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags) */ if (frp->tname != NULL) goto err; - if (opts_empty(sp, O_TMP_DIRECTORY, 0)) - goto err; - (void)snprintf(tname, sizeof(tname), - "%s/vi.XXXXXXXXXX", O_STR(sp, O_TMP_DIRECTORY)); fd = mkstemp(tname); if (fd == -1 || fstat(fd, &sb) == -1 || fchmod(fd, S_IRUSR | S_IWUSR) == -1) { diff --git a/usr.bin/vi/common/options.c b/usr.bin/vi/common/options.c index 6ecd64bcd35..a4cd43604b3 100644 --- a/usr.bin/vi/common/options.c +++ b/usr.bin/vi/common/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.21 2016/01/06 22:28:52 millert Exp $ */ +/* $OpenBSD: options.c,v 1.22 2016/08/01 18:27:35 bentley Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -63,8 +63,6 @@ OPTLIST const optlist[] = { {"columns", f_columns, OPT_NUM, OPT_NOSAVE}, /* O_COMMENT 4.4BSD */ {"comment", NULL, OPT_0BOOL, 0}, -/* O_TMP_DIRECTORY 4BSD */ - {"directory", NULL, OPT_STR, 0}, /* O_EDCOMPATIBLE 4BSD */ {"edcompatible",NULL, OPT_0BOOL, 0}, /* O_ESCAPETIME 4.4BSD */ @@ -237,7 +235,6 @@ static OABBREV const abbrev[] = { {"aw", O_AUTOWRITE}, /* 4BSD */ {"bf", O_BEAUTIFY}, /* 4BSD */ {"co", O_COLUMNS}, /* 4.4BSD */ - {"dir", O_TMP_DIRECTORY}, /* 4BSD */ {"eb", O_ERRORBELLS}, /* 4BSD */ {"ed", O_EDCOMPATIBLE}, /* 4BSD */ {"ex", O_EXRC}, /* System V (undocumented) */ @@ -333,17 +330,6 @@ opts_init(SCR *sp, int *oargs) (void)snprintf(b1, sizeof(b1), "cdpath=%s", (s = getenv("CDPATH")) == NULL ? ":" : s); OI(O_CDPATH, b1); - - /* - * !!! - * Vi historically stored temporary files in /var/tmp. We store them - * in /tmp by default, hoping it's a memory based file system. There - * are two ways to change this -- the user can set either the directory - * option or the TMPDIR environmental variable. - */ - (void)snprintf(b1, sizeof(b1), - "directory=%s", (s = getenv("TMPDIR")) == NULL ? _PATH_TMP : s); - OI(O_TMP_DIRECTORY, b1); OI(O_ESCAPETIME, "escapetime=1"); OI(O_FILEC, "filec=\t"); OI(O_KEYTIME, "keytime=6"); diff --git a/usr.bin/vi/docs/USD.doc/vi.man/vi.1 b/usr.bin/vi/docs/USD.doc/vi.man/vi.1 index f40357c8ac9..17e5aeca179 100644 --- a/usr.bin/vi/docs/USD.doc/vi.man/vi.1 +++ b/usr.bin/vi/docs/USD.doc/vi.man/vi.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: vi.1,v 1.64 2016/02/09 07:41:12 jmc Exp $ +.\" $OpenBSD: vi.1,v 1.65 2016/08/01 18:27:35 bentley Exp $ .\" .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. @@ -14,7 +14,7 @@ .\" .\" @(#)vi.1 8.51 (Berkeley) 10/10/96 .\" -.Dd $Mdocdate: February 9 2016 $ +.Dd $Mdocdate: August 1 2016 $ .Dt VI 1 .Os .Sh NAME @@ -2285,8 +2285,6 @@ Set the number of columns in the screen. .Nm vi only. Skip leading comments in shell, C and C++ language files. -.It Cm directory , dir Bq "environment variable TMPDIR, or /tmp" -The directory where temporary files are created. .It Cm edcompatible , ed Bq off Remember the values of the .Sq c @@ -2628,10 +2626,6 @@ runs, or the option is explicitly reset by the user, .Nm ex Ns / Ns Nm vi enters the value into the environment. -.It Ev TMPDIR -The location used to stored temporary files (see also the -.Cm directory -edit option). .El .Sh ASYNCHRONOUS EVENTS .Bl -tag -width "SIGWINCH" -compact diff --git a/usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff b/usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff index 5d75aef58b4..ca47594141e 100644 --- a/usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff +++ b/usr.bin/vi/docs/USD.doc/vi.ref/set.opt.roff @@ -1,4 +1,4 @@ -.\" $OpenBSD: set.opt.roff,v 1.10 2016/01/06 22:41:53 millert Exp $ +.\" $OpenBSD: set.opt.roff,v 1.11 2016/08/01 18:27:35 bentley Exp $ .\" .\" Copyright (c) 1994 .\" The Regents of the University of California. All rights reserved. @@ -368,14 +368,6 @@ this option causes .CO vi to skip to the end of that shell, C or C++ comment (probably a terribly boring legal notice) before displaying the file. -.KY directory -.IP "directory, dir [environment variable TMPDIR, or /tmp]" -The directory where temporary files are created. -The environment variable -.LI TMPDIR -is used as the default value if it exists, otherwise -.LI /tmp -is used. .KY edcompatible .IP "edcompatible, ed [off]" Remember the values of the diff --git a/usr.bin/vi/ex/ex_filter.c b/usr.bin/vi/ex/ex_filter.c index e112db64372..e33cdd0d7d3 100644 --- a/usr.bin/vi/ex/ex_filter.c +++ b/usr.bin/vi/ex/ex_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_filter.c,v 1.14 2016/01/06 22:28:52 millert Exp $ */ +/* $OpenBSD: ex_filter.c,v 1.15 2016/08/01 18:27:35 bentley Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -45,7 +45,7 @@ ex_filter(SCR *sp, EXCMD *cmdp, MARK *fm, MARK *tm, MARK *rp, char *cmd, pid_t parent_writer_pid, utility_pid; recno_t nread; int input[2], output[2], fd, rval; - char *name, tname[PATH_MAX]; + char *name, tname[] = "/tmp/vi.XXXXXXXXXX"; rval = 0; @@ -79,10 +79,6 @@ ex_filter(SCR *sp, EXCMD *cmdp, MARK *fm, MARK *tm, MARK *rp, char *cmd, input[0] = input[1] = output[0] = output[1] = -1; if (ftype == FILTER_BANG) { - if (opts_empty(sp, O_TMP_DIRECTORY, 0)) - goto err; - (void)snprintf(tname, sizeof(tname), - "%s/vi.XXXXXXXXXX", O_STR(sp, O_TMP_DIRECTORY)); fd = mkstemp(tname); if (fd == -1) { msgq(sp, M_SYSERR, diff --git a/usr.bin/vi/include/options_def.h b/usr.bin/vi/include/options_def.h index 4985d51da75..b7b01a3e022 100644 --- a/usr.bin/vi/include/options_def.h +++ b/usr.bin/vi/include/options_def.h @@ -1,80 +1,81 @@ -/* $OpenBSD: options_def.h,v 1.6 2016/01/06 22:27:40 millert Exp $ */ +/* $OpenBSD: options_def.h,v 1.7 2016/08/01 18:27:35 bentley Exp $ */ -#define O_ALTWERASE 0 -#define O_AUTOINDENT 1 -#define O_AUTOPRINT 2 -#define O_AUTOWRITE 3 -#define O_BACKUP 4 -#define O_BEAUTIFY 5 -#define O_CDPATH 6 -#define O_CEDIT 7 -#define O_COLUMNS 8 -#define O_COMMENT 9 -#define O_TMP_DIRECTORY 10 -#define O_EDCOMPATIBLE 11 -#define O_ESCAPETIME 12 -#define O_ERRORBELLS 13 -#define O_EXRC 14 -#define O_EXTENDED 15 -#define O_FILEC 16 -#define O_FLASH 17 -#define O_HARDTABS 18 -#define O_ICLOWER 19 -#define O_IGNORECASE 20 -#define O_KEYTIME 21 -#define O_LEFTRIGHT 22 -#define O_LINES 23 -#define O_LISP 24 -#define O_LIST 25 -#define O_LOCKFILES 26 -#define O_MAGIC 27 -#define O_MATCHTIME 28 -#define O_MESG 29 -#define O_MODELINE 30 -#define O_NOPRINT 31 -#define O_NUMBER 32 -#define O_OCTAL 33 -#define O_OPEN 34 -#define O_OPTIMIZE 35 -#define O_PARAGRAPHS 36 -#define O_PATH 37 -#define O_PRINT 38 -#define O_PROMPT 39 -#define O_READONLY 40 -#define O_RECDIR 41 -#define O_REDRAW 42 -#define O_REMAP 43 -#define O_REPORT 44 -#define O_RULER 45 -#define O_SCROLL 46 -#define O_SEARCHINCR 47 -#define O_SECTIONS 48 -#define O_SECURE 49 -#define O_SHELL 50 -#define O_SHELLMETA 51 -#define O_SHIFTWIDTH 52 -#define O_SHOWMATCH 53 -#define O_SHOWMODE 54 -#define O_SIDESCROLL 55 -#define O_SLOWOPEN 56 -#define O_SOURCEANY 57 -#define O_TABSTOP 58 -#define O_TAGLENGTH 59 -#define O_TAGS 60 -#define O_TERM 61 -#define O_TERSE 62 -#define O_TILDEOP 63 -#define O_TIMEOUT 64 -#define O_TTYWERASE 65 -#define O_VERBOSE 66 -#define O_W1200 67 -#define O_W300 68 -#define O_W9600 69 -#define O_WARN 70 -#define O_WINDOW 71 -#define O_WINDOWNAME 72 -#define O_WRAPLEN 73 -#define O_WRAPMARGIN 74 -#define O_WRAPSCAN 75 -#define O_WRITEANY 76 -#define O_OPTIONCOUNT 77 +enum { + O_ALTWERASE = 0, + O_AUTOINDENT, + O_AUTOPRINT, + O_AUTOWRITE, + O_BACKUP, + O_BEAUTIFY, + O_CDPATH, + O_CEDIT, + O_COLUMNS, + O_COMMENT, + O_EDCOMPATIBLE, + O_ESCAPETIME, + O_ERRORBELLS, + O_EXRC, + O_EXTENDED, + O_FILEC, + O_FLASH, + O_HARDTABS, + O_ICLOWER, + O_IGNORECASE, + O_KEYTIME, + O_LEFTRIGHT, + O_LINES, + O_LISP, + O_LIST, + O_LOCKFILES, + O_MAGIC, + O_MATCHTIME, + O_MESG, + O_MODELINE, + O_NOPRINT, + O_NUMBER, + O_OCTAL, + O_OPEN, + O_OPTIMIZE, + O_PARAGRAPHS, + O_PATH, + O_PRINT, + O_PROMPT, + O_READONLY, + O_RECDIR, + O_REDRAW, + O_REMAP, + O_REPORT, + O_RULER, + O_SCROLL, + O_SEARCHINCR, + O_SECTIONS, + O_SECURE, + O_SHELL, + O_SHELLMETA, + O_SHIFTWIDTH, + O_SHOWMATCH, + O_SHOWMODE, + O_SIDESCROLL, + O_SLOWOPEN, + O_SOURCEANY, + O_TABSTOP, + O_TAGLENGTH, + O_TAGS, + O_TERM, + O_TERSE, + O_TILDEOP, + O_TIMEOUT, + O_TTYWERASE, + O_VERBOSE, + O_W1200, + O_W300, + O_W9600, + O_WARN, + O_WINDOW, + O_WINDOWNAME, + O_WRAPLEN, + O_WRAPMARGIN, + O_WRAPSCAN, + O_WRITEANY, + O_OPTIONCOUNT, +}; -- 2.20.1