about summary refs log tree commit diff
path: root/Src/Zle/compcore.c
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-17 11:59:32 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2000-05-17 11:59:32 +0000
commit05d3c175a5f9d1eb7bd8ed5f9c36ff5838ee6b8e (patch)
tree3efe3a37fc8b26b2dbafc2441558ebe9a525cf37 /Src/Zle/compcore.c
parentcd4b5eac3a2291f0a96493ae5cac666268638832 (diff)
downloadzsh-05d3c175a5f9d1eb7bd8ed5f9c36ff5838ee6b8e.tar.gz
zsh-05d3c175a5f9d1eb7bd8ed5f9c36ff5838ee6b8e.tar.xz
zsh-05d3c175a5f9d1eb7bd8ed5f9c36ff5838ee6b8e.zip
add Felix' completion matching test; some fixes for bugs shown by it (11439)
Diffstat (limited to 'Src/Zle/compcore.c')
-rw-r--r--Src/Zle/compcore.c90
1 files changed, 46 insertions, 44 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 60f73c635..1b16870d1 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1740,55 +1740,57 @@ addmatches(Cadata dat, char **argv)
 		    llpl -= gfl;
 		}
 	    }
-	    s = dat->ppre ? dat->ppre : dupstring("");
-	    if ((ml = match_str(lpre, s, &bpl, 0, NULL, 0, 0, 1)) >= 0) {
-		if (matchsubs) {
-		    Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, 0);
-
-		    tmp->prefix = matchsubs;
-		    if (matchlastpart)
-			matchlastpart->next = tmp;
+	    if ((s = dat->ppre)) {
+		if ((ml = match_str(lpre, s, &bpl, 0, NULL, 0, 0, 1)) >= 0) {
+		    if (matchsubs) {
+			Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, 0);
+
+			tmp->prefix = matchsubs;
+			if (matchlastpart)
+			    matchlastpart->next = tmp;
+			else
+			    matchparts = tmp;
+		    }
+		    pline = matchparts;
+		    lpre += ml;
+		    llpl -= ml;
+		    bcp = ml;
+		    bpadd = strlen(s) - ml;
+		} else {
+		    if (llpl <= lpl && strpfx(lpre, s))
+			lpre = dupstring("");
+		    else if (llpl > lpl && strpfx(s, lpre))
+			lpre += lpl;
 		    else
-			matchparts = tmp;
+			*argv = NULL;
+		    bcp = lpl;
 		}
-		pline = matchparts;
-		lpre += ml;
-		llpl -= ml;
-		bcp = ml;
-		bpadd = strlen(s) - ml;
-	    } else {
-		if (llpl <= lpl && strpfx(lpre, s))
-		    lpre = dupstring("");
-		else if (llpl > lpl && strpfx(s, lpre))
-		    lpre += lpl;
-		else
-		    *argv = NULL;
-		bcp = lpl;
 	    }
-	    s = dat->psuf ? dat->psuf : dupstring("");
-	    if ((ml = match_str(lsuf, s, &bsl, 0, NULL, 1, 0, 1)) >= 0) {
-		if (matchsubs) {
-		    Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, CLF_SUF);
-
-		    tmp->suffix = matchsubs;
-		    if (matchlastpart)
-			matchlastpart->next = tmp;
+	    if ((s = dat->psuf)) {
+		if ((ml = match_str(lsuf, s, &bsl, 0, NULL, 1, 0, 1)) >= 0) {
+		    if (matchsubs) {
+			Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, CLF_SUF);
+
+			tmp->suffix = matchsubs;
+			if (matchlastpart)
+			    matchlastpart->next = tmp;
+			else
+			    matchparts = tmp;
+		    }
+		    sline = revert_cline(matchparts);
+		    lsuf[llsl - ml] = '\0';
+		    llsl -= ml;
+		    bcs = ml;
+		    bsadd = strlen(s) - ml;
+		} else {
+		    if (llsl <= lsl && strsfx(lsuf, s))
+			lsuf = dupstring("");
+		    else if (llsl > lsl && strsfx(s, lsuf))
+			lsuf[llsl - lsl] = '\0';
 		    else
-			matchparts = tmp;
+			*argv = NULL;
+		    bcs = lsl;
 		}
-		sline = revert_cline(matchparts);
-		lsuf[llsl - ml] = '\0';
-		llsl -= ml;
-		bcs = ml;
-		bsadd = strlen(s) - ml;
-	    } else {
-		if (llsl <= lsl && strsfx(lsuf, s))
-		    lsuf = dupstring("");
-		else if (llsl > lsl && strsfx(s, lsuf))
-		    lsuf[llsl - lsl] = '\0';
-		else
-		    *argv = NULL;
-		bcs = lsl;
 	    }
 	    if (comppatmatch && *comppatmatch) {
 		int is = (*comppatmatch == '*');