Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Oct 2000 14:55:28 +0200 (CEST)
From:      Christian Weisgerber <naddy@mips.inka.de>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/22182: vi options noprint/print/octal broken
Message-ID:  <200010211255.e9LCtSn71210@kemoauc.mips.inka.de>

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

>Number:         22182
>Category:       bin
>Synopsis:       vi options noprint/print/octal broken
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 21 06:40:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Christian Weisgerber
>Release:        FreeBSD 5.0-CURRENT alpha
>Organization:
>Environment:

>Description:

There's a bug in our vi (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.

>How-To-Repeat:

For option "octal":
* Insert a non-printable character >0x80.
* :set octal
  => The character is still displayed in hex.
* :set nooctal
  => The display switches to octal.

Similarly for "print" and "noprint".

>Fix:

From NetBSD:

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 14:42:25 2000
@@ -128,11 +128,11 @@
 /* O_MSGCAT	  4.4BSD */
 	{"msgcat",	f_msgcat,	OPT_STR,	0},
 /* O_NOPRINT	  4.4BSD */
-	{"noprint",	f_print,	OPT_STR,	0},
+	{"noprint",	f_print,	OPT_STR,	OPT_EARLYSET},
 /* O_NUMBER	    4BSD */
 	{"number",	f_reformat,	OPT_0BOOL,	0},
 /* O_OCTAL	  4.4BSD */
-	{"octal",	f_print,	OPT_0BOOL,	0},
+	{"octal",	f_print,	OPT_0BOOL,	OPT_EARLYSET},
 /* O_OPEN	    4BSD */
 	{"open",	NULL,		OPT_1BOOL,	0},
 /* O_OPTIMIZE	    4BSD */
@@ -142,7 +142,7 @@
 /* O_PATH	  4.4BSD */
 	{"path",	NULL,		OPT_STR,	0},
 /* O_PRINT	  4.4BSD */
-	{"print",	f_print,	OPT_STR,	0},
+	{"print",	f_print,	OPT_STR,	OPT_EARLYSET},
 /* O_PROMPT	    4BSD */
 	{"prompt",	NULL,		OPT_1BOOL,	0},
 /* O_READONLY	    4BSD (undocumented) */
@@ -568,6 +568,14 @@
 						break;
 				}
 
+			if (F_ISSET(op, OPT_EARLYSET)) {
+			    /* Set the value. */
+			    if (turnoff)
+				O_CLR(sp, offset);
+			    else
+				O_SET(sp, offset);
+			}
+
 			/* Report to subsystems. */
 			if (op->func != NULL &&
 			    op->func(sp, spo, NULL, &turnoff) ||
@@ -578,11 +586,13 @@
 				break;
 			}
 
-			/* Set the value. */
-			if (turnoff)
+			if (!F_ISSET(op, OPT_EARLYSET)) {
+			    /* Set the value. */
+			    if (turnoff)
 				O_CLR(sp, offset);
-			else
+			    else
 				O_SET(sp, offset);
+			}
 			break;
 		case OPT_NUM:
 			if (turnoff) {
@@ -653,6 +663,14 @@
 			    O_VAL(sp, offset) == value)
 				break;
 
+			if (F_ISSET(op, OPT_EARLYSET)) {
+			    /* Set the value. */
+			    if (o_set(sp, offset, 0, NULL, value)) {
+				rval = 1;
+				break;
+			    }
+			}
+
 			/* Report to subsystems. */
 			if (op->func != NULL &&
 			    op->func(sp, spo, sep, &value) ||
@@ -663,9 +681,11 @@
 				break;
 			}
 
-			/* Set the value. */
-			if (o_set(sp, offset, 0, NULL, value))
+			if (!F_ISSET(op, OPT_EARLYSET)) {
+			    /* Set the value. */
+			    if (o_set(sp, offset, 0, NULL, value))
 				rval = 1;
+			}
 			break;
 		case OPT_STR:
 			if (turnoff) {
@@ -690,6 +710,14 @@
 			    !strcmp(O_STR(sp, offset), sep))
 				break;
 
+			if (F_ISSET(op, OPT_EARLYSET)) {
+			    /* Set the value. */
+			    if (o_set(sp, offset, OS_STRDUP, sep, 0)) {
+				rval = 1;
+				break;
+			    }
+			}
+
 			/* Report to subsystems. */
 			if (op->func != NULL &&
 			    op->func(sp, spo, sep, NULL) ||
@@ -700,9 +728,11 @@
 				break;
 			}
 
-			/* Set the value. */
-			if (o_set(sp, offset, OS_STRDUP, sep, 0))
+			if (!F_ISSET(op, OPT_EARLYSET)) {
+			    /* Set the value. */
+			    if (o_set(sp, offset, OS_STRDUP, sep, 0))
 				rval = 1;
+			}
 			break;
 		default:
 			abort();
diff -ur /usr/src/contrib/nvi/common/options.h nvi/common/options.h
--- /usr/src/contrib/nvi/common/options.h	Fri Nov  1 07:45:38 1996
+++ nvi/common/options.h	Sat Oct 21 14:41:48 2000
@@ -89,6 +89,7 @@
 #define	OPT_NOSET	0x010		/* Option may not be set. */
 #define	OPT_NOUNSET	0x020		/* Option may not be unset. */
 #define	OPT_NOZERO	0x040		/* Option may not be set to 0. */
+#define	OPT_EARLYSET	0x080		/* Func called after value is set */
 	u_int8_t flags;
 };
 

>Release-Note:
>Audit-Trail:
>Unformatted:


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




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