[net.bugs] 3 minor 'vi' bugs.

chris@pixutl.UUCP (chris) (07/03/84)

[]

   Try this: vi a file, type '^F', then '100^B', then '^G'. If
everything still looks normal, try a few more '100^B'.
   Now try that one:  ':set ht=0'.
   Finally, try ':set sw=0', then open a new line and type '^D'.

   

   The first bug is in the CTRL(b) case of vmain(), line ~= 425 in
ex_vmain.c. There are some parentheses missing in the address
calculation which causes it to get higher rather than lower when
you enter a 'n^B'. If the resulting address is greater than the
number of lines in the file, you will get an empty screen with a
cursor somewhere in the middle of it, or a core dump.

	/* original code */
	addr = dot - vcline - 2 + (cnt-1)*basWLINES;
	/* modified code */
	addr = dot - ((vcline - 2) + (cnt-1)*basWLINES);


   The second and third 'bugs' (some people may argue that setting
these values at 0 doesn't make much sense anyway, but sooner or later,
someone will try it) can be fixed easily by adding the same check for
these 2 values as the one for 'TABSTOP'. In ex_set.c, around line
100, add these lines:

			if (value(HARDTABS) <= 0)
				value(HARDTABS) = TABS;
			if (value(SHIFTWIDTH) <= 0)
				value(SHIFTWIDTH) = TABS;

after these lines:

			if (value(TABSTOP) <= 0)
				value(TABSTOP) = TABS;


   Any comments or other suggestions?


   Chris.
-- 


 Chris Bertin            :         (617) 657-8720 x2318
 Pixel Computer Inc.     :
 260 Fordham Rd.         :  {allegra|ihnp4|cbosgd|ima|genrad|amd|harvard}\
 Wilmington, Ma 01887    :     !wjh12!pixel!pixutl!chris

stevens@inuxh.UUCP (W Stevens) (07/09/84)

>    >   The first bug is in the CTRL(b) case of vmain(), line ~= 425 in
>    >ex_vmain.c. There are some parentheses missing in the address ...
>    >
>    >	/* original code */
>    >	addr = dot - vcline - 2 + (cnt-1)*basWLINES;
>    >	/* modified code */
>    >	addr = dot - ((vcline - 2) + (cnt-1)*basWLINES);

>    I'll have to take exception to this; the correctly modified line
>    should be:
>    
>    	addr = dot - vcline - 2 - (cnt-1)*basWLINES;

Wrongo; the first fix is correct.  In fact, there's another bug in the
following line, too.  The complete fix is:

		if (one + vcline != dot && vcnt > 2) {
	*		addr = dot - vcline + 2 - (cnt-1)*basWLINES;
	*		forbid (addr <= one);
			dot = addr;
			vcnt = vcline = 0;
		}

--
Scott Stevens
AT&T Consumer Products
Indianapolis, Indiana, USA
UUCP: inuxh!stevens

jeff@voder.UUCP (Jeff Gilliam) (07/12/84)

>   Try this: vi a file, type '^F', then '100^B', then '^G'. If
>everything still looks normal, try a few more '100^B'.
>   Now try that one:  ':set ht=0'.
>   Finally, try ':set sw=0', then open a new line and type '^D'.
>
>   The first bug is in the CTRL(b) case of vmain(), line ~= 425 in
>ex_vmain.c. There are some parentheses missing in the address ...
>
>	/* original code */
>	addr = dot - vcline - 2 + (cnt-1)*basWLINES;
>	/* modified code */
>	addr = dot - ((vcline - 2) + (cnt-1)*basWLINES);

I'll have to take exception to this; the correctly modified line
should be:

	addr = dot - vcline - 2 - (cnt-1)*basWLINES;

After making this change try the following to verify it really
works:

	vi somefile
	10^F			(move forward 10 screens full)
	10^B			(you should be right back at line 1)
	.
	.
	.

Regarding your second and third bugs: they're fixed in 4.2 (with
exactly the same code you suggest).

Jeff "No clever signature line yet" Gilliam