* Another <ffffffff>
@ 2016-04-04 11:35 Daniel Shahaf
2016-04-04 11:49 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Shahaf @ 2016-04-04 11:35 UTC (permalink / raw)
To: zsh-workers
In 'zsh -f', typing
<C-r><C-space>
at the prompt gives me "<ffffffff> " with the <...> part in reverse video.
IF I try to use that as an argument, it gets interpreted as a question mark:
% cd $(mktemp -d)
% touch a aa aaa
% echo ./<C-r><C-space>
./a
%
That <ffffffff> was last seen in the multibyte thread in 36510 + 36521.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Another <ffffffff>
2016-04-04 11:35 Another <ffffffff> Daniel Shahaf
@ 2016-04-04 11:49 ` Peter Stephenson
2016-04-04 12:56 ` Peter Stephenson
2016-04-04 12:58 ` Peter Stephenson
0 siblings, 2 replies; 5+ messages in thread
From: Peter Stephenson @ 2016-04-04 11:49 UTC (permalink / raw)
To: zsh-workers
On Mon, 4 Apr 2016 11:35:24 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> In 'zsh -f', typing
>
> <C-r><C-space>
>
> at the prompt gives me "<ffffffff> " with the <...> part in reverse video.
Presumably what it should do is exit reverse search and execute
set-mark-command.
I think the problem is probably that the <C-space> isn't being saved for
re-evaluation properly when search is exited.
pws
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Another <ffffffff>
2016-04-04 11:49 ` Peter Stephenson
@ 2016-04-04 12:56 ` Peter Stephenson
2016-04-04 12:58 ` Peter Stephenson
1 sibling, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2016-04-04 12:56 UTC (permalink / raw)
To: zsh-workers
On Mon, 4 Apr 2016 12:49:45 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> On Mon, 4 Apr 2016 11:35:24 +0000
> Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > In 'zsh -f', typing
> >
> > <C-r><C-space>
> >
> > at the prompt gives me "<ffffffff> " with the <...> part in reverse video.
>
> Presumably what it should do is exit reverse search and execute
> set-mark-command.
>
> I think the problem is probably that the <C-space> isn't being saved for
> re-evaluation properly when search is exited.
This looks like it fixes this. The new function can also be used to
simplify a bit of memory management elsewhere. The ungetkeycmd() call
is the crucial one.
As far as I can see the remaining two cases that don't unmetafy are
correct: the other case in zle_hist.c is for a key string, which isn't
metafied (it claims), and vichgbuf appears to be a raw byte string
(although the comment above "examination of the code suggests..." which
I added myself isn't a great confidence booster).
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 382eb8d..bf38085 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1615,8 +1615,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
else
lastchar = lastc;
if(lastlen != keybuflen) {
- unmetafy(keybuf + lastlen, &keybuflen);
- ungetbytes(keybuf+lastlen, keybuflen);
+ ungetbytes_unmeta(keybuf+lastlen, keybuflen);
if(vichgflag)
vichgbufptr -= keybuflen;
keybuf[lastlen] = 0;
@@ -1672,7 +1671,7 @@ getkeybuf(int w)
mod_export void
ungetkeycmd(void)
{
- ungetbytes(keybuf, keybuflen);
+ ungetbytes_unmeta(keybuf, keybuflen);
}
/* read a command from the current keymap, with widgets */
@@ -1698,9 +1697,7 @@ getkeycmd(void)
hops = 0;
return NULL;
}
- pb = unmetafy(ztrdup(str), &len);
- ungetbytes(pb, len);
- zfree(pb, strlen(str) + 1);
+ ungetbytes_unmeta(str, len);
goto sentstring;
}
if (func == Th(z_executenamedcmd) && !statusline) {
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 104e5d6..472e326 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -357,6 +357,21 @@ ungetbytes(char *s, int len)
ungetbyte(*--s);
}
+/**/
+void
+ungetbytes_unmeta(char *s, int len)
+{
+ s += len;
+ while (len--) {
+ if (len && s[-2] == Meta) {
+ ungetbyte(*--s ^ 32);
+ len--;
+ s--;
+ } else
+ ungetbyte(*--s);
+ }
+}
+
#if defined(pyr) && defined(HAVE_SELECT)
static int
breakread(int fd, char *buf, int n)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Another <ffffffff>
2016-04-04 11:49 ` Peter Stephenson
2016-04-04 12:56 ` Peter Stephenson
@ 2016-04-04 12:58 ` Peter Stephenson
2016-04-04 13:51 ` Peter Stephenson
1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2016-04-04 12:58 UTC (permalink / raw)
To: zsh-workers
Sorry, try this one instead...
pws
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 382eb8d..7734ddc 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1615,8 +1615,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
else
lastchar = lastc;
if(lastlen != keybuflen) {
- unmetafy(keybuf + lastlen, &keybuflen);
- ungetbytes(keybuf+lastlen, keybuflen);
+ ungetbytes_unmeta(keybuf+lastlen, keybuflen);
if(vichgflag)
vichgbufptr -= keybuflen;
keybuf[lastlen] = 0;
@@ -1672,7 +1671,7 @@ getkeybuf(int w)
mod_export void
ungetkeycmd(void)
{
- ungetbytes(keybuf, keybuflen);
+ ungetbytes_unmeta(keybuf, keybuflen);
}
/* read a command from the current keymap, with widgets */
@@ -1690,17 +1689,12 @@ getkeycmd(void)
if(!*seq)
return NULL;
if(!func) {
- int len;
- char *pb;
-
if (++hops == 20) {
zerr("string inserting another one too many times");
hops = 0;
return NULL;
}
- pb = unmetafy(ztrdup(str), &len);
- ungetbytes(pb, len);
- zfree(pb, strlen(str) + 1);
+ ungetbytes_unmeta(str, strlen(str));
goto sentstring;
}
if (func == Th(z_executenamedcmd) && !statusline) {
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 104e5d6..472e326 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -357,6 +357,21 @@ ungetbytes(char *s, int len)
ungetbyte(*--s);
}
+/**/
+void
+ungetbytes_unmeta(char *s, int len)
+{
+ s += len;
+ while (len--) {
+ if (len && s[-2] == Meta) {
+ ungetbyte(*--s ^ 32);
+ len--;
+ s--;
+ } else
+ ungetbyte(*--s);
+ }
+}
+
#if defined(pyr) && defined(HAVE_SELECT)
static int
breakread(int fd, char *buf, int n)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Another <ffffffff>
2016-04-04 12:58 ` Peter Stephenson
@ 2016-04-04 13:51 ` Peter Stephenson
0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2016-04-04 13:51 UTC (permalink / raw)
To: zsh-workers
On Mon, 4 Apr 2016 13:58:26 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> --- a/Src/Zle/zle_keymap.c
> +++ b/Src/Zle/zle_keymap.c
> @@ -1615,8 +1615,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
> else
> lastchar = lastc;
> if(lastlen != keybuflen) {
> - unmetafy(keybuf + lastlen, &keybuflen);
> - ungetbytes(keybuf+lastlen, keybuflen);
> + ungetbytes_unmeta(keybuf+lastlen, keybuflen);
> if(vichgflag)
> vichgbufptr -= keybuflen;
> keybuf[lastlen] = 0;
Sorry, another problem --- this one is wrong because we actually do need
the keybuf unmetafied subsequently. So this stays as it was. This was
causing test X02zlevi to fail.
pws
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-04-04 14:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-04 11:35 Another <ffffffff> Daniel Shahaf
2016-04-04 11:49 ` Peter Stephenson
2016-04-04 12:56 ` Peter Stephenson
2016-04-04 12:58 ` Peter Stephenson
2016-04-04 13:51 ` Peter Stephenson
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).