diff src/regexp_nfa.c @ 4553:7b835b2969af v7.3.1024

updated for version 7.3.1024 Problem: New regexp: End of matching pattern not set correctly. (Cesar Romani) Solution: Quit the loop after finding the match. Store nfa_has_zend in the program.
author Bram Moolenaar <bram@vim.org>
date Sun, 26 May 2013 16:57:28 +0200
parents f0c37f5cf4ea
children b2946c06d1b6
line wrap: on
line diff
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -2651,7 +2651,7 @@ addstate(l, state, m, off, lid, match)
 	    break;
 
 	case NFA_MCLOSE + 0:
-	    if (nfa_has_zend == TRUE)
+	    if (nfa_has_zend)
 	    {
 		addstate(l, state->out, m, off, lid, match);
 		break;
@@ -3109,7 +3109,11 @@ nfa_regmatch(start, submatch, m)
 		fprintf(log_fd, "\n");
 #endif
 		/* Found the left-most longest match, do not look at any other
-		 * states at this position. */
+		 * states at this position.  When the list of states is going
+		 * to be empty quit without advancing, so that "reginput" is
+		 * correct. */
+		if (nextlist->n == 0 && neglist->n == 0)
+		    clen = 0;
 		goto nextchar;
 
 	    case NFA_END_INVISIBLE:
@@ -3783,8 +3787,9 @@ nfa_regexec_both(line, col)
     regline = line;
     reglnum = 0;    /* relative to line */
 
+    nfa_has_zend = prog->has_zend;
+
     nstate = prog->nstate;
-
     for (i = 0; i < nstate; ++i)
     {
 	prog->state[i].id = i;
@@ -3871,6 +3876,7 @@ nfa_regcomp(expr, re_flags)
     prog->regflags = regflags;
     prog->engine = &nfa_regengine;
     prog->nstate = nstate;
+    prog->has_zend = nfa_has_zend;
 #ifdef ENABLE_LOG
     nfa_postfix_dump(expr, OK);
     nfa_dump(prog);