summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2015-07-25 21:36:54 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2015-07-25 21:36:54 +0100
commitdd8079e0415cf213d9bb5d41d1ad95c04b774f3a (patch)
tree8b5e346d5b1121b49caf5724ca936ab9e5fe4d9e /Src/utils.c
parent771381c2ce0587d825528d49244006edf770fd47 (diff)
downloadzsh-dd8079e0415cf213d9bb5d41d1ad95c04b774f3a.tar.gz
zsh-dd8079e0415cf213d9bb5d41d1ad95c04b774f3a.tar.xz
zsh-dd8079e0415cf213d9bb5d41d1ad95c04b774f3a.zip
35809: fix $((...)) completion by _expand widget.
This changes internal quoting of the form still including tokens
not to add unnecessary internal backslashes.
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 0acab88ff..f7aaaedf4 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5551,7 +5551,25 @@ quotestring(const char *s, char **e, int instring)
 		/* Needs to be passed straight through. */
 		if (dobackslash)
 		    *v++ = '\\';
-		*v++ = *u++;
+		if (*u == Inparmath) {
+		    /*
+		     * Already syntactically quoted: don't
+		     * add more.
+		     */
+		    int inmath = 1;
+		    *v++ = *u++;
+		    for (;;) {
+			char uc = *u;
+			*v++ = *u++;
+			if (uc == '\0')
+			    break;
+			else if (uc == Outparmath && !--inmath)
+			    break;
+			else if (uc == Inparmath)
+			    ++inmath;
+		    }
+		} else
+		    *v++ = *u++;
 		continue;
 	    }