summaryrefslogtreecommitdiff
path: root/src/regexp.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-07-11 22:40:32 +0000
committerBram Moolenaar <Bram@vim.org>2005-07-11 22:40:32 +0000
commit3b56eb3d3188b4fdf3956df8e7c709fabf9969ca (patch)
treedf963f784d8a6032eb798f27975541c84b16527f /src/regexp.c
parent9ff7011bcba731fc32e0cf6de8f4b037c0fcc3ec (diff)
downloadvim-git-3b56eb3d3188b4fdf3956df8e7c709fabf9969ca.tar.gz
updated for version 7.0107
Diffstat (limited to 'src/regexp.c')
-rw-r--r--src/regexp.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/regexp.c b/src/regexp.c
index dd0b1530a..ae1bfd12f 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -866,8 +866,8 @@ skip_anyof(p)
int l;
#endif
- cpo_lit = (!reg_syn && vim_strchr(p_cpo, CPO_LITERAL) != NULL);
- cpo_bsl = (!reg_syn && vim_strchr(p_cpo, CPO_BACKSL) != NULL);
+ cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
+ cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
if (*p == '^') /* Complement of range. */
++p;
@@ -1573,8 +1573,8 @@ regatom(flagp)
int extra = 0;
*flagp = WORST; /* Tentatively. */
- cpo_lit = (!reg_syn && vim_strchr(p_cpo, CPO_LITERAL) != NULL);
- cpo_bsl = (!reg_syn && vim_strchr(p_cpo, CPO_BACKSL) != NULL);
+ cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
+ cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
c = getchr();
switch (c)
@@ -3044,6 +3044,12 @@ static int ireg_icombine;
#endif
/*
+ * Copy of "rmm_maxcol": maximum column to search for a match. Zero when
+ * there is no maximum.
+ */
+static int ireg_maxcol;
+
+/*
* Sometimes need to save a copy of a line. Since alloc()/free() is very
* slow, we keep one allocated piece of memory and only re-allocate it when
* it's too small. It's freed in vim_regexec_both() when finished.
@@ -3203,6 +3209,7 @@ vim_regexec(rmp, line, col)
#ifdef FEAT_MBYTE
ireg_icombine = FALSE;
#endif
+ ireg_maxcol = 0;
return (vim_regexec_both(line, col) != 0);
}
@@ -3226,6 +3233,7 @@ vim_regexec_nl(rmp, line, col)
#ifdef FEAT_MBYTE
ireg_icombine = FALSE;
#endif
+ ireg_maxcol = 0;
return (vim_regexec_both(line, col) != 0);
}
#endif
@@ -3260,6 +3268,7 @@ vim_regexec_multi(rmp, win, buf, lnum, col)
#ifdef FEAT_MBYTE
ireg_icombine = FALSE;
#endif
+ ireg_maxcol = rmp->rmm_maxcol;
/* Need to switch to buffer "buf" to make vim_iswordc() work. */
curbuf = buf;
@@ -3317,6 +3326,10 @@ vim_regexec_both(line, col)
if (prog_magic_wrong())
goto theend;
+ /* If the start column is past the maximum column: no need to try. */
+ if (ireg_maxcol > 0 && col >= ireg_maxcol)
+ goto theend;
+
/* If pattern contains "\c" or "\C": overrule value of ireg_ic */
if (prog->regflags & RF_ICASE)
ireg_ic = TRUE;
@@ -3428,6 +3441,13 @@ vim_regexec_both(line, col)
col = (int)(s - regline);
}
+ /* Check for maximum column to try. */
+ if (ireg_maxcol > 0 && col >= ireg_maxcol)
+ {
+ retval = 0;
+ break;
+ }
+
retval = regtry(prog, col);
if (retval > 0)
break;