about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-12-16 08:45:35 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-12-16 08:45:35 +0000
commit6296ccf4c4eddaff4abf8cb25869d8e7c9dc228f (patch)
tree534e30b0ec442c6f357961bb2bf333be348a8c16
parentd253252358add8c8cf5d8447ea6eed08da69b18d (diff)
downloadzsh-6296ccf4c4eddaff4abf8cb25869d8e7c9dc228f.tar.gz
zsh-6296ccf4c4eddaff4abf8cb25869d8e7c9dc228f.tar.xz
zsh-6296ccf4c4eddaff4abf8cb25869d8e7c9dc228f.zip
zsh-workers/9076
-rw-r--r--Src/Zle/compcore.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 8356ad5a5..457493150 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -1662,8 +1662,26 @@ addmatches(Cadata dat, char **argv)
 	    } else
 		lsl = 0;
 	    if (dat->aflags & CAF_MATCH) {
-		int ml;
+		int ml, gfl = 0;
+		char *globflag = NULL;
 
+		if (comppatmatch && *comppatmatch &&
+		    dat->ppre && lpre[0] == '(' && lpre[1] == '#') {
+		    char *p;
+
+		    for (p = lpre + 2; *p && *p != ')'; p++);
+
+		    if (*p == ')') {
+			char sav = p[1];
+
+			p[1] = '\0';
+			globflag = dupstring(lpre);
+			gfl = p - lpre + 1;
+			p[1] = sav;
+
+			lpre = p + 1;
+		    }
+		}
 		s = dat->ppre ? dat->ppre : "";
 		if ((ml = match_str(lpre, s, &bpl, 0, NULL, 0, 0, 1)) >= 0) {
 		    if (matchsubs) {
@@ -1688,11 +1706,11 @@ addmatches(Cadata dat, char **argv)
 			*argv = NULL;
 		    bcp = lpl;
 		}
-
 		s = dat->psuf ? 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);
+			Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0,
+					      CLF_SUF);
 
 			tmp->suffix = matchsubs;
 			if (matchlastpart)
@@ -1715,17 +1733,21 @@ addmatches(Cadata dat, char **argv)
 		}
 		if (comppatmatch && *comppatmatch) {
 		    int is = (*comppatmatch == '*');
-		    char *tmp = (char *) zhalloc(2 + llpl + llsl);
+		    char *tmp = (char *) zhalloc(2 + llpl + llsl + gfl);
 
-		    strcpy(tmp, lpre);
-		    tmp[llpl] = 'x';
-		    strcpy(tmp + llpl + is, lsuf);
+		    if (gfl) {
+			strcpy(tmp, globflag);
+			strcat(tmp, lpre);
+		    } else
+			strcpy(tmp, lpre);
+		    tmp[llpl + gfl] = 'x';
+		    strcpy(tmp + llpl + gfl + is, lsuf);
 
 		    tokenize(tmp);
 		    remnulargs(tmp);
 		    if (haswilds(tmp)) {
 			if (is)
-			    tmp[llpl] = Star;
+			    tmp[llpl + gfl] = Star;
 			if ((cp = patcompile(tmp, 0, NULL)))
 			    haspattern = 1;
 		    }