greim@sbsvax.UUCP (Michael Greim) (03/30/88)
Hi folks, (set tabstop=4) Thanks for the fixes to vi, which have been posted recently. I applied them and they seem to work. I discovered that some time ago I have found fixes for some bugs which may be of interest to you, so here they are. All the following applies to 4BSD vi. The source code is taken from 4.2BSD vi modified locally. This should explain any inconsistancies. 1.) Symptoms This bug is in 4.2BSD vi and quite probably in its predecessors. Go to the end of a file with more than three pages. Type 3^B from visual mode. Result : the cursor is stuck in a strange place. I cannot tell more, as I cannot lay my hands on an old vi to test. I am citing from my changes-log. Diagnosis In a special place there is a typographical error: + instead of - Therapy In ex_vmain.c around line 429 the source looks like this /* * ^B Window backwards, with 2 lines of continuity. * Inverse of ^F. */ case CTRL(b): vsave(); if (one + vcline != dot && vcnt > 2) { addr = dot - vcline + 2 + (cnt-1)*basWLINES; forbid (addr <= zero); dot = addr; vcnt = vcline = 0; } vzop(0, 0, '^'); continue; Change the line addr = dot - vcline + 2 + (cnt-1)*basWLINES; to addr = dot - vcline + 2 - (cnt-1)*basWLINES; and all is weel. 2.) Symptoms This bug is even in 4.3BSD vi, ULTRIX vi. (Can't start the SUNs : they have been moved as there is some restructuring done to some of our rooms, and we get new connections too :-) Take a file with some text in it. Write in some places 'mg' (without the quotes). Add 'mg' to the end of line. Issue from command mode (or what's it called ? Where you get the ':' prompt ?) the command '%s/mg/Michael Greim/gc' Vi asks you if it is correct to change the string by printing the line in which it found the string and a line containing blanks and some ^^^ to mark the place. The marks are sometimes (!) in a wrong place, quite probably when asking about the 'mg' at the end of a line. I just tried vi on ULTRIX, it has this bug too. The bug is not linked in any magical way to my name, this was just the occasion I discovered the bug. Diagnosis Just some flush is missing (Can't remember details :-) Therapy In ex_re.c in the routine 'confirmed' it looks like pofix(); pline(lineno(a)); if (inopen) putchar('\n' | QUOTE); c = column(loc1 - 1); ugo(c - 1 + (inopen ? 1 : 0), ' '); Change the ...inopen... if condition to if (inopen) { putchar('\n' | QUOTE); flush(); } and whooosh, the bug speeds away. 3.) Symptom This bug is also in every version of vi I could lay my hands on. Do the following, start by being in visual mode : - remove some characters with 'x' - mark two lines with 'a' and 'b' (Command : ma rsp. mb from visual) - :'a,'by - go to some place (in visual) and try to put : p You get the last character you removed using 'x'. Diagnosis (I am citing from my changes-log and from faulty memory. I did this fix in august 1987 :-) Ex and vi use different sets of buffers for x'd and y'd text. When you yank in ex, the buffer of vi for x'd characters is not cleared. When you put something, it looks first into the 'x' buffer, and only if this is empty, it looks into the 'yank' buffer. Therapy After yanking or deleting, clean the 'x' buffer. In ex_cmds.c around line 252 it looks like /* delete */ case 'd': /* * Caution: dp and dl have special meaning already. */ tail("delete"); c = cmdreg(); setCNL(); vmacchng(0); if (c) YANKreg(c); delete(0); appendnone(); continue; Insert the following line before 'continue' DEL[0] = '\0'; /* 28.aug.87 mg */ Around line 750 it looks like /* yank */ case 'y': tail("yank"); c = cmdreg(); setcount(); eol(); vmacchng(0); if (c) YANKreg(c); else yank(); continue; Insert the following line before 'continue' DEL[0] = '\0'; /* 28.aug.87 mg */ Now everything should work fine. If I made some errors, please do not hesitate to correct me (politely, please :-}). Absorb, apply and enjoy, Michael -- +------------------------------------------------------------------------------+ | UUCP: ...!uunet!unido!sbsvax!greim | Michael T. Greim | | or greim@sbsvax.UUCP | Universitaet des Saarlandes | | CSNET: greim%sbsvax.uucp@Germany.CSnet| FB 10 - Informatik (Dept. of CS) | | ARPA: greim%sbsvax.uucp@uunet.UU.NET | Bau 36, Im Stadtwald 15 | | Phone: +49 681 302 2434 | D-6600 Saarbruecken 11, West Germany | +------------------------------------------------------------------------------+ | Watch this space. Don't let it escape. | +------------------------------------------------------------------------------+