diff src/regexp_nfa.c @ 4525:36ddcf4cecbc v7.3.1010

updated for version 7.3.1010 Problem: New regexp: adding \Z makes every character match. Solution: Only apply ireg_icombine for composing characters. Alsl add missing change from patch 1008. (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Fri, 24 May 2013 20:25:33 +0200
parents 9a2183bd8295
children 55bcaa1d2749
line wrap: on
line diff
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -2859,7 +2859,7 @@ nfa_regmatch(start, submatch, m)
     List	*listtbl[2][2];
     List	*ll;
     int		listid = 1;
-    int		endnode = 0;
+    int		endnode;
     List	*thislist;
     List	*nextlist;
     List	*neglist;
@@ -3192,13 +3192,7 @@ nfa_regmatch(start, submatch, m)
 
 	    case NFA_MULTIBYTE:
 	    case NFA_COMPOSING:
-		switch (t->state->c)
-		{
-		    case NFA_MULTIBYTE:	    endnode = NFA_END_MULTIBYTE; break;
-		    case NFA_COMPOSING:	    endnode = NFA_END_COMPOSING; break;
-		    default:		    endnode = 0;
-		}
-
+	        endnode = t->state->c + 1;
 		result = OK;
 		sta = t->state->out;
 		len = 1;
@@ -3206,7 +3200,7 @@ nfa_regmatch(start, submatch, m)
 		{
 		    if (reginput[len-1] != sta->c)
 		    {
-			result = OK - 1;
+			result = FAIL;
 			break;
 		    }
 		    len++;
@@ -3215,11 +3209,11 @@ nfa_regmatch(start, submatch, m)
 
 		/* if input char length doesn't match regexp char length */
 		if (len -1 < n || sta->c != endnode)
-		    result = OK - 1;
+		    result = FAIL;
 		end = t->state->out1;	    /* NFA_END_MULTIBYTE or
 					       NFA_END_COMPOSING */
 		/* If \Z was present, then ignore composing characters */
-		if (regflags & RF_ICOMBINE)
+		if (ireg_icombine && endnode == NFA_END_COMPOSING)
 		    result = 1 ^ sta->negated;
 		ADD_POS_NEG_STATE(end);
 		break;