mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
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.
This commit is contained in:
13
src/regexp.c
13
src/regexp.c
@@ -7924,7 +7924,6 @@ vim_regcomp(expr_arg, re_flags)
|
|||||||
regprog_T *prog = NULL;
|
regprog_T *prog = NULL;
|
||||||
char_u *expr = expr_arg;
|
char_u *expr = expr_arg;
|
||||||
|
|
||||||
syntax_error = FALSE;
|
|
||||||
regexp_engine = p_re;
|
regexp_engine = p_re;
|
||||||
|
|
||||||
/* Check for prefix "\%#=", that sets the regexp engine */
|
/* 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");
|
f = fopen(BT_REGEXP_DEBUG_LOG_NAME, "a");
|
||||||
if (f)
|
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);
|
fclose(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
EMSG2("(NFA) Could not open \"%s\" to write !!!",
|
EMSG2("(NFA) Could not open \"%s\" to write !!!",
|
||||||
BT_REGEXP_DEBUG_LOG_NAME);
|
BT_REGEXP_DEBUG_LOG_NAME);
|
||||||
/*
|
|
||||||
if (syntax_error)
|
|
||||||
EMSG("NFA Regexp: Syntax Error !");
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
@@ -7992,11 +7984,8 @@ vim_regcomp(expr_arg, re_flags)
|
|||||||
* NFA engine.
|
* NFA engine.
|
||||||
*/
|
*/
|
||||||
if (regexp_engine == AUTOMATIC_ENGINE)
|
if (regexp_engine == AUTOMATIC_ENGINE)
|
||||||
if (!syntax_error)
|
|
||||||
prog = bt_regengine.regcomp(expr, re_flags);
|
prog = bt_regengine.regcomp(expr, re_flags);
|
||||||
|
}
|
||||||
} /* endif prog==NULL */
|
|
||||||
|
|
||||||
|
|
||||||
return prog;
|
return prog;
|
||||||
}
|
}
|
||||||
|
@@ -221,23 +221,6 @@ static int nfa_classcodes[] = {
|
|||||||
|
|
||||||
static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
|
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. */
|
/* NFA regexp \ze operator encountered. */
|
||||||
static int nfa_has_zend;
|
static int nfa_has_zend;
|
||||||
|
|
||||||
@@ -692,7 +675,6 @@ nfa_regatom()
|
|||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case NUL:
|
case NUL:
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSG_RET_FAIL(_("E865: (NFA) Regexp end encountered prematurely"));
|
EMSG_RET_FAIL(_("E865: (NFA) Regexp end encountered prematurely"));
|
||||||
|
|
||||||
case Magic('^'):
|
case Magic('^'):
|
||||||
@@ -814,7 +796,6 @@ nfa_regatom()
|
|||||||
case Magic('|'):
|
case Magic('|'):
|
||||||
case Magic('&'):
|
case Magic('&'):
|
||||||
case Magic(')'):
|
case Magic(')'):
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSGN(_(e_misplaced), no_Magic(c));
|
EMSGN(_(e_misplaced), no_Magic(c));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
@@ -825,7 +806,6 @@ nfa_regatom()
|
|||||||
case Magic('*'):
|
case Magic('*'):
|
||||||
case Magic('{'):
|
case Magic('{'):
|
||||||
/* these should follow an atom, not form an atom */
|
/* these should follow an atom, not form an atom */
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSGN(_(e_misplaced), no_Magic(c));
|
EMSGN(_(e_misplaced), no_Magic(c));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
@@ -902,7 +882,6 @@ nfa_regatom()
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSGN(_("E867: (NFA) Unknown operator '\\z%c'"),
|
EMSGN(_("E867: (NFA) Unknown operator '\\z%c'"),
|
||||||
no_Magic(c));
|
no_Magic(c));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -1023,7 +1002,6 @@ nfa_regatom()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"),
|
EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"),
|
||||||
no_Magic(c));
|
no_Magic(c));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -1359,10 +1337,7 @@ collection:
|
|||||||
} /* if exists closing ] */
|
} /* if exists closing ] */
|
||||||
|
|
||||||
if (reg_strict)
|
if (reg_strict)
|
||||||
{
|
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSG_RET_FAIL(_(e_missingbracket));
|
EMSG_RET_FAIL(_(e_missingbracket));
|
||||||
}
|
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1512,7 +1487,6 @@ nfa_regpiece()
|
|||||||
}
|
}
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSGN(_("E869: (NFA) Unknown operator '\\@%c'"), op);
|
EMSGN(_("E869: (NFA) Unknown operator '\\@%c'"), op);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@@ -1543,10 +1517,8 @@ nfa_regpiece()
|
|||||||
greedy = FALSE;
|
greedy = FALSE;
|
||||||
}
|
}
|
||||||
if (!read_limits(&minval, &maxval))
|
if (!read_limits(&minval, &maxval))
|
||||||
{
|
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSG_RET_FAIL(_("E870: (NFA regexp) Error reading repetition limits"));
|
EMSG_RET_FAIL(_("E870: (NFA regexp) Error reading repetition limits"));
|
||||||
}
|
|
||||||
/* <atom>{0,inf}, <atom>{0,} and <atom>{} are equivalent to
|
/* <atom>{0,inf}, <atom>{0,} and <atom>{} are equivalent to
|
||||||
* <atom>* */
|
* <atom>* */
|
||||||
if (minval == 0 && maxval == MAX_LIMIT)
|
if (minval == 0 && maxval == MAX_LIMIT)
|
||||||
@@ -1614,11 +1586,8 @@ nfa_regpiece()
|
|||||||
} /* end switch */
|
} /* end switch */
|
||||||
|
|
||||||
if (re_multi_type(peekchr()) != NOT_MULTI)
|
if (re_multi_type(peekchr()) != NOT_MULTI)
|
||||||
{
|
|
||||||
/* Can't have a multi follow a 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 !"));
|
EMSG_RET_FAIL(_("E871: (NFA regexp) Can't have a multi follow a multi !"));
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -1767,10 +1736,7 @@ nfa_reg(paren)
|
|||||||
if (paren == REG_PAREN)
|
if (paren == REG_PAREN)
|
||||||
{
|
{
|
||||||
if (regnpar >= NSUBEXP) /* Too many `(' */
|
if (regnpar >= NSUBEXP) /* Too many `(' */
|
||||||
{
|
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSG_RET_FAIL(_("E872: (NFA regexp) Too many '('"));
|
EMSG_RET_FAIL(_("E872: (NFA regexp) Too many '('"));
|
||||||
}
|
|
||||||
parno = regnpar++;
|
parno = regnpar++;
|
||||||
}
|
}
|
||||||
#ifdef FEAT_SYN_HL
|
#ifdef FEAT_SYN_HL
|
||||||
@@ -1778,10 +1744,7 @@ nfa_reg(paren)
|
|||||||
{
|
{
|
||||||
/* Make a ZOPEN node. */
|
/* Make a ZOPEN node. */
|
||||||
if (regnzpar >= NSUBEXP)
|
if (regnzpar >= NSUBEXP)
|
||||||
{
|
|
||||||
syntax_error = TRUE;
|
|
||||||
EMSG_RET_FAIL(_("E879: (NFA regexp) Too many \\z("));
|
EMSG_RET_FAIL(_("E879: (NFA regexp) Too many \\z("));
|
||||||
}
|
|
||||||
parno = regnzpar++;
|
parno = regnzpar++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1800,7 +1763,6 @@ nfa_reg(paren)
|
|||||||
/* Check for proper termination. */
|
/* Check for proper termination. */
|
||||||
if (paren != REG_NOPAREN && getchr() != Magic(')'))
|
if (paren != REG_NOPAREN && getchr() != Magic(')'))
|
||||||
{
|
{
|
||||||
syntax_error = TRUE;
|
|
||||||
if (paren == REG_NPAREN)
|
if (paren == REG_NPAREN)
|
||||||
EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL);
|
EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL);
|
||||||
else
|
else
|
||||||
@@ -1808,7 +1770,6 @@ nfa_reg(paren)
|
|||||||
}
|
}
|
||||||
else if (paren == REG_NOPAREN && peekchr() != NUL)
|
else if (paren == REG_NOPAREN && peekchr() != NUL)
|
||||||
{
|
{
|
||||||
syntax_error = TRUE;
|
|
||||||
if (peekchr() == Magic(')'))
|
if (peekchr() == Magic(')'))
|
||||||
EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL);
|
EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL);
|
||||||
else
|
else
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1128,
|
||||||
/**/
|
/**/
|
||||||
1127,
|
1127,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user