vim-patch:7.4.262

Problem:    Duplicate code in regexec().
Solution:   Add line_lbr flag to regexec_nl().

https://code.google.com/p/vim/source/detail?r=0ea551fa607dc443b97c2fba97dc0c9cb0bcf303
This commit is contained in:
Klemen Košir
2014-04-27 13:40:53 +02:00
committed by Thiago de Arruda
parent 852f0aaae8
commit 463d0940e3
4 changed files with 14 additions and 79 deletions

View File

@@ -3295,53 +3295,28 @@ static lpos_T reg_endzpos[NSUBEXP]; /* idem, end pos */
/* TRUE if using multi-line regexp. */
#define REG_MULTI (reg_match == NULL)
static int bt_regexec(regmatch_T *rmp, char_u *line, colnr_T col);
static int bt_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col, bool line_lbr);
/*
* Match a regexp against a string.
* "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
* Uses curbuf for line count and 'iskeyword'.
* If "line_lbr" is true, consider a "\n" in "line" to be a line break.
*
* Return TRUE if there is a match, FALSE if not.
*/
static int
bt_regexec (
regmatch_T *rmp,
char_u *line, /* string to match against */
colnr_T col /* column to start looking for match */
)
{
reg_match = rmp;
reg_mmatch = NULL;
reg_maxline = 0;
reg_line_lbr = FALSE;
reg_buf = curbuf;
reg_win = NULL;
ireg_ic = rmp->rm_ic;
ireg_icombine = FALSE;
ireg_maxcol = 0;
return bt_regexec_both(line, col, NULL) != 0;
}
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
static int bt_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col);
/*
* Like vim_regexec(), but consider a "\n" in "line" to be a line break.
*/
static int
bt_regexec_nl (
regmatch_T *rmp,
char_u *line, /* string to match against */
colnr_T col /* column to start looking for match */
colnr_T col, /* column to start looking for match */
bool line_lbr
)
{
reg_match = rmp;
reg_mmatch = NULL;
reg_maxline = 0;
reg_line_lbr = TRUE;
reg_line_lbr = line_lbr;
reg_buf = curbuf;
reg_win = NULL;
ireg_ic = rmp->rm_ic;
@@ -3349,7 +3324,6 @@ bt_regexec_nl (
ireg_maxcol = 0;
return bt_regexec_both(line, col, NULL) != 0;
}
#endif
static long bt_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf,
linenr_T lnum, colnr_T col,
@@ -6985,11 +6959,7 @@ static regengine_T bt_regengine =
{
bt_regcomp,
bt_regfree,
bt_regexec,
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
bt_regexec_nl,
#endif
bt_regexec_multi
#ifdef REGEXP_DEBUG
,(char_u *)""
@@ -7006,11 +6976,7 @@ static regengine_T nfa_regengine =
{
nfa_regcomp,
nfa_regfree,
nfa_regexec,
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
nfa_regexec_nl,
#endif
nfa_regexec_multi
#ifdef REGEXP_DEBUG
,(char_u *)""
@@ -7126,7 +7092,7 @@ vim_regexec (
colnr_T col /* column to start looking for match */
)
{
return rmp->regprog->engine->regexec(rmp, line, col);
return rmp->regprog->engine->regexec_nl(rmp, line, col, false);
}
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
@@ -7136,7 +7102,7 @@ vim_regexec (
*/
int vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col)
{
return rmp->regprog->engine->regexec_nl(rmp, line, col);
return rmp->regprog->engine->regexec_nl(rmp, line, col, true);
}
#endif