From 6bca0ecb48e06d4a94d23ca6c700d5e7ff6e4261 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 2 Nov 2005 11:09:22 +0000 Subject: users/9610: handle digit argument when copying words --- Src/Zle/zle_misc.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'Src/Zle/zle_misc.c') 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; -- cgit 1.4.1