From 63d9da322f438a98bb654cc4976874fa89f1fa62 Mon Sep 17 00:00:00 2001
From: Alison Winters <alisonatwork@outlook.com>
Date: Sat, 27 Feb 2021 15:18:45 -0800
Subject: vi: restore 0 offset after :set noXXX command

Fixes bug where commands after the first noXXX command are ignored.
    e.g. :set noic tabstop=4

While at it, stop recognizing "notabstop=NNN".

function                                             old     new   delta
colon                                               2990    2965     -25

Signed-off-by: Alison Winters <alisonatwork@outlook.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
 editors/vi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/editors/vi.c b/editors/vi.c
index 458ca6293..e77c348fb 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2709,7 +2709,6 @@ static void colon(char *buf)
 #  if ENABLE_FEATURE_VI_SETOPTS
 		char *argp;
 #  endif
-		i = 0;			// offset into args
 		// only blank is regarded as args delimiter. What about tab '\t'?
 		if (!args[0] || strcasecmp(args, "all") == 0) {
 			// print out values of all options
@@ -2732,15 +2731,16 @@ static void colon(char *buf)
 #  if ENABLE_FEATURE_VI_SETOPTS
 		argp = args;
 		while (*argp) {
-			if (strncmp(argp, "no", 2) == 0)
-				i = 2;		// ":set noautoindent"
+			i = 0;
+			if (argp[0] == 'n' && argp[1] == 'o') // "noXXX"
+				i = 2;
 			setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
 			setops(argp, "flash "     , i, "fl", VI_ERR_METHOD);
 			setops(argp, "ignorecase ", i, "ic", VI_IGNORECASE);
 			setops(argp, "showmatch " , i, "sm", VI_SHOWMATCH );
-			if (strncmp(argp + i, "tabstop=", 8) == 0) {
+			if (strncmp(argp, "tabstop=", 8) == 0) {
 				int t = 0;
-				sscanf(argp + i+8, "%u", &t);
+				sscanf(argp + 8, "%u", &t);
 				if (t > 0 && t <= MAX_TABSTOP)
 					tabstop = t;
 			}
-- 
cgit v1.2.3