about summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-01-27 23:52:13 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-01-27 23:52:13 +0000
commit2b948e6c375a540129883272f9c4e118ada8ab1e (patch)
treeba76260f60c76592dc76a88c84e025cabe8b8b62 /Src/utils.c
parentdf54eeed2ca4823d57c2bc74fc5def7b3b4a77ae (diff)
downloadzsh-2b948e6c375a540129883272f9c4e118ada8ab1e.tar.gz
zsh-2b948e6c375a540129883272f9c4e118ada8ab1e.tar.xz
zsh-2b948e6c375a540129883272f9c4e118ada8ab1e.zip
23138: further tweak to backslashes in $'...'
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/Src/utils.c b/Src/utils.c
index c0ccc6715..ce7b4caac 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4915,27 +4915,45 @@ getkeystring(char *s, int *len, int how, int *misc)
 	    *t++ = *++s ^ 32;
 	else {
 	    if (itok(*s)) {
+		/*
+		 * We need to be quite careful here.  We haven't
+		 * necessarily got an input stream with all tokens
+		 * removed, so the majority of tokens need passing
+		 * through untouched and without Meta handling.
+		 * However, me may need to handle tokenized
+		 * backslashes.
+		 */
 		if (meta || control) {
 		    /*
 		     * Presumably we should be using meta or control
 		     * on the character representing the token.
+		     *
+		     * Special case: $'\M-\\' where the token is a Bnull.
+		     * This time we dump the Bnull since we're
+		     * replacing the whole thing.  The lexer
+		     * doesn't know about the meta or control modifiers.
 		     */
-		    *t++ = ztokens[*s - Pound];
+		    if ((how & GETKEY_DOLLAR_QUOTE) && *s == Bnull)
+			*t++ = *++s;
+		    else
+			*t++ = ztokens[*s - Pound];
 		} else if (how & GETKEY_DOLLAR_QUOTE) {
+		    /*
+		     * We don't want to metafy this, it's a real
+		     * token.
+		     */
+		    *tdest++ = *s;
 		    if (*s == Bnull) {
 			/*
 			 * Bnull is a backslash which quotes a couple
 			 * of special characters that always appear
 			 * literally next.  See strquote handling
-			 * in gettokstr() in lex.c.
+			 * in gettokstr() in lex.c.  We need
+			 * to retain the Bnull (as above) so that quote
+			 * handling in completion can tell where the
+			 * backslash was.
 			 */
 			*tdest++ = *++s;
-		    } else {
-			/*
-			 * We don't want to metafy this, it's a real
-			 * token.
-			 */
-			*tdest++ = *s;
 		    }
 		    continue;
 		} else