about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-09 09:01:23 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-09 09:01:23 +0000
commit95af0ef9c4639763c8094d6e8cd5d8ec01a32f96 (patch)
tree7c31df1ba19e54c20fe165527a89b2f7f640b8b4
parent126c1f2b4da9ab76b6c6ec3980e6922fb1f19ab4 (diff)
downloadzsh-95af0ef9c4639763c8094d6e8cd5d8ec01a32f96.tar.gz
zsh-95af0ef9c4639763c8094d6e8cd5d8ec01a32f96.tar.xz
zsh-95af0ef9c4639763c8094d6e8cd5d8ec01a32f96.zip
zsh-workers/8599
-rw-r--r--Src/Zle/compcore.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 3ea884f53..c3de9c564 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -923,34 +923,40 @@ makecomplist(char *s, int incmd, int lst)
 char *
 multiquote(char *s, int ign)
 {
-    char *os = s, *p = compqstack;
-
-    if (p && *p && (ign < 1 || p[ign])) {
-	if (ign > 0)
-	    p += ign;
-	while (*p) {
-	    if (ign >= 0 || p[1])
-		s = bslashquote(s, NULL,
-				(*p == '\'' ? 1 : (*p == '"' ? 2 : 0)));
-	    p++;
+    if (s) {
+	char *os = s, *p = compqstack;
+
+	if (p && *p && (ign < 1 || p[ign])) {
+	    if (ign > 0)
+		p += ign;
+	    while (*p) {
+		if (ign >= 0 || p[1])
+		    s = bslashquote(s, NULL,
+				    (*p == '\'' ? 1 : (*p == '"' ? 2 : 0)));
+		p++;
+	    }
 	}
+	return (s == os ? dupstring(s) : s);
     }
-    return (s == os ? dupstring(s) : s);
+    return NULL;
 }
 
 /**/
 char *
 tildequote(char *s, int ign)
 {
-    int tilde;
+    if (s) {
+	int tilde;
 
-    if ((tilde = (*s == '~')))
-	*s = 'x';
-    s = multiquote(s, ign);
-    if (tilde)
-	*s = '~';
+	if ((tilde = (*s == '~')))
+	    *s = 'x';
+	s = multiquote(s, ign);
+	if (tilde)
+	    *s = '~';
 
-    return s;
+	return s;
+    }
+    return NULL;
 }
 
 /* Check if we have to complete a parameter name. */
@@ -1708,10 +1714,12 @@ addmatches(Cadata dat, char **argv)
 		} else if (dat->rems)
 		    dat->rems = dupstring(dat->rems);
 
-		lpre = ((!(dat->aflags & CAF_QUOTE) &&
-			 (!dat->ppre && (dat->flags & CMF_FILE))) ?
-			tildequote(lpre, 1) : multiquote(lpre, 1));
-		lsuf = multiquote(lsuf, 1);
+		if (lpre)
+		    lpre = ((!(dat->aflags & CAF_QUOTE) &&
+			     (!dat->ppre && (dat->flags & CMF_FILE))) ?
+			    tildequote(lpre, 1) : multiquote(lpre, 1));
+		if (lsuf)
+		    lsuf = multiquote(lsuf, 1);
 	    }
 	    /* Walk through the matches given. */
 	    obpl = bpl;