about summary refs log tree commit diff
path: root/Src/Zle/compmatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle/compmatch.c')
-rw-r--r--Src/Zle/compmatch.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index c4523ae47..b59f5a2e1 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -1818,10 +1818,12 @@ bld_line(Cmatcher mp, ZLE_STRING_T line, char *mword, char *word,
 
 	if (sfx) {
 	    wp = wordcp - 1;
-	    curgenpat--;
-	} else
+	    tmpgenpat = curgenpat - 1;
+	} else {
+	    tmpgenpat = curgenpat;
 	    wp = wordcp;
-	if (pattern_match1(curgenpat, *wp, &wmtp))
+	}
+	if (pattern_match1(tmpgenpat, *wp, &wmtp))
 	{
 	    convchar_t lchr;
 	    /*
@@ -1831,8 +1833,8 @@ bld_line(Cmatcher mp, ZLE_STRING_T line, char *mword, char *word,
 	     * else if it's generic, keep the word character,
 	     * since we have no choice.
 	     */
-	    if (curgenpat->tp == CPAT_CHAR)
-		lchr = curgenpat->u.chr;
+	    if (tmpgenpat->tp == CPAT_CHAR)
+		lchr = tmpgenpat->u.chr;
 	    else
 		lchr = *wp;
 
@@ -1845,9 +1847,10 @@ bld_line(Cmatcher mp, ZLE_STRING_T line, char *mword, char *word,
 	    wlen--;
 	    rl++;
 
-	    if (sfx)
+	    if (sfx) {
 		wordcp = wp;
-	    else {
+		curgenpat = tmpgenpat;
+	    } else {
 		if (llen)
 		    curgenpat++;
 		wordcp++;