zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: Bug in ZSH's vi emulation
Date: Thu, 03 Nov 2016 09:36:05 +0000	[thread overview]
Message-ID: <20161103093605.06e92c45@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <161102211243.ZM16026@torch.brasslantern.com>

On Wed, 02 Nov 2016 21:12:43 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Nov 2,  5:51pm, Oliver Kiddle wrote:
> }
> } We've also got a separate issue of only lastchar being stuffed into
> } vichgbuf so repeating, e.g. gU doesn't work. Why is keybuflen only
> } 1 in startvichange? That, along with what the general point of lastchar
> } is, has me fairly puzzled.
> 
> It's because of getkeymapcmd():
> 
>     if(lastlen != keybuflen) {
> 	unmetafy(keybuf + lastlen, &keybuflen);		<-- here
> 	ungetbytes(keybuf+lastlen, keybuflen);
> 	if(vichgflag)
> 	    vichgbufptr -= keybuflen;
> 	keybuf[lastlen] = 0;
>     }
> 
> Seems like it ought to do the following?  Or else use a temporary instead
> of stomping on keybuflen.
> 
> diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
> index 3db4207..b5244b5 100644
> --- a/Src/Zle/zle_keymap.c
> +++ b/Src/Zle/zle_keymap.c
> @@ -1622,7 +1622,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
>  	ungetbytes(keybuf+lastlen, keybuflen);
>  	if(vichgflag)
>  	    vichgbufptr -= keybuflen;
> -	keybuf[lastlen] = 0;
> +	keybuf[keybuflen = lastlen] = 0;
>      }
>      *funcp = func;
>      *strp = str;
> 

Yes, I stared at this for a while but I think the intention is to take
the (keybuflen-lastlen) null-terminated characters off the end and make
them available for re-reading as input, leaving only the first lastlen
in the key buffer.

That means keybuflen needs updating at the end anyway, to get rid of
those characters from the key buffer, so use of a temporary is
immaterial.

Comments when this was originally written probably wouldn't have hurt.

pws


  reply	other threads:[~2016-11-03  9:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05  8:09 Ghjuvan' Lacambre
2016-10-05 17:19 ` Bart Schaefer
2016-11-02  4:59   ` Daniel Shahaf
2016-11-02 16:51     ` Oliver Kiddle
2016-11-02 17:34       ` Peter Stephenson
2016-11-02 18:46       ` Bart Schaefer
2016-11-02 23:19       ` Bart Schaefer
2016-11-03  1:54         ` Daniel Shahaf
2016-11-03  4:12       ` Bart Schaefer
2016-11-03  9:36         ` Peter Stephenson [this message]
2016-11-03  4:44       ` Bart Schaefer
2016-11-03 12:43         ` Oliver Kiddle
2016-11-03 13:08           ` Bart Schaefer
2016-11-03 14:55           ` Bart Schaefer
2016-11-03 14:57             ` Bart Schaefer
2016-11-03 16:06           ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161103093605.06e92c45@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).