[BusyBox] VI

Stephane Billiart stephane at reefedge.com
Sat Jan 31 15:56:05 UTC 2004


On Sat, Jan 17, 2004 at 11:45:20PM +0100, Richard Kojedzinszky wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi all,
> 
> I dont know if someone has already discovered this bug or not, but i write
> it down:
> i just opened a file for editing, with busybox's vi, entered insert mode,
> and pressed the 'END' button some times. And i saw that with everytime i
> press that, it jumps to the next line's end. I suppose this is a bug.
> 
> Another was, when issuing the command 'cw' at the last line's last word,
> and no spaces after that word, then the word's last char stayed in the
> buffer. Maybe this is another bug?
> 
> I use the 1.00-pre5 busybox dist, and posted a patch which fixes these two
> bugs maybe.
> 
> I hope i not missed anything. :)
> 
> Best regards,
> Kojedzinszky Richard
> TvNetWork Rt.
> E-mail: krichy at tvnetwork.hu
> PGP: 0x24E79141
>   Fingerprint = 6847 ECFF EF58 0C09 18A5  16CF 270F 0C6F 24E7 9141
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Made with pgp4pine 1.75-6
> 
> iD8DBQFACbsEJw8MbyTnkUERApmqAJ9+6QAbMvKA+P6cZvVNCWzhOPoG6ACcD8JA
> XeV6NZ84Zhxoc/vqcDamU/c=
> =texM
> -----END PGP SIGNATURE-----

> diff -ruNP busybox-1.00-pre5/editors/vi.c busybox-1.00-pre5.vi/editors/vi.c
> --- busybox-1.00-pre5/editors/vi.c	Mon Sep 15 10:33:36 2003
> +++ busybox-1.00-pre5.vi/editors/vi.c	Sat Jan 17 23:09:21 2004
> @@ -1669,7 +1669,9 @@
>  		q = dot;
>  	} else if (strchr("wW", c)) {
>  		do_cmd(c);		// execute movement cmd
> -		if (dot > text)
> +		// if we are at the next word's first char
> +		// step back one char
> +		if (dot > text && isspace(dot[-1]))
>  			dot--;		// move back off of next word
>  		if (dot > text && *dot == '\n')
>  			dot--;		// stay off NL
> @@ -3197,7 +3199,7 @@
>  		if (cmdcnt-- > 1) {
>  			do_cmd(c);
>  		}				// repeat cnt
> -		dot = end_line(dot + 1);
> +		dot = end_line(dot);
>  		break;
>  	case '%':			// %- find matching char of pair () [] {}
>  		for (q = dot; q < end && *q != '\n'; q++) {

> _______________________________________________
> busybox mailing list
> busybox at mail.busybox.net
> http://busybox.net/mailman/listinfo/busybox

I just noticed that this patch, while fixing 'cw' and 'dw' for the last
word of a file makes busybox behave differently from the original vi for
'cw' and 'dw' on any other word not followed by a space.
Consider the following line:                       

example /bin/busybox

doing 'cw'/'dw' when the cursor is on 'bin' normally leaves the '/' out
but busybox with this patch eats the '/'.
substitutions for the other words of the line 'example' and 'busybox'
are fine with or without the patch.

I'm not sure what the fix would be yet but I prefer a small bug for the
last word of the file to a bug for all other words not followed by a space

Any thoughts?

-- 
Stéphane



More information about the busybox mailing list