diff options
author | Peter Stephenson <pws@zsh.org> | 2016-04-04 14:54:54 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2016-04-04 14:54:54 +0100 |
commit | 2b7035d974a69d9a47b1f89f868787a4585386a1 (patch) | |
tree | 419fb9c926df47a44888ae642866f11764610c84 /Src | |
parent | caff72941d86983b44103653895328b411b29b4e (diff) | |
download | zsh-2b7035d974a69d9a47b1f89f868787a4585386a1.tar.gz zsh-2b7035d974a69d9a47b1f89f868787a4585386a1.tar.xz zsh-2b7035d974a69d9a47b1f89f868787a4585386a1.zip |
38241: ungetkeycmd() needs to unmetafy key string.
Use the new function to simplify memory management in prefix handling. Third time lucky.
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/zle_keymap.c | 9 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 15 |
2 files changed, 17 insertions, 7 deletions
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index 382eb8d41..13fd13844 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -1672,7 +1672,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 +1690,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 104e5d6c5..472e326d1 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) |