about summary refs log tree commit diff
path: root/Src/Zle/zle_tricky.c
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-08 10:26:20 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-08 10:26:20 +0000
commitf9a6f521d6475360bee03808ced1f301983bb700 (patch)
tree6e01b5b9e8b01ca160c211e88a6a451967f39e5d /Src/Zle/zle_tricky.c
parent623351671b7437dee08763bbdf9d2e8e6505e347 (diff)
downloadzsh-f9a6f521d6475360bee03808ced1f301983bb700.tar.gz
zsh-f9a6f521d6475360bee03808ced1f301983bb700.tar.xz
zsh-f9a6f521d6475360bee03808ced1f301983bb700.zip
zsh-workers/8588
Diffstat (limited to 'Src/Zle/zle_tricky.c')
-rw-r--r--Src/Zle/zle_tricky.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 6a17c46d0..04b841411 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -112,7 +112,7 @@ static char *qword;
  * closing quote. */
 
 /**/
-char *qipre, *qisuf, autoq;
+char *qipre, *qisuf, *autoq;
 
 /* This contains the name of the function to call if this is for a new  *
  * style completion. */
@@ -547,7 +547,8 @@ docomplete(int lst)
     qipre = ztrdup("");
     zsfree(qisuf);
     qisuf = ztrdup("");
-    autoq = '\0';
+    zsfree(autoq);
+    autoq = NULL;
     /* Get the word to complete. */
     noerrs = 1;
     s = get_comp_string();
@@ -882,6 +883,20 @@ dupbrinfo(Brinfo p, Brinfo *last)
     return ret;
 }
 
+/* This is a bit like has_token(), but ignores nulls. */
+
+static int
+has_real_token(const char *s)
+{
+    while (*s) {
+	if (itok(*s) && !INULL(*s))
+	    return 1;
+	s++;
+    }
+    return 0;
+}
+
+
 /* Lasciate ogni speranza.                                                  *
  * This function is a nightmare.  It works, but I'm sure that nobody really *
  * understands why.  The problem is: to make it cleaner we would need       *
@@ -1264,7 +1279,7 @@ get_comp_string(void)
 		else if (*p == Snull)
 		    *p = '\'';
 	}
-	if ((*s == Snull || *s == Dnull) && !has_token(s + 1)) {
+	if ((*s == Snull || *s == Dnull) && !has_real_token(s + 1)) {
 	    char *q = (*s == Snull ? "'" : "\""), *n = tricat(qipre, q, "");
 	    int sl = strlen(s);
 
@@ -1276,7 +1291,7 @@ get_comp_string(void)
 		zsfree(qisuf);
 		qisuf = n;
 	    }
-	    autoq = *q;
+	    autoq = ztrdup(q);
 	}
 	/* While building the quoted form, we also clean up the command line. */
 	for (p = s, tt = qword, i = wb; *p; p++, tt++, i++)