mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
852f0aaae8
commit
463d0940e3
48
src/regexp.c
48
src/regexp.c
@ -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
|
||||
|
||||
|
@ -138,11 +138,7 @@ typedef struct {
|
||||
struct regengine {
|
||||
regprog_T *(*regcomp)(char_u*, int);
|
||||
void (*regfree)(regprog_T *);
|
||||
int (*regexec)(regmatch_T*, char_u*, colnr_T);
|
||||
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
|
||||
|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
|
||||
int (*regexec_nl)(regmatch_T*, char_u*, colnr_T);
|
||||
#endif
|
||||
int (*regexec_nl)(regmatch_T*, char_u*, colnr_T, bool);
|
||||
long (*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T,
|
||||
proftime_T*);
|
||||
#ifdef DEBUG
|
||||
|
@ -311,7 +311,7 @@ static long nfa_regtry(nfa_regprog_T *prog, colnr_T col);
|
||||
static long nfa_regexec_both(char_u *line, colnr_T col);
|
||||
static regprog_T *nfa_regcomp(char_u *expr, int re_flags);
|
||||
static void nfa_regfree(regprog_T *prog);
|
||||
static int nfa_regexec(regmatch_T *rmp, char_u *line, colnr_T col);
|
||||
static int nfa_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col, bool line_lbr);
|
||||
static long nfa_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf,
|
||||
linenr_T lnum, colnr_T col,
|
||||
proftime_T *tm);
|
||||
@ -6356,47 +6356,22 @@ static void nfa_regfree(regprog_T *prog)
|
||||
* Match a regexp against a string.
|
||||
* "rmp->regprog" is a compiled regexp as returned by nfa_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
|
||||
nfa_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 nfa_regexec_both(line, col) != 0;
|
||||
}
|
||||
|
||||
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
|
||||
|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
|
||||
|
||||
static int nfa_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col);
|
||||
|
||||
/*
|
||||
* Like nfa_regexec(), but consider a "\n" in "line" to be a line break.
|
||||
*/
|
||||
static int
|
||||
nfa_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;
|
||||
@ -6404,8 +6379,6 @@ nfa_regexec_nl (
|
||||
ireg_maxcol = 0;
|
||||
return nfa_regexec_both(line, col) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Match a regexp against multiple lines.
|
||||
|
@ -205,7 +205,7 @@ static int included_patches[] = {
|
||||
265,
|
||||
264,
|
||||
//263,
|
||||
//262,
|
||||
262,
|
||||
261,
|
||||
260,
|
||||
//259,
|
||||
|
Loading…
Reference in New Issue
Block a user