about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2002-01-31 15:13:26 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2002-01-31 15:13:26 +0000
commit16f1f616f9778cdf79f554d7107f0c3cf2c08654 (patch)
tree1268157d8e01753d3337614f9c785b68732ed626 /Src
parent149aafd65ee260f6071aeacbe07fa99df21ecce3 (diff)
downloadzsh-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.c53
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++=' ';
+			    }
 			}
 		    }
 		}