diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2005-11-02 11:09:22 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2005-11-02 11:09:22 +0000 |
commit | 6bca0ecb48e06d4a94d23ca6c700d5e7ff6e4261 (patch) | |
tree | fc1716a4dc09074f7aa37f1a1d500e10f3fe929f | |
parent | 29b0eda154f56d183e28dccea9b7d51946685165 (diff) | |
download | zsh-6bca0ecb48e06d4a94d23ca6c700d5e7ff6e4261.tar.gz zsh-6bca0ecb48e06d4a94d23ca6c700d5e7ff6e4261.tar.xz zsh-6bca0ecb48e06d4a94d23ca6c700d5e7ff6e4261.zip |
users/9610: handle digit argument when copying words
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/Zle/zle_misc.c | 40 |
2 files changed, 32 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog index 7d215a1e6..33a0cac28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-11-02 Peter Stephenson <pws@csr.com> + * users/9610: Src/Zle/zle_misc.c: Handle digit argument + in copy-prev-word and copy-prev-shell-word. + * 21973: Src/Zle/zle_misc.c: idigit() test in digitargument() had reversed sense. diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c index 2557fb0ed..8605c4624 100644 --- a/Src/Zle/zle_misc.c +++ b/Src/Zle/zle_misc.c @@ -616,17 +616,28 @@ universalargument(char **args) int copyprevword(UNUSED(char **args)) { - int len, t0; + int len, t0 = zlecs, t1; - for (t0 = zlecs - 1; t0 >= 0; t0--) - if (ZC_iword(zleline[t0])) - break; - for (; t0 >= 0; t0--) - if (!ZC_iword(zleline[t0])) - break; - if (t0) - t0++; - len = zlecs - t0; + if (zmult > 0) { + int count = zmult; + + for (;;) { + t1 = t0; + + while (t0 && !ZC_iword(zleline[t0-1])) + t0--; + while (t0 && ZC_iword(zleline[t0-1])) + t0--; + + if (!--count) + break; + if (t0 == 0) + return 1; + } + } + else + return 1; + len = t1 - t0; spaceinline(len); ZS_memcpy(zleline + zlecs, zleline + t0, len); zlecs += len; @@ -642,12 +653,19 @@ copyprevshellword(UNUSED(char **args)) int i; unsigned char *p = NULL; - if ((l = bufferwords(NULL, NULL, &i))) + if (zmult <= 0) + return 1; + + if ((l = bufferwords(NULL, NULL, &i))) { + i -= (zmult-1); + if (i < 0) + return 1; for (n = firstnode(l); n; incnode(n)) if (!i--) { p = (unsigned char *)getdata(n); break; } + } if (p) { int len; |