changeset 4762:47906f888725 v7.3.1128

updated for version 7.3.1128 Problem: Now that the NFA engine handles everything every failure is a syntax error. Solution: Remove the syntax_error flag.
author Bram Moolenaar <bram@vim.org>
date Wed, 05 Jun 2013 21:42:53 +0200
parents 086272ff3a96
children 1b5ca3e53566
files src/regexp.c src/regexp_nfa.c src/version.c
diffstat 3 files changed, 6 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -7924,7 +7924,6 @@ vim_regcomp(expr_arg, re_flags)
     regprog_T   *prog = NULL;
     char_u	*expr = expr_arg;
 
-    syntax_error = FALSE;
     regexp_engine = p_re;
 
     /* Check for prefix "\%#=", that sets the regexp engine */
@@ -7971,19 +7970,12 @@ vim_regcomp(expr_arg, re_flags)
 	    f = fopen(BT_REGEXP_DEBUG_LOG_NAME, "a");
 	    if (f)
 	    {
-		if (!syntax_error)
-		    fprintf(f, "NFA engine could not handle \"%s\"\n", expr);
-		else
-		    fprintf(f, "Syntax error in \"%s\"\n", expr);
+		fprintf(f, "Syntax error in \"%s\"\n", expr);
 		fclose(f);
 	    }
 	    else
 		EMSG2("(NFA) Could not open \"%s\" to write !!!",
                         BT_REGEXP_DEBUG_LOG_NAME);
-	    /*
-	    if (syntax_error)
-		EMSG("NFA Regexp: Syntax Error !");
-	    */
 	}
 #endif
 	/*
@@ -7992,11 +7984,8 @@ vim_regcomp(expr_arg, re_flags)
 	 * NFA engine.
 	 */
 	if (regexp_engine == AUTOMATIC_ENGINE)
-	    if (!syntax_error)
-		prog = bt_regengine.regcomp(expr, re_flags);
-
-    }	    /* endif prog==NULL */
-
+	    prog = bt_regengine.regcomp(expr, re_flags);
+    }
 
     return prog;
 }
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -221,23 +221,6 @@ static int nfa_classcodes[] = {
 
 static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
 
-/*
- * NFA errors can be of 3 types:
- * *** NFA runtime errors, when something unknown goes wrong. The NFA fails
- *     silently and revert the to backtracking engine.
- *     syntax_error = FALSE;
- * *** Regexp syntax errors, when the input regexp is not syntactically correct.
- *     The NFA engine displays an error message, and nothing else happens.
- *     syntax_error = TRUE
- * *** Unsupported features, when the input regexp uses an operator that is not
- *     implemented in the NFA. The NFA engine fails silently, and reverts to the
- *     old backtracking engine.
- *     syntax_error = FALSE
- * "The NFA fails" means that "compiling the regexp with the NFA fails":
- * nfa_regcomp() returns FAIL.
- */
-static int syntax_error = FALSE;
-
 /* NFA regexp \ze operator encountered. */
 static int nfa_has_zend;
 
@@ -692,7 +675,6 @@ nfa_regatom()
     switch (c)
     {
 	case NUL:
-	    syntax_error = TRUE;
 	    EMSG_RET_FAIL(_("E865: (NFA) Regexp end encountered prematurely"));
 
 	case Magic('^'):
@@ -814,7 +796,6 @@ nfa_regatom()
 	case Magic('|'):
 	case Magic('&'):
 	case Magic(')'):
-	    syntax_error = TRUE;
 	    EMSGN(_(e_misplaced), no_Magic(c));
 	    return FAIL;
 
@@ -825,7 +806,6 @@ nfa_regatom()
 	case Magic('*'):
 	case Magic('{'):
 	    /* these should follow an atom, not form an atom */
-	    syntax_error = TRUE;
 	    EMSGN(_(e_misplaced), no_Magic(c));
 	    return FAIL;
 
@@ -902,7 +882,6 @@ nfa_regatom()
 		    break;
 #endif
 		default:
-		    syntax_error = TRUE;
 		    EMSGN(_("E867: (NFA) Unknown operator '\\z%c'"),
 								 no_Magic(c));
 		    return FAIL;
@@ -1023,7 +1002,6 @@ nfa_regatom()
 			    break;
 			}
 		    }
-		    syntax_error = TRUE;
 		    EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"),
 								 no_Magic(c));
 		    return FAIL;
@@ -1359,10 +1337,7 @@ collection:
 	    } /* if exists closing ] */
 
 	    if (reg_strict)
-	    {
-		syntax_error = TRUE;
 		EMSG_RET_FAIL(_(e_missingbracket));
-	    }
 	    /* FALLTHROUGH */
 
 	default:
@@ -1512,7 +1487,6 @@ nfa_regpiece()
 	    }
 	    if (i == 0)
 	    {
-		syntax_error = TRUE;
 		EMSGN(_("E869: (NFA) Unknown operator '\\@%c'"), op);
 		return FAIL;
 	    }
@@ -1543,10 +1517,8 @@ nfa_regpiece()
 		greedy = FALSE;
 	    }
 	    if (!read_limits(&minval, &maxval))
-	    {
-		syntax_error = TRUE;
 		EMSG_RET_FAIL(_("E870: (NFA regexp) Error reading repetition limits"));
-	    }
+
 	    /*  <atom>{0,inf}, <atom>{0,} and <atom>{}  are equivalent to
 	     *  <atom>*  */
 	    if (minval == 0 && maxval == MAX_LIMIT)
@@ -1614,11 +1586,8 @@ nfa_regpiece()
     }	/* end switch */
 
     if (re_multi_type(peekchr()) != NOT_MULTI)
-    {
 	/* Can't have a multi follow a multi. */
-	syntax_error = TRUE;
 	EMSG_RET_FAIL(_("E871: (NFA regexp) Can't have a multi follow a multi !"));
-    }
 
     return OK;
 }
@@ -1767,10 +1736,7 @@ nfa_reg(paren)
     if (paren == REG_PAREN)
     {
 	if (regnpar >= NSUBEXP) /* Too many `(' */
-	{
-	    syntax_error = TRUE;
 	    EMSG_RET_FAIL(_("E872: (NFA regexp) Too many '('"));
-	}
 	parno = regnpar++;
     }
 #ifdef FEAT_SYN_HL
@@ -1778,10 +1744,7 @@ nfa_reg(paren)
     {
 	/* Make a ZOPEN node. */
 	if (regnzpar >= NSUBEXP)
-	{
-	    syntax_error = TRUE;
 	    EMSG_RET_FAIL(_("E879: (NFA regexp) Too many \\z("));
-	}
 	parno = regnzpar++;
     }
 #endif
@@ -1800,7 +1763,6 @@ nfa_reg(paren)
     /* Check for proper termination. */
     if (paren != REG_NOPAREN && getchr() != Magic(')'))
     {
-	syntax_error = TRUE;
 	if (paren == REG_NPAREN)
 	    EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL);
 	else
@@ -1808,7 +1770,6 @@ nfa_reg(paren)
     }
     else if (paren == REG_NOPAREN && peekchr() != NUL)
     {
-	syntax_error = TRUE;
 	if (peekchr() == Magic(')'))
 	    EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL);
 	else
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1128,
+/**/
     1127,
 /**/
     1126,