Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Oct 2000 13:28:00 +0200
From:      Christian Weisgerber <naddy@mips.inka.de>
To:        freebsd-hackers@freebsd.org
Subject:   Anybody want to review vi patch?
Message-ID:  <20001021132800.A67078@kemoauc.mips.inka.de>

next in thread | raw e-mail | index | archive | help

--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

There's a bug in nvi 1.79.  The options "noprint", "print", and
"octal" don't work properly.  When these options are changed, the
routine that evaluates them is called before the option has been
set.

Do we have any people who know their way around the guts of nvi?
I've appended a patch, partly based on a change in nvi 1.81 where
this is fixed incompletely, and I'd like somebody to review this.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de

--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="nvi.patch"

diff -ur /usr/src/contrib/nvi/common/options.c nvi/common/options.c
--- /usr/src/contrib/nvi/common/options.c	Sat Apr 19 01:36:33 1997
+++ nvi/common/options.c	Sat Oct 21 13:06:06 2000
@@ -132,7 +132,7 @@
 /* O_NUMBER	    4BSD */
 	{"number",	f_reformat,	OPT_0BOOL,	0},
 /* O_OCTAL	  4.4BSD */
-	{"octal",	f_print,	OPT_0BOOL,	0},
+	{"octal",	f_octal,	OPT_0BOOL,	0},
 /* O_OPEN	    4BSD */
 	{"open",	NULL,		OPT_1BOOL,	0},
 /* O_OPTIMIZE	    4BSD */
diff -ur /usr/src/contrib/nvi/common/options_f.c nvi/common/options_f.c
--- /usr/src/contrib/nvi/common/options_f.c	Fri Nov  1 07:45:38 1996
+++ nvi/common/options_f.c	Sat Oct 21 13:11:14 2000
@@ -190,6 +190,34 @@
 	char *str;
 	u_long *valp;
 {
+	/* Preset the value, needed for reinitialization of lookup table. */
+	if (o_set(sp, op-sp->opts, OS_STRDUP, str, 0))
+		return(1);
+
+	/* Reinitialize the key fast lookup table. */
+	v_key_ilookup(sp);
+
+	/* Reformat the screen. */
+	F_SET(sp, SC_SCR_REFORMAT);
+	return (0);
+}
+
+/*
+ * PUBLIC: int f_octal __P((SCR *, OPTION *, char *, u_long *));
+ */
+int
+f_octal(sp, op, str, valp)
+	SCR *sp;
+	OPTION *op;
+	char *str;
+	u_long *valp;
+{
+	/* Preset the value, needed for reinitialization of lookup table. */
+	if (*valp)
+		O_CLR(sp, op - sp->opts);
+	else
+		O_SET(sp, op - sp->opts);
+
 	/* Reinitialize the key fast lookup table. */
 	v_key_ilookup(sp);
 
diff -ur /usr/src/contrib/nvi/include/com_extern.h nvi/include/com_extern.h
--- /usr/src/contrib/nvi/include/com_extern.h	Fri Nov  1 07:45:31 1996
+++ nvi/include/com_extern.h	Sat Oct 21 13:05:53 2000
@@ -157,6 +157,7 @@
 int f_msgcat __P((SCR *, OPTION *, char *, u_long *));
 int f_paragraph __P((SCR *, OPTION *, char *, u_long *));
 int f_print __P((SCR *, OPTION *, char *, u_long *));
+int f_octal __P((SCR *, OPTION *, char *, u_long *));
 int f_readonly __P((SCR *, OPTION *, char *, u_long *));
 int f_recompile __P((SCR *, OPTION *, char *, u_long *));
 int f_reformat __P((SCR *, OPTION *, char *, u_long *));

--UugvWAfsgieZRqgk--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001021132800.A67078>