diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/regexp.c | 48 | ||||
-rw-r--r-- | src/regexp_defs.h | 6 | ||||
-rw-r--r-- | src/regexp_nfa.c | 37 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 14 insertions, 79 deletions
diff --git a/src/regexp.c b/src/regexp.c index 35ed1b85f7..b9a111caf1 100644 --- a/src/regexp.c +++ b/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 diff --git a/src/regexp_defs.h b/src/regexp_defs.h index 9b13de89d3..a4eaa8d0a5 100644 --- a/src/regexp_defs.h +++ b/src/regexp_defs.h @@ -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 diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index f22848cce5..52dc228bb2 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -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. diff --git a/src/version.c b/src/version.c index 988b12fbf2..8803430a3b 100644 --- a/src/version.c +++ b/src/version.c @@ -205,7 +205,7 @@ static int included_patches[] = { 265, 264, //263, - //262, + 262, 261, 260, //259, |