[BusyBox] VI

Richard Kojedzinszky krichy at tvnetwork.hu
Sat Jan 31 19:26:40 UTC 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I've noticed the bug also, and here is another patch for it. I hope it'll
not introduce more bugs. Not too nice, but works for me.

Here it is for busybox-1.00-pre6

- --- busybox-1.00-pre6/editors/vi.c	Wed Jan 21 11:59:45 2004
+++ busybox-1.00-pre6-p/editors/vi.c	Sat Jan 31 09:54:26 2004
@@ -1669,10 +1669,13 @@
 		q = dot;
 	} else if (strchr("wW", c)) {
 		do_cmd(c);		// execute movement cmd
- -		// 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 we are at the next word's first char
+ 		// step back one char
+ 		// but check the possibilities when it is true
+ 		if (dot > text && ((isspace(dot[0]) && !isspace(dot[0]))
+ 				|| (ispunct(dot[-1]) && !ispunct(dot[0]))
+ 				|| (isalnum(dot[-1]) && !isalnum(dot[0]))))
+  			dot--;		// move back off of next word
 		if (dot > text && *dot == '\n')
 			dot--;		// stay off NL
 		q = dot;
- ---

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

On Sat, 31 Jan 2004, Stephane Billiart wrote:

> 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
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Made with pgp4pine 1.75-6

iD8DBQFAHAFzJw8MbyTnkUERAgcpAJ9fNXdE5W2KVYQBFmjByaTulq64XgCeNS6o
PW8nUh/Oc/EMQdPC58CUO9c=
=Kje/
-----END PGP SIGNATURE-----




More information about the busybox mailing list