summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authormichaels <michaels@cvs.openbsd.org>1996-10-16 01:19:02 +0000
committermichaels <michaels@cvs.openbsd.org>1996-10-16 01:19:02 +0000
commitbbac58ea85fcdd5f15449819005e17cd93c3e14a (patch)
tree46cac5bf539a167855f9d647a2047e9d9fe89608 /usr.bin
parentbdd4fa6809d3bd31f8890df0ca821dcfd660042f (diff)
nvi 1.78:
+ Fix bugs when both the leftright scrolling and number edit options were on. + Fix bug where splitting in the middle of the screen could repaint incorrectly. + Fix first-nul in input bug, where random garbage was inserted. + Correct search and mark-as-motion-command bug, it's a line mode action if the search starts at or before the first non<blank>. + Fix bug autoindent bug, where ^D could shift too far in the line. + Fix core dump where ! command called from the .exrc file. + Add the -S command-line option, which initializes vi to have the secure edit option preset.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/vi/cl/cl.h3
-rw-r--r--usr.bin/vi/cl/cl_funcs.c12
-rw-r--r--usr.bin/vi/cl/cl_main.c18
-rw-r--r--usr.bin/vi/cl/cl_read.c8
-rw-r--r--usr.bin/vi/cl/cl_screen.c10
-rw-r--r--usr.bin/vi/common/api.c13
-rw-r--r--usr.bin/vi/common/common.h4
-rw-r--r--usr.bin/vi/common/gs.h10
-rw-r--r--usr.bin/vi/common/key.c4
-rw-r--r--usr.bin/vi/common/main.c71
-rw-r--r--usr.bin/vi/common/options.c46
-rw-r--r--usr.bin/vi/common/options.h4
-rw-r--r--usr.bin/vi/common/put.c12
-rw-r--r--usr.bin/vi/docs/USD.doc/vi.man/nvi.115
-rw-r--r--usr.bin/vi/docs/changelog12
-rw-r--r--usr.bin/vi/ex/ex.c10
-rw-r--r--usr.bin/vi/ex/ex_argv.c14
-rw-r--r--usr.bin/vi/ex/ex_bang.c12
-rw-r--r--usr.bin/vi/ex/ex_script.c8
-rw-r--r--usr.bin/vi/ex/ex_txt.c9
-rw-r--r--usr.bin/vi/ex/version.h2
-rw-r--r--usr.bin/vi/include/perl_extern.h6
-rw-r--r--usr.bin/vi/include/vi_extern.h1
-rw-r--r--usr.bin/vi/vi/v_itxt.c4
-rw-r--r--usr.bin/vi/vi/v_mark.c13
-rw-r--r--usr.bin/vi/vi/v_search.c13
-rw-r--r--usr.bin/vi/vi/v_txt.c32
-rw-r--r--usr.bin/vi/vi/vi.c4
-rw-r--r--usr.bin/vi/vi/vs_line.c18
-rw-r--r--usr.bin/vi/vi/vs_msg.c4
-rw-r--r--usr.bin/vi/vi/vs_refresh.c62
-rw-r--r--usr.bin/vi/vi/vs_split.c6
32 files changed, 269 insertions, 191 deletions
diff --git a/usr.bin/vi/cl/cl.h b/usr.bin/vi/cl/cl.h
index d69108911e8..2ef2b8d1f81 100644
--- a/usr.bin/vi/cl/cl.h
+++ b/usr.bin/vi/cl/cl.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)cl.h 10.18 (Berkeley) 9/15/96
+ * @(#)cl.h 10.19 (Berkeley) 9/24/96
*/
typedef struct _cl_private {
@@ -47,6 +47,7 @@ typedef struct _cl_private {
#define CL_SIGINT 0x0040 /* SIGINT arrived. */
#define CL_SIGTERM 0x0080 /* SIGTERM arrived. */
#define CL_SIGWINCH 0x0100 /* SIGWINCH arrived. */
+#define CL_STDIN_TTY 0x0200 /* Talking to a terminal. */
u_int32_t flags;
} CL_PRIVATE;
diff --git a/usr.bin/vi/cl/cl_funcs.c b/usr.bin/vi/cl/cl_funcs.c
index b4dce4fcd2b..40315ee85e8 100644
--- a/usr.bin/vi/cl/cl_funcs.c
+++ b/usr.bin/vi/cl/cl_funcs.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_funcs.c 10.48 (Berkeley) 8/11/96";
+static const char sccsid[] = "@(#)cl_funcs.c 10.50 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -572,7 +572,7 @@ cl_suspend(sp, allowedp)
*/
if (F_ISSET(sp, SC_EX)) {
/* Save the terminal settings, and restore the original ones. */
- if (F_ISSET(gp, G_STDIN_TTY)) {
+ if (F_ISSET(clp, CL_STDIN_TTY)) {
(void)tcgetattr(STDIN_FILENO, &t);
(void)tcsetattr(STDIN_FILENO,
TCSASOFT | TCSADRAIN, &clp->orig);
@@ -584,7 +584,7 @@ cl_suspend(sp, allowedp)
/* Time passes ... */
/* Restore terminal settings. */
- if (F_ISSET(gp, G_STDIN_TTY))
+ if (F_ISSET(clp, CL_STDIN_TTY))
(void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
return (0);
}
@@ -649,7 +649,7 @@ cl_suspend(sp, allowedp)
#ifdef HAVE_BSD_CURSES
/* Restore terminal settings. */
- if (F_ISSET(gp, G_STDIN_TTY))
+ if (F_ISSET(clp, CL_STDIN_TTY))
(void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
(void)cl_attr(sp, SA_ALTERNATE, 1);
@@ -684,8 +684,8 @@ void
cl_usage()
{
#define USAGE "\
-usage: ex [-eFRrsv] [-c command] [-t tag] [-w size] [file ...]\n\
-usage: vi [-eFlRrv] [-c command] [-t tag] [-w size] [file ...]\n"
+usage: ex [-eFRrSsv] [-c command] [-t tag] [-w size] [file ...]\n\
+usage: vi [-eFlRrSv] [-c command] [-t tag] [-w size] [file ...]\n"
(void)fprintf(stderr, "%s", USAGE);
#undef USAGE
}
diff --git a/usr.bin/vi/cl/cl_main.c b/usr.bin/vi/cl/cl_main.c
index 0e6fdbcafda..f7693683014 100644
--- a/usr.bin/vi/cl/cl_main.c
+++ b/usr.bin/vi/cl/cl_main.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_main.c 10.33 (Berkeley) 8/11/96";
+static const char sccsid[] = "@(#)cl_main.c 10.35 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -28,7 +28,7 @@ static const char sccsid[] = "@(#)cl_main.c 10.33 (Berkeley) 8/11/96";
#include <unistd.h>
#include "../common/common.h"
-#ifdef notyet
+#ifdef RUNNING_IP
#include "../ip/ip.h"
#endif
#include "cl.h"
@@ -73,7 +73,7 @@ main(argc, argv)
* no way to portably call getopt twice, so arguments parsed here must
* be removed from the argument list.
*/
-#ifdef notyet
+#ifdef RUNNING_IP
ip_arg = NULL;
for (p_av = t_av = argv;;) {
if (*t_av == NULL) {
@@ -229,17 +229,21 @@ cl_init(gp)
gp->cl_private = clp;
/*
- * Set the G_STDIN_TTY flag. It's purpose is to avoid setting and
- * resetting the tty if the input isn't from there.
+ * Set the CL_STDIN_TTY flag. It's purpose is to avoid setting
+ * and resetting the tty if the input isn't from there. We also
+ * use the same test to determine if we're running a script or
+ * not.
*/
if (isatty(STDIN_FILENO))
- F_SET(gp, G_STDIN_TTY);
+ F_SET(clp, CL_STDIN_TTY);
+ else
+ F_SET(gp, G_SCRIPTED);
/*
* We expect that if we've lost our controlling terminal that the
* open() (but not the tcgetattr()) will fail.
*/
- if (F_ISSET(gp, G_STDIN_TTY)) {
+ if (F_ISSET(clp, CL_STDIN_TTY)) {
if (tcgetattr(STDIN_FILENO, &clp->orig) == -1)
goto tcfail;
} else if ((fd = open(_PATH_TTY, O_RDONLY, 0)) != -1) {
diff --git a/usr.bin/vi/cl/cl_read.c b/usr.bin/vi/cl/cl_read.c
index 24c564f378f..8a95a77b243 100644
--- a/usr.bin/vi/cl/cl_read.c
+++ b/usr.bin/vi/cl/cl_read.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_read.c 10.14 (Berkeley) 6/30/96";
+static const char sccsid[] = "@(#)cl_read.c 10.15 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -148,6 +148,7 @@ cl_read(sp, flags, bp, blen, nrp, tp)
input_t rval;
int maxfd, nr, term_reset;
+ gp = sp->gp;
clp = CLP(sp);
term_reset = 0;
@@ -157,8 +158,7 @@ cl_read(sp, flags, bp, blen, nrp, tp)
* when trying to complete a map, but we're going to hang
* on the next read anyway.
*/
- gp = sp->gp;
- if (!F_ISSET(gp, G_STDIN_TTY)) {
+ if (!F_ISSET(clp, CL_STDIN_TTY)) {
switch (nr = read(STDIN_FILENO, bp, blen)) {
case 0:
return (INP_EOF);
@@ -221,7 +221,7 @@ cl_read(sp, flags, bp, blen, nrp, tp)
* It's ugly that we wait on scripting file descriptors here, but it's
* the only way to keep from locking out scripting windows.
*/
- if (F_ISSET(gp, G_SCRIPT)) {
+ if (F_ISSET(gp, G_SCRWIN)) {
loop: FD_ZERO(&rdfd);
FD_SET(STDIN_FILENO, &rdfd);
maxfd = STDIN_FILENO;
diff --git a/usr.bin/vi/cl/cl_screen.c b/usr.bin/vi/cl/cl_screen.c
index 9d8d9811a21..2ce58e80cc7 100644
--- a/usr.bin/vi/cl/cl_screen.c
+++ b/usr.bin/vi/cl/cl_screen.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)cl_screen.c 10.48 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)cl_screen.c 10.49 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -148,12 +148,12 @@ cl_quit(gp)
rval = 1;
/* Really leave vi mode. */
- if (F_ISSET(gp, G_STDIN_TTY) &&
+ if (F_ISSET(clp, CL_STDIN_TTY) &&
F_ISSET(clp, CL_SCR_VI_INIT) && cl_vi_end(gp))
rval = 1;
/* Really leave ex mode. */
- if (F_ISSET(gp, G_STDIN_TTY) &&
+ if (F_ISSET(clp, CL_STDIN_TTY) &&
F_ISSET(clp, CL_SCR_EX_INIT) && cl_ex_end(gp))
rval = 1;
@@ -193,7 +193,7 @@ cl_vi_init(sp)
goto fast;
/* Curses vi always reads from (and writes to) a terminal. */
- if (!F_ISSET(gp, G_STDIN_TTY) || !isatty(STDOUT_FILENO)) {
+ if (!F_ISSET(clp, CL_STDIN_TTY) || !isatty(STDOUT_FILENO)) {
msgq(sp, M_ERR,
"016|Vi's standard input and output must be a terminal");
return (1);
@@ -436,7 +436,7 @@ cl_ex_init(sp)
goto fast;
/* If not reading from a file, we're done. */
- if (!F_ISSET(sp->gp, G_STDIN_TTY))
+ if (!F_ISSET(clp, CL_STDIN_TTY))
return (0);
/* Get the ex termcap/terminfo strings. */
diff --git a/usr.bin/vi/common/api.c b/usr.bin/vi/common/api.c
index 62f61d0256b..1f430775ee1 100644
--- a/usr.bin/vi/common/api.c
+++ b/usr.bin/vi/common/api.c
@@ -12,7 +12,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)api.c 8.23 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)api.c 8.24 (Berkeley) 9/18/96";
#endif /* not lint */
#include <sys/types.h>
@@ -410,13 +410,16 @@ api_unmap(sp, name)
/*
* api_opts_get --
* Return a option value as a string, in allocated memory.
+ * If the option is of type boolean, boolvalue is (un)set
+ * according to the value; otherwise boolvalue is -1.
*
- * PUBLIC: int api_opts_get __P((SCR *, char *, char **));
+ * PUBLIC: int api_opts_get __P((SCR *, char *, char **, int *));
*/
int
-api_opts_get(sp, name, value)
+api_opts_get(sp, name, value, boolvalue)
SCR *sp;
char *name, **value;
+ int *boolvalue;
{
int offset;
OPTLIST const *op;
@@ -425,12 +428,16 @@ api_opts_get(sp, name, value)
return (1);
offset = op - optlist;
+ if (boolvalue != NULL)
+ *boolvalue = -1;
switch (op->type) {
case OPT_0BOOL:
case OPT_1BOOL:
MALLOC_RET(sp, *value, char *, strlen(op->name) + 2 + 1);
(void)sprintf(*value,
"%s%s", O_ISSET(sp, offset) ? "" : "no", op->name);
+ if (boolvalue != NULL)
+ *boolvalue = O_ISSET(sp, offset);
break;
case OPT_NUM:
MALLOC_RET(sp, *value, char *, 20);
diff --git a/usr.bin/vi/common/common.h b/usr.bin/vi/common/common.h
index 555db960d7a..0e13fc80b84 100644
--- a/usr.bin/vi/common/common.h
+++ b/usr.bin/vi/common/common.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)common.h 10.12 (Berkeley) 5/24/96
+ * @(#)common.h 10.13 (Berkeley) 9/25/96
*/
/*
@@ -93,4 +93,4 @@ typedef enum { SEQ_ABBREV, SEQ_COMMAND, SEQ_INPUT } seq_t;
#include "log.h"
#include "mem.h"
-#include "common_extern.h"
+#include "com_extern.h"
diff --git a/usr.bin/vi/common/gs.h b/usr.bin/vi/common/gs.h
index 542e2ef1e27..e5a43a656ac 100644
--- a/usr.bin/vi/common/gs.h
+++ b/usr.bin/vi/common/gs.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)gs.h 10.33 (Berkeley) 7/12/96
+ * @(#)gs.h 10.34 (Berkeley) 9/24/96
*/
#define TEMPORARY_FILE_STRING "/tmp" /* Default temporary file name. */
@@ -139,10 +139,10 @@ struct _gs {
#define G_BELLSCHED 0x0002 /* Bell scheduled. */
#define G_INTERRUPTED 0x0004 /* Interrupted. */
#define G_RECOVER_SET 0x0008 /* Recover system initialized. */
-#define G_SCRIPT 0x0010 /* Scripting windows running. */
-#define G_SNAPSHOT 0x0020 /* Always snapshot files. */
-#define G_SRESTART 0x0040 /* Screen restarted. */
-#define G_STDIN_TTY 0x0080 /* Standard input is a tty. */
+#define G_SCRIPTED 0x0010 /* Ex script session. */
+#define G_SCRWIN 0x0020 /* Scripting windows running. */
+#define G_SNAPSHOT 0x0040 /* Always snapshot files. */
+#define G_SRESTART 0x0080 /* Screen restarted. */
#define G_TMP_INUSE 0x0100 /* Temporary buffer in use. */
u_int32_t flags;
diff --git a/usr.bin/vi/common/key.c b/usr.bin/vi/common/key.c
index 474efe2da5e..e1311ab571b 100644
--- a/usr.bin/vi/common/key.c
+++ b/usr.bin/vi/common/key.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)key.c 10.32 (Berkeley) 6/30/96";
+static const char sccsid[] = "@(#)key.c 10.33 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -561,7 +561,7 @@ retry: istimeout = remap_cnt = 0;
* If we're reading new characters, check any scripting
* windows for input.
*/
- if (F_ISSET(gp, G_SCRIPT) && sscr_input(sp))
+ if (F_ISSET(gp, G_SCRWIN) && sscr_input(sp))
return (1);
loop: if (gp->scr_event(sp, argp,
LF_ISSET(EC_INTERRUPT | EC_QUOTED | EC_RAW), timeout))
diff --git a/usr.bin/vi/common/main.c b/usr.bin/vi/common/main.c
index 27dcb70a1c1..033fb8c96f3 100644
--- a/usr.bin/vi/common/main.c
+++ b/usr.bin/vi/common/main.c
@@ -18,7 +18,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char sccsid[] = "@(#)main.c 10.44 (Berkeley) 7/13/96";
+static const char sccsid[] = "@(#)main.c 10.47 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -39,6 +39,7 @@ static const char sccsid[] = "@(#)main.c 10.44 (Berkeley) 7/13/96";
#include "../vi/vi.h"
#include "pathnames.h"
+static void attach __P((GS *));
static void v_estr __P((char *, int, char *));
static int v_obsolete __P((char *, char *[]));
@@ -62,9 +63,8 @@ editor(gp, argc, argv)
SCR *sp;
size_t len;
u_int flags;
- int ch, fd, flagchk, lflag, startup, readonly, rval, silent;
- char *tag_f, *wsizearg;
- char path[256];
+ int ch, flagchk, lflag, secure, startup, readonly, rval, silent;
+ char *tag_f, *wsizearg, path[256];
/* Initialize the busy routine, if not defined by the screen. */
if (gp->scr_busy == NULL)
@@ -107,16 +107,16 @@ editor(gp, argc, argv)
/* Parse the arguments. */
flagchk = '\0';
tag_f = wsizearg = NULL;
- lflag = silent = 0;
+ lflag = secure = silent = 0;
startup = 1;
/* Set the file snapshot flag. */
F_SET(gp, G_SNAPSHOT);
#ifdef DEBUG
- while ((ch = getopt(argc, argv, "c:D:eFlRrsT:t:vw:")) != EOF)
+ while ((ch = getopt(argc, argv, "c:D:eFlRrSsT:t:vw:")) != EOF)
#else
- while ((ch = getopt(argc, argv, "c:eFlRrst:vw:")) != EOF)
+ while ((ch = getopt(argc, argv, "c:eFlRrSst:vw:")) != EOF)
#endif
switch (ch) {
case 'c': /* Run the command. */
@@ -138,20 +138,7 @@ editor(gp, argc, argv)
startup = 0;
break;
case 'w':
- if ((fd = open(_PATH_TTY, O_RDONLY, 0)) < 0) {
- v_estr(gp->progname, errno, _PATH_TTY);
- return (1);
- }
- (void)printf("process %lu waiting, enter <CR> to continue: ",
- (u_long)getpid());
- (void)fflush(stdout);
- do {
- if (read(fd, &ch, 1) != 1) {
- (void)close(fd);
- return (0);
- }
- } while (ch != '\n' && ch != '\r');
- (void)close(fd);
+ attach(gp);
break;
default:
v_estr(gp->progname, 0,
@@ -181,6 +168,9 @@ editor(gp, argc, argv)
}
flagchk = 'r';
break;
+ case 'S':
+ secure = 1;
+ break;
case 's':
silent = 1;
break;
@@ -232,7 +222,7 @@ editor(gp, argc, argv)
v_estr(gp->progname, 0, "-s option is only applicable to ex.");
goto err;
}
- if (LF_ISSET(SC_EX) && !F_ISSET(gp, G_STDIN_TTY))
+ if (LF_ISSET(SC_EX) && F_ISSET(gp, G_SCRIPTED))
silent = 1;
/*
@@ -255,13 +245,15 @@ editor(gp, argc, argv)
if (v_key_init(sp)) /* Special key initialization. */
goto err;
- { int oargs[4], *oargp = oargs;
- if (readonly) /* Command-line options. */
- *oargp++ = O_READONLY;
- if (lflag) {
+ { int oargs[5], *oargp = oargs;
+ if (lflag) { /* Command-line options. */
*oargp++ = O_LISP;
*oargp++ = O_SHOWMATCH;
}
+ if (readonly)
+ *oargp++ = O_READONLY;
+ if (secure)
+ *oargp++ = O_SECURE;
*oargp = -1; /* Options initialization. */
if (opts_init(sp, oargs))
goto err;
@@ -582,6 +574,33 @@ nomem: v_estr(name, errno, NULL);
return (0);
}
+#ifdef DEBUG
+static void
+attach(gp)
+ GS *gp;
+{
+ int fd;
+ char ch;
+
+ if ((fd = open(_PATH_TTY, O_RDONLY, 0)) < 0) {
+ v_estr(gp->progname, errno, _PATH_TTY);
+ return;
+ }
+
+ (void)printf("process %lu waiting, enter <CR> to continue: ",
+ (u_long)getpid());
+ (void)fflush(stdout);
+
+ do {
+ if (read(fd, &ch, 1) != 1) {
+ (void)close(fd);
+ return;
+ }
+ } while (ch != '\n' && ch != '\r');
+ (void)close(fd);
+}
+#endif
+
static void
v_estr(name, eno, msg)
char *name, *msg;
diff --git a/usr.bin/vi/common/options.c b/usr.bin/vi/common/options.c
index 8b5468e45ff..a285dc1869b 100644
--- a/usr.bin/vi/common/options.c
+++ b/usr.bin/vi/common/options.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)options.c 10.49 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)options.c 10.50 (Berkeley) 10/1/96";
#endif /* not lint */
#include <sys/types.h>
@@ -394,8 +394,8 @@ opts_init(sp, oargs)
OI(O_WINDOW, b1);
/*
- * Set boolean default values, and copy all settings into the
- * the default information.
+ * Set boolean default values, and copy all settings into the default
+ * information. OS_NOFREE is set, we're copying, not replacing.
*/
for (op = optlist, cnt = 0; op->name != NULL; ++op, ++cnt)
switch (op->type) {
@@ -409,8 +409,8 @@ opts_init(sp, oargs)
o_set(sp, cnt, OS_DEF, NULL, O_VAL(sp, cnt));
break;
case OPT_STR:
- if (O_STR(sp, cnt) != NULL && o_set(sp,
- cnt, OS_DEF | OS_STRDUP, O_STR(sp, cnt), 0))
+ if (O_STR(sp, cnt) != NULL && o_set(sp, cnt,
+ OS_DEF | OS_NOFREE | OS_STRDUP, O_STR(sp, cnt), 0))
goto err;
break;
default:
@@ -696,7 +696,7 @@ badnum: p = msg_print(sp, name, &nf);
}
/* Set the value. */
- if (o_set(sp, offset, OS_FREE | OS_STRDUP, sep, 0))
+ if (o_set(sp, offset, OS_STRDUP, sep, 0))
rval = 1;
break;
default:
@@ -734,23 +734,21 @@ o_set(sp, opt, flags, str, val)
return (1);
}
-
/* Free the previous string, if requested, and set the value. */
- if LF_ISSET(OS_DEF) {
- if (LF_ISSET(OS_FREE) && op->o_def.str != NULL)
- free(op->o_def.str);
- if (LF_ISSET(OS_STR | OS_STRDUP))
+ if LF_ISSET(OS_DEF)
+ if (LF_ISSET(OS_STR | OS_STRDUP)) {
+ if (!LF_ISSET(OS_NOFREE) && op->o_def.str != NULL)
+ free(op->o_def.str);
op->o_def.str = str;
- else
+ } else
op->o_def.val = val;
- } else {
- if (LF_ISSET(OS_FREE) && op->o_cur.str != NULL)
- free(op->o_cur.str);
- if (LF_ISSET(OS_STR | OS_STRDUP))
+ else
+ if (LF_ISSET(OS_STR | OS_STRDUP)) {
+ if (!LF_ISSET(OS_NOFREE) && op->o_cur.str != NULL)
+ free(op->o_cur.str);
op->o_cur.str = str;
- else
+ } else
op->o_cur.val = val;
- }
return (0);
}
@@ -1085,20 +1083,20 @@ opts_copy(orig, sp)
* screens referencing the same memory.
*/
if (rval || O_STR(sp, cnt) == NULL) {
- o_set(sp, cnt, OS_STR, NULL, 0);
- o_set(sp, cnt, OS_DEF | OS_STR, NULL, 0);
+ o_set(sp, cnt, OS_NOFREE | OS_STR, NULL, 0);
+ o_set(sp, cnt, OS_DEF | OS_NOFREE | OS_STR, NULL, 0);
continue;
}
/* Copy the current string. */
- if (o_set(sp, cnt, OS_STRDUP, O_STR(sp, cnt), 0)) {
- o_set(sp, cnt, OS_DEF | OS_STR, NULL, 0);
+ if (o_set(sp, cnt, OS_NOFREE | OS_STRDUP, O_STR(sp, cnt), 0)) {
+ o_set(sp, cnt, OS_DEF | OS_NOFREE | OS_STR, NULL, 0);
goto nomem;
}
/* Copy the default string. */
- if (O_D_STR(sp, cnt) != NULL &&
- o_set(sp, cnt, OS_DEF | OS_STRDUP, O_D_STR(sp, cnt), 0)) {
+ if (O_D_STR(sp, cnt) != NULL && o_set(sp, cnt,
+ OS_DEF | OS_NOFREE | OS_STRDUP, O_D_STR(sp, cnt), 0)) {
nomem: msgq(orig, M_SYSERR, NULL);
rval = 1;
}
diff --git a/usr.bin/vi/common/options.h b/usr.bin/vi/common/options.h
index 805df7904c4..3f7ed6c58b5 100644
--- a/usr.bin/vi/common/options.h
+++ b/usr.bin/vi/common/options.h
@@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
- * @(#)options.h 10.17 (Berkeley) 7/2/96
+ * @(#)options.h 10.18 (Berkeley) 10/1/96
*/
/*
@@ -41,7 +41,7 @@
/* Flags to o_set(). */
#define OS_DEF 0x01 /* Set the default value. */
-#define OS_FREE 0x02 /* Free old string if set. */
+#define OS_NOFREE 0x02 /* Don't free the old string. */
#define OS_STR 0x04 /* Set to the str value. */
#define OS_STRDUP 0x08 /* Copy and set to the str value. */
diff --git a/usr.bin/vi/common/put.c b/usr.bin/vi/common/put.c
index 66e40a410ba..8c0ca4b7c14 100644
--- a/usr.bin/vi/common/put.c
+++ b/usr.bin/vi/common/put.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)put.c 10.10 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)put.c 10.11 (Berkeley) 9/23/96";
#endif /* not lint */
#include <sys/types.h>
@@ -131,11 +131,13 @@ put(sp, cbp, namep, cp, rp, append)
}
/* First line from the CB. */
- memcpy(t, tp->lb, tp->len);
- t += tp->len;
+ if (tp->len != 0) {
+ memcpy(t, tp->lb, tp->len);
+ t += tp->len;
+ }
/* Calculate length left in the original line. */
- clen = len != 0 ? len - cp->cno - (append ? 1 : 0) : 0;
+ clen = len == 0 ? 0 : len - (cp->cno + (append ? 1 : 0));
/*
* !!!
@@ -151,7 +153,7 @@ put(sp, cbp, namep, cp, rp, append)
* behavior, and expect POSIX.2 to do so as well.
*/
rp->lno = lno;
- rp->cno = len == 0 ? 0 : sp->cno + (append ? 1 : 0);
+ rp->cno = len == 0 ? 0 : sp->cno + (append && tp->len ? 1 : 0);
/*
* If no more lines in the CB, append the rest of the original
diff --git a/usr.bin/vi/docs/USD.doc/vi.man/nvi.1 b/usr.bin/vi/docs/USD.doc/vi.man/nvi.1
index 9c9187dde71..63c9c50a9fd 100644
--- a/usr.bin/vi/docs/USD.doc/vi.man/nvi.1
+++ b/usr.bin/vi/docs/USD.doc/vi.man/nvi.1
@@ -8,16 +8,16 @@
.\"
.\" See the LICENSE file for redistribution information.
.\"
-.\" @(#)vi.1 8.49 (Berkeley) 8/20/96
+.\" @(#)vi.1 8.50 (Berkeley) 9/23/96
.\"
-.TH VI 1 "August 20, 1996"
+.TH VI 1 "September 23, 1996"
.UC
.SH NAME
ex, vi, view \- text editors
.SH SYNOPSIS
.B ex
[\c
-.B -eFRrsv\c
+.B -eFRrSsv\c
] [\c
.BI -c " cmd"\c
] [\c
@@ -28,7 +28,7 @@ ex, vi, view \- text editors
.br
.B vi
[\c
-.B -eFlRrv\c
+.B -eFlRrSv\c
] [\c
.BI -c " cmd"\c
] [\c
@@ -39,7 +39,7 @@ ex, vi, view \- text editors
.br
.B view
[\c
-.B -eFRrv\c
+.B -eFRrSv\c
] [\c
.BI -c " cmd"\c
] [\c
@@ -136,6 +136,11 @@ the file is edited as if the
.B \-r
option had not been specified.
.TP
+.B \-S
+Run with the
+.B secure
+edit option set, disallowing all access to external programs.
+.TP
.B \-s
Enter batch mode; applicable only to
.I \&ex
diff --git a/usr.bin/vi/docs/changelog b/usr.bin/vi/docs/changelog
index ce2b35f6e48..fee1fc00bb9 100644
--- a/usr.bin/vi/docs/changelog
+++ b/usr.bin/vi/docs/changelog
@@ -1,3 +1,15 @@
+1.76 -> 1.78 (10/01/96)
+ + Fix bugs when both the leftright scrolling and number edit options
+ were on.
+ + Fix bug where splitting in the middle of the screen could repaint
+ incorrectly.
+ + Fix first-nul in input bug, where random garbage was inserted.
+ + Correct search and mark-as-motion-command bug, it's a line mode
+ action if the search starts at or before the first non<blank>.
+ + Fix bug autoindent bug, where ^D could shift too far in the line.
+ + Fix core dump where ! command called from the .exrc file.
+ + Add the -S command-line option, which initializes vi to have the
+ secure edit option preset.
1.75 -> 1.76 (09/15/96)
+ Fix bug where ^V didn't keep input mapping from happening.
+ Fix a core dump bug in the R command.
diff --git a/usr.bin/vi/ex/ex.c b/usr.bin/vi/ex/ex.c
index df456ce0117..d9266c75bd0 100644
--- a/usr.bin/vi/ex/ex.c
+++ b/usr.bin/vi/ex/ex.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex.c 10.54 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)ex.c 10.55 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -75,7 +75,7 @@ ex(spp)
}
/* If reading from a file, errors should have name and line info. */
- if (!F_ISSET(gp, G_STDIN_TTY)) {
+ if (F_ISSET(gp, G_SCRIPTED)) {
gp->excmd.if_lno = 1;
gp->excmd.if_name = "script";
}
@@ -130,7 +130,7 @@ ex(spp)
}
F_INIT(&gp->excmd, E_NRSEP);
- if (ex_cmd(sp) && !F_ISSET(gp, G_STDIN_TTY))
+ if (ex_cmd(sp) && F_ISSET(gp, G_SCRIPTED))
return (1);
if (INTERRUPTED(sp)) {
@@ -1336,7 +1336,7 @@ addr_verify:
*/
if (F_ISSET(ecp, E_NRSEP)) {
if (sp->ep != NULL &&
- F_ISSET(sp, SC_EX) && F_ISSET(gp, G_STDIN_TTY) &&
+ F_ISSET(sp, SC_EX) && !F_ISSET(gp, G_SCRIPTED) &&
(F_ISSET(ecp, E_USELASTCMD) || ecp->cmd == &cmds[C_SCROLL]))
gp->scr_ex_adjust(sp, EX_TERM_SCROLL);
F_CLR(ecp, E_NRSEP);
@@ -1349,7 +1349,7 @@ addr_verify:
* Interrupts behave like errors, for now.
*/
if (ecp->cmd->fn(sp, ecp) || INTERRUPTED(sp)) {
- if (!F_ISSET(gp, G_STDIN_TTY))
+ if (F_ISSET(gp, G_SCRIPTED))
F_SET(sp, SC_EXIT_FORCE);
goto err;
}
diff --git a/usr.bin/vi/ex/ex_argv.c b/usr.bin/vi/ex/ex_argv.c
index 1930bf145d0..cc5a201bea2 100644
--- a/usr.bin/vi/ex/ex_argv.c
+++ b/usr.bin/vi/ex/ex_argv.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_argv.c 10.25 (Berkeley) 8/13/96";
+static const char sccsid[] = "@(#)ex_argv.c 10.26 (Berkeley) 9/20/96";
#endif /* not lint */
#include <sys/types.h>
@@ -325,7 +325,7 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
{
EX_PRIVATE *exp;
char *bp, *t;
- size_t blen, len, tlen;
+ size_t blen, len, off, tlen;
/* Replace file name characters. */
for (bp = *bpp, blen = *blenp, len = *lenp; cmdlen > 0; --cmdlen, ++cmd)
@@ -340,7 +340,9 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
return (1);
}
len += tlen = strlen(exp->lastbcomm);
+ off = p - bp;
ADD_SPACE_RET(sp, bp, blen, len);
+ p = bp + off;
memcpy(p, exp->lastbcomm, tlen);
p += tlen;
F_SET(excp, E_MODIFY);
@@ -353,7 +355,9 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
}
tlen = strlen(t);
len += tlen;
+ off = p - bp;
ADD_SPACE_RET(sp, bp, blen, len);
+ p = bp + off;
memcpy(p, t, tlen);
p += tlen;
F_SET(excp, E_MODIFY);
@@ -365,7 +369,9 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
return (1);
}
len += tlen = strlen(t);
+ off = p - bp;
ADD_SPACE_RET(sp, bp, blen, len);
+ p = bp + off;
memcpy(p, t, tlen);
p += tlen;
F_SET(excp, E_MODIFY);
@@ -385,13 +391,17 @@ argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)
/* FALLTHROUGH */
default:
ins_ch: ++len;
+ off = p - bp;
ADD_SPACE_RET(sp, bp, blen, len);
+ p = bp + off;
*p++ = *cmd;
}
/* Nul termination. */
++len;
+ off = p - bp;
ADD_SPACE_RET(sp, bp, blen, len);
+ p = bp + off;
*p = '\0';
/* Return the new string length, buffer, buffer length. */
diff --git a/usr.bin/vi/ex/ex_bang.c b/usr.bin/vi/ex/ex_bang.c
index e9c9dbfdd2d..25f3f7732ab 100644
--- a/usr.bin/vi/ex/ex_bang.c
+++ b/usr.bin/vi/ex/ex_bang.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_bang.c 10.32 (Berkeley) 5/18/96";
+static const char sccsid[] = "@(#)ex_bang.c 10.33 (Berkeley) 9/23/96";
#endif /* not lint */
#include <sys/types.h>
@@ -94,14 +94,14 @@ ex_bang(sp, cmdp)
}
/*
- * If no addresses were specified, run the command. If the file has
- * been modified and autowrite is set, write the file back. If the
- * file has been modified, autowrite is not set and the warn option is
- * set, tell the user about the file.
+ * If no addresses were specified, run the command. If there's an
+ * underlying file, it's been modified and autowrite is set, write
+ * the file back. If the file has been modified, autowrite is not
+ * set and the warn option is set, tell the user about the file.
*/
if (cmdp->addrcnt == 0) {
msg = NULL;
- if (F_ISSET(sp->ep, F_MODIFIED))
+ if (sp->ep != NULL && F_ISSET(sp->ep, F_MODIFIED))
if (O_ISSET(sp, O_AUTOWRITE)) {
if (file_aw(sp, FS_ALL))
return (0);
diff --git a/usr.bin/vi/ex/ex_script.c b/usr.bin/vi/ex/ex_script.c
index 87d9823965a..9ca6d60060d 100644
--- a/usr.bin/vi/ex/ex_script.c
+++ b/usr.bin/vi/ex/ex_script.c
@@ -13,7 +13,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_script.c 10.29 (Berkeley) 5/12/96";
+static const char sccsid[] = "@(#)ex_script.c 10.30 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -193,7 +193,7 @@ err: if (sc->sh_master != -1)
return (1);
F_SET(sp, SC_SCRIPT);
- F_SET(sp->gp, G_SCRIPT);
+ F_SET(sp->gp, G_SCRWIN);
return (0);
}
@@ -619,10 +619,10 @@ sscr_check(sp)
gp = sp->gp;
for (sp = gp->dq.cqh_first; sp != (void *)&gp->dq; sp = sp->q.cqe_next)
if (F_ISSET(sp, SC_SCRIPT)) {
- F_SET(gp, G_SCRIPT);
+ F_SET(gp, G_SCRWIN);
return;
}
- F_CLR(gp, G_SCRIPT);
+ F_CLR(gp, G_SCRWIN);
}
#ifdef HAVE_SYS5_PTY
diff --git a/usr.bin/vi/ex/ex_txt.c b/usr.bin/vi/ex/ex_txt.c
index 09471c2938a..3838afd52bf 100644
--- a/usr.bin/vi/ex/ex_txt.c
+++ b/usr.bin/vi/ex/ex_txt.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)ex_txt.c 10.15 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)ex_txt.c 10.16 (Berkeley) 9/24/96";
#endif /* not lint */
#include <sys/types.h>
@@ -101,15 +101,16 @@ newtp: if ((tp = text_init(sp, NULL, 0, 32)) == NULL)
* practice, but not 'cause it's easier.
*/
gp = sp->gp;
- if (F_ISSET(gp, G_STDIN_TTY)) {
+ if (F_ISSET(gp, G_SCRIPTED))
+ LF_CLR(TXT_AUTOINDENT);
+ else {
if (LF_ISSET(TXT_AUTOINDENT)) {
LF_SET(TXT_EOFCHAR);
if (v_txt_auto(sp, sp->lno, NULL, 0, tp))
goto err;
}
txt_prompt(sp, tp, prompt, flags);
- } else
- LF_CLR(TXT_AUTOINDENT);
+ }
for (carat_st = C_NOTSET;;) {
if (v_event_get(sp, &ev, 0, 0))
diff --git a/usr.bin/vi/ex/version.h b/usr.bin/vi/ex/version.h
index badc55d163b..429b3471001 100644
--- a/usr.bin/vi/ex/version.h
+++ b/usr.bin/vi/ex/version.h
@@ -1,2 +1,2 @@
#define VI_VERSION \
- "Version 1.76 (9/15/96) The CSRG, University of California, Berkeley."
+ "Version 1.78 (10/1/96) The CSRG, University of California, Berkeley."
diff --git a/usr.bin/vi/include/perl_extern.h b/usr.bin/vi/include/perl_extern.h
index d8323be96f8..5198675b09c 100644
--- a/usr.bin/vi/include/perl_extern.h
+++ b/usr.bin/vi/include/perl_extern.h
@@ -1,2 +1,8 @@
int perl_end __P((GS *));
int perl_init __P((GS *));
+int perl_screen_end __P((SCR*));
+int perl_ex_perl __P((SCR*, CHAR_T *, size_t, recno_t, recno_t));
+int perl_ex_perldo __P((SCR*, CHAR_T *, size_t, recno_t, recno_t));
+#ifdef USE_SFIO
+Sfdisc_t* sfdcnewnvi __P((SCR*));
+#endif
diff --git a/usr.bin/vi/include/vi_extern.h b/usr.bin/vi/include/vi_extern.h
index bcd23595ecb..fb50fac1383 100644
--- a/usr.bin/vi/include/vi_extern.h
+++ b/usr.bin/vi/include/vi_extern.h
@@ -116,6 +116,7 @@ void vs_home __P((SCR *));
void vs_update __P((SCR *, const char *, const char *));
void vs_msg __P((SCR *, mtype_t, char *, size_t));
int vs_ex_resolve __P((SCR *, int *));
+int vs_resolve __P((SCR *, int));
int vs_repaint __P((SCR *, EVENT *));
int vs_refresh __P((SCR *, int));
int vs_column __P((SCR *, size_t *));
diff --git a/usr.bin/vi/vi/v_itxt.c b/usr.bin/vi/vi/v_itxt.c
index 347629d5202..871ee8c581a 100644
--- a/usr.bin/vi/vi/v_itxt.c
+++ b/usr.bin/vi/vi/v_itxt.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_itxt.c 10.14 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)v_itxt.c 10.15 (Berkeley) 9/25/96";
#endif /* not lint */
#include <sys/types.h>
@@ -57,7 +57,7 @@ static const char sccsid[] = "@(#)v_itxt.c 10.14 (Berkeley) 9/15/96";
(void)log_cursor(sp); \
}
-static u_int32_t set_txt_std __P((SCR *, VICMD *, u_int));
+static u_int32_t set_txt_std __P((SCR *, VICMD *, u_int32_t));
/*
* v_iA -- [count]A
diff --git a/usr.bin/vi/vi/v_mark.c b/usr.bin/vi/vi/v_mark.c
index 037bad124b7..447430efabe 100644
--- a/usr.bin/vi/vi/v_mark.c
+++ b/usr.bin/vi/vi/v_mark.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_mark.c 10.7 (Berkeley) 3/6/96";
+static const char sccsid[] = "@(#)v_mark.c 10.8 (Berkeley) 9/20/96";
#endif /* not lint */
#include <sys/types.h>
@@ -215,15 +215,18 @@ mark(sp, vp, cmd)
* the character before the current one (this is safe because we know
* the search had to move to succeed).
*
- * Mark motions become line mode opertions if they start at column 0
- * and end at column 0 of another line.
+ * Mark motions become line mode opertions if they start at the first
+ * nonblank and end at column 0 of another line.
*/
if (vp->m_start.lno < vp->m_stop.lno && vp->m_stop.cno == 0) {
if (db_get(sp, --vp->m_stop.lno, DBG_FATAL, NULL, &len))
return (1);
- if (vp->m_start.cno == 0)
- F_SET(vp, VM_LMODE);
vp->m_stop.cno = len ? len - 1 : 0;
+ len = 0;
+ if (nonblank(sp, vp->m_start.lno, &len))
+ return (1);
+ if (vp->m_start.cno <= len)
+ F_SET(vp, VM_LMODE);
} else
--vp->m_stop.cno;
diff --git a/usr.bin/vi/vi/v_search.c b/usr.bin/vi/vi/v_search.c
index 94a53691613..4f7a2671ab8 100644
--- a/usr.bin/vi/vi/v_search.c
+++ b/usr.bin/vi/vi/v_search.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_search.c 10.17 (Berkeley) 6/30/96";
+static const char sccsid[] = "@(#)v_search.c 10.18 (Berkeley) 9/19/96";
#endif /* not lint */
#include <sys/types.h>
@@ -496,15 +496,18 @@ v_correct(sp, vp, isdelta)
* the current one (this is safe because we know the search had to move
* to succeed).
*
- * Searches become line mode operations if they start at column 0 and
- * end at column 0 of another line.
+ * Searches become line mode operations if they start at the first
+ * nonblank and end at column 0 of another line.
*/
if (vp->m_start.lno < vp->m_stop.lno && vp->m_stop.cno == 0) {
if (db_get(sp, --vp->m_stop.lno, DBG_FATAL, NULL, &len))
return (1);
- if (vp->m_start.cno == 0)
- F_SET(vp, VM_LMODE);
vp->m_stop.cno = len ? len - 1 : 0;
+ len = 0;
+ if (nonblank(sp, vp->m_start.lno, &len))
+ return (1);
+ if (vp->m_start.cno <= len)
+ F_SET(vp, VM_LMODE);
} else
--vp->m_stop.cno;
diff --git a/usr.bin/vi/vi/v_txt.c b/usr.bin/vi/vi/v_txt.c
index d4068f4a296..d0b286f0e18 100644
--- a/usr.bin/vi/vi/v_txt.c
+++ b/usr.bin/vi/vi/v_txt.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)v_txt.c 10.83 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)v_txt.c 10.86 (Berkeley) 9/20/96";
#endif /* not lint */
#include <sys/types.h>
@@ -535,14 +535,14 @@ next: if (v_event_get(sp, evp, 0, ec_flags))
/*
* !!!
* If the first character of the input is a nul, replay the previous
- * input. Note, it was okay to replay non-existent input. This was
- * not documented as far as I know, and is a great test of vi clones.
+ * input. (Historically, it's okay to replay non-existent input.)
+ * This was not documented as far as I know, and is a great test of vi
+ * clones.
*/
- if (!LF_ISSET(TXT_REPLAY) && evp->e_c == '\0') {
+ if (rcol == 0 && !LF_ISSET(TXT_REPLAY) && evp->e_c == '\0') {
if (vip->rep == NULL)
goto done;
- rcol = 0;
abb = AB_NOTSET;
LF_CLR(TXT_RECORD);
LF_SET(TXT_REPLAY);
@@ -1951,24 +1951,20 @@ txt_dent(sp, tp, isindent)
/*
* Back up over any previous <blank> characters, changing them into
- * overwrite characters (including any ai characters).
+ * overwrite characters (including any ai characters). Then figure
+ * out the current screen column.
*/
- for (; tp->cno > tp->offset; --tp->cno, ++tp->owrite)
- if (tp->lb[tp->cno - 1] == ' ')
- --current;
- else if (tp->lb[tp->cno - 1] == '\t') {
- off = COL_OFF(current, ts);
- if (current > off)
- current -= off;
- else
- current = 0;
- } else
- break;
+ for (; tp->cno > tp->offset &&
+ (tp->lb[tp->cno - 1] == ' ' || tp->lb[tp->cno - 1] == '\t');
+ --tp->cno, ++tp->owrite);
+ for (current = cno = 0; cno < tp->cno; ++cno)
+ current += tp->lb[cno] == '\t' ?
+ COL_OFF(current, ts) : KEY_LEN(sp, tp->lb[cno]);
/*
* If we didn't move up to or past the target, it's because there
* weren't enough characters to delete, e.g. the first character
- * of the line was an tp->offset character, and the user entered
+ * of the line was a tp->offset character, and the user entered
* ^D to move to the beginning of a line. An example of this is:
*
* :set ai sw=4<cr>i<space>a<esc>i^T^D
diff --git a/usr.bin/vi/vi/vi.c b/usr.bin/vi/vi/vi.c
index f5befc138ab..b2dca8c1c90 100644
--- a/usr.bin/vi/vi/vi.c
+++ b/usr.bin/vi/vi/vi.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vi.c 10.55 (Berkeley) 8/17/96";
+static const char sccsid[] = "@(#)vi.c 10.56 (Berkeley) 9/25/96";
#endif /* not lint */
#include <sys/types.h>
@@ -39,7 +39,7 @@ static gcret_t v_cmd __P((SCR *, VICMD *, VICMD *, VICMD *, int *, int *));
static int v_count __P((SCR *, ARG_CHAR_T, u_long *));
static void v_dtoh __P((SCR *));
static int v_init __P((SCR *));
-static gcret_t v_key __P((SCR *, int, EVENT *, u_int));
+static gcret_t v_key __P((SCR *, int, EVENT *, u_int32_t));
static int v_keyword __P((SCR *));
static int v_motion __P((SCR *, VICMD *, VICMD *, int *));
diff --git a/usr.bin/vi/vi/vs_line.c b/usr.bin/vi/vi/vs_line.c
index 7529898e71e..b439de925ce 100644
--- a/usr.bin/vi/vi/vs_line.c
+++ b/usr.bin/vi/vi/vs_line.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_line.c 10.18 (Berkeley) 5/13/96";
+static const char sccsid[] = "@(#)vs_line.c 10.19 (Berkeley) 9/26/96";
#endif /* not lint */
#include <sys/types.h>
@@ -221,7 +221,9 @@ empty: (void)gp->scr_addstr(sp,
offset_in_line = smp->c_sboff;
offset_in_char = smp->c_scoff;
p = &p[offset_in_line];
- if (skip_cols > cols_per_screen)
+
+ /* Set cols_per_screen to 2nd and later line length. */
+ if (O_ISSET(sp, O_LEFTRIGHT) || skip_cols > cols_per_screen)
cols_per_screen = sp->cols;
goto display;
}
@@ -241,7 +243,9 @@ empty: (void)gp->scr_addstr(sp,
smp->c_sboff = offset_in_line;
smp->c_scoff = offset_in_char;
p = &p[offset_in_line];
- if (skip_cols > cols_per_screen)
+
+ /* Set cols_per_screen to 2nd and later line length. */
+ if (O_ISSET(sp, O_LEFTRIGHT) || skip_cols > cols_per_screen)
cols_per_screen = sp->cols;
goto display;
}
@@ -259,6 +263,9 @@ empty: (void)gp->scr_addstr(sp,
break;
}
+ /* Set cols_per_screen to 2nd and later line length. */
+ cols_per_screen = sp->cols;
+
/* Put starting info for this line in the cache. */
if (scno != skip_cols) {
smp->c_sboff = offset_in_line;
@@ -280,10 +287,7 @@ empty: (void)gp->scr_addstr(sp,
continue;
scno -= cols_per_screen;
- /*
- * Reset the cols_per_screen to second and subsequent
- * line length.
- */
+ /* Set cols_per_screen to 2nd and later line length. */
cols_per_screen = sp->cols;
/*
diff --git a/usr.bin/vi/vi/vs_msg.c b/usr.bin/vi/vi/vs_msg.c
index 881a1c9e8dd..5eb83c438ac 100644
--- a/usr.bin/vi/vi/vs_msg.c
+++ b/usr.bin/vi/vi/vs_msg.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_msg.c 10.75 (Berkeley) 8/17/96";
+static const char sccsid[] = "@(#)vs_msg.c 10.76 (Berkeley) 9/26/96";
#endif /* not lint */
#include <sys/types.h>
@@ -648,6 +648,8 @@ vs_ex_resolve(sp, continuep)
*
* This routine is called from the main vi loop to periodically ensure that
* the user has seen any messages that have been displayed.
+ *
+ * PUBLIC: int vs_resolve __P((SCR *, int));
*/
int
vs_resolve(sp, forcewait)
diff --git a/usr.bin/vi/vi/vs_refresh.c b/usr.bin/vi/vi/vs_refresh.c
index e8bcddea9c0..1a91dce0bff 100644
--- a/usr.bin/vi/vi/vs_refresh.c
+++ b/usr.bin/vi/vi/vs_refresh.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_refresh.c 10.41 (Berkeley) 9/15/96";
+static const char sccsid[] = "@(#)vs_refresh.c 10.43 (Berkeley) 9/26/96";
#endif /* not lint */
#include <sys/types.h>
@@ -82,23 +82,7 @@ vs_refresh(sp, forcepaint)
F_SET(tsp, SC_SCR_REDRAW | SC_STATUS);
/*
- * 2: Paint any missing status lines.
- *
- * XXX
- * This is fairly evil. Status lines are written using the vi message
- * mechanism, since we have no idea how long they are. Since we may be
- * painting screens other than the current one, we don't want to make
- * the user wait. We depend heavily on there not being any other lines
- * currently waiting to be displayed and the message truncation code in
- * the msgq_status routine working.
- */
- for (tsp = sp->gp->dq.cqh_first;
- tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next)
- if (F_ISSET(tsp, SC_STATUS))
- vs_resolve(tsp, 0);
-
- /*
- * 3: Related or dirtied screens, or screens with messages.
+ * 2: Related or dirtied screens, or screens with messages.
*
* If related screens share a view into a file, they may have been
* modified as well. Refresh any screens that aren't exiting that
@@ -122,7 +106,7 @@ vs_refresh(sp, forcepaint)
}
/*
- * 4: Refresh the current screen.
+ * 3: Refresh the current screen.
*
* Always refresh the current screen, it may be a cursor movement.
* Also, always do it last -- that way, SC_SCR_REDRAW can be set
@@ -133,6 +117,22 @@ vs_refresh(sp, forcepaint)
return (1);
/*
+ * 4: Paint any missing status lines.
+ *
+ * XXX
+ * This is fairly evil. Status lines are written using the vi message
+ * mechanism, since we have no idea how long they are. Since we may be
+ * painting screens other than the current one, we don't want to make
+ * the user wait. We depend heavily on there not being any other lines
+ * currently waiting to be displayed and the message truncation code in
+ * the msgq_status routine working.
+ */
+ for (tsp = sp->gp->dq.cqh_first;
+ tsp != (void *)&sp->gp->dq; tsp = tsp->q.cqe_next)
+ if (F_ISSET(tsp, SC_STATUS))
+ vs_resolve(tsp, 0);
+
+ /*
* A side-effect of refreshing the screen is that it's now ready
* for everything else, i.e. messages.
*/
@@ -160,7 +160,7 @@ vs_paint(sp, flags)
VI_PRIVATE *vip;
recno_t lastline, lcnt;
size_t cwtotal, cnt, len, notused, off, y;
- int ch, didpaint, isempty, leftright_warp, shifted;
+ int ch, didpaint, isempty, leftright_warp;
char *p;
#define LNO sp->lno /* Current file line. */
@@ -579,34 +579,36 @@ slow: for (smp = HMAP; smp->lno != LNO; ++smp);
* first screen as compared to subsequent ones.
*/
if (O_ISSET(sp, O_LEFTRIGHT)) {
- /* Get the screen column for this character. */
+ /*
+ * Get the screen column for this character, and correct
+ * for the number option offset.
+ */
cnt = vs_columns(sp, NULL, LNO, &CNO, NULL);
-
- shifted = 0;
+ if (O_ISSET(sp, O_NUMBER))
+ cnt -= O_NUMBER_LENGTH;
/* Adjust the window towards the beginning of the line. */
off = smp->coff;
if (off >= cnt) {
- while (off >= cnt)
+ do {
if (off >= O_VAL(sp, O_SIDESCROLL))
off -= O_VAL(sp, O_SIDESCROLL);
else {
off = 0;
break;
}
- shifted = 1;
+ } while (off >= cnt);
+ goto shifted;
}
/* Adjust the window towards the end of the line. */
if (off == 0 && off + SCREEN_COLS(sp) < cnt ||
off != 0 && off + sp->cols < cnt) {
- while (off + sp->cols < cnt)
+ do {
off += O_VAL(sp, O_SIDESCROLL);
- shifted = 1;
- }
+ } while (off + sp->cols < cnt);
- /* Fill in screen map with the new offset. */
- if (shifted) {
+shifted: /* Fill in screen map with the new offset. */
if (F_ISSET(sp, SC_TINPUT_INFO))
smp->coff = off;
else {
diff --git a/usr.bin/vi/vi/vs_split.c b/usr.bin/vi/vi/vs_split.c
index 30e60e8222b..89492357004 100644
--- a/usr.bin/vi/vi/vs_split.c
+++ b/usr.bin/vi/vi/vs_split.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "@(#)vs_split.c 10.29 (Berkeley) 8/19/96";
+static const char sccsid[] = "@(#)vs_split.c 10.30 (Berkeley) 9/20/96";
#endif /* not lint */
#include <sys/types.h>
@@ -48,6 +48,7 @@ vs_split(sp, new, ccl)
gp = sp->gp;
/* Check to see if it's possible. */
+ /* XXX: The IS_ONELINE fix will change this, too. */
if (sp->rows < 4) {
msgq(sp, M_ERR,
"222|Screen must be larger than %d lines to split", 4 - 1);
@@ -88,7 +89,8 @@ vs_split(sp, new, ccl)
* with the cursor on the colon command line. Then split the screen
* in half and update the shared information.
*/
- splitup = !ccl && (vs_sm_cursor(sp, &smp) ? 0 : smp - HMAP) > half;
+ splitup =
+ !ccl && (vs_sm_cursor(sp, &smp) ? 0 : (smp - HMAP) + 1) >= half;
if (splitup) { /* Old is bottom half. */
new->rows = sp->rows - half; /* New. */
new->woff = sp->woff;