diff options
author | Oliver Kiddle <opk@users.sourceforge.net> | 2002-01-31 15:13:26 +0000 |
---|---|---|
committer | Oliver Kiddle <opk@users.sourceforge.net> | 2002-01-31 15:13:26 +0000 |
commit | 16f1f616f9778cdf79f554d7107f0c3cf2c08654 (patch) | |
tree | 1268157d8e01753d3337614f9c785b68732ed626 /Src | |
parent | 149aafd65ee260f6071aeacbe07fa99df21ecce3 (diff) | |
download | zsh-16f1f616f9778cdf79f554d7107f0c3cf2c08654.tar.gz zsh-16f1f616f9778cdf79f554d7107f0c3cf2c08654.tar.xz zsh-16f1f616f9778cdf79f554d7107f0c3cf2c08654.zip |
16494: extract outermost words with negative arguments to %_ and add %^
Diffstat (limited to 'Src')
-rw-r--r-- | Src/prompt.c | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/Src/prompt.c b/Src/prompt.c index 9b6edfcc6..06dd2e5a9 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -574,15 +574,54 @@ putpromptchar(int doprint, int endchar) case 'E': tsetcap(TCCLEAREOL, 1); break; + case '^': + if (cmdsp) { + if (arg >= 0) { + if (arg > cmdsp || arg == 0) + arg = cmdsp; + for (t0 = cmdsp - 1; arg--; t0--) { + stradd(cmdnames[cmdstack[t0]]); + if (arg) { + addbufspc(1); + *bp++=' '; + } + } + } else { + arg = -arg; + if (arg > cmdsp) + arg = cmdsp; + for (t0 = arg - 1; arg--; t0--) { + stradd(cmdnames[cmdstack[t0]]); + if (arg) { + addbufspc(1); + *bp++=' '; + } + } + } + } + break; case '_': if (cmdsp) { - if (arg > cmdsp || arg <= 0) - arg = cmdsp; - for (t0 = cmdsp - arg; arg--; t0++) { - stradd(cmdnames[cmdstack[t0]]); - if (arg) { - addbufspc(1); - *bp++=' '; + if (arg >= 0) { + if (arg > cmdsp || arg == 0) + arg = cmdsp; + for (t0 = cmdsp - arg; arg--; t0++) { + stradd(cmdnames[cmdstack[t0]]); + if (arg) { + addbufspc(1); + *bp++=' '; + } + } + } else { + arg = -arg; + if (arg > cmdsp) + arg = cmdsp; + for (t0 = 0; arg--; t0++) { + stradd(cmdnames[cmdstack[t0]]); + if (arg) { + addbufspc(1); + *bp++=' '; + } } } } |