aboutsummaryrefslogtreecommitdiff
path: root/src/regexp.c
diff options
context:
space:
mode:
authorKlemen Košir <klemen913@gmail.com>2014-04-27 13:40:53 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-29 10:32:04 -0300
commit463d0940e30ed16c6d2f6b40923aed2b4999e80b (patch)
tree44e76457df57cefa52d843c2dd0217b73380f144 /src/regexp.c
parent852f0aaae8c82ed879df8bbe9cb1914002dad954 (diff)
downloadrneovim-463d0940e30ed16c6d2f6b40923aed2b4999e80b.tar.gz
rneovim-463d0940e30ed16c6d2f6b40923aed2b4999e80b.tar.bz2
rneovim-463d0940e30ed16c6d2f6b40923aed2b4999e80b.zip
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
Diffstat (limited to 'src/regexp.c')
-rw-r--r--src/regexp.c48
1 files changed, 7 insertions, 41 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