forked from aniani/vim
updated for version 7.3.1119
Problem: Flags in 'cpo' are search for several times. Solution: Store the result and re-use the flags.
This commit is contained in:
34
src/regexp.c
34
src/regexp.c
@@ -365,6 +365,7 @@ static char_u e_unmatchedpar[] = N_("E55: Unmatched %s)");
|
|||||||
static char_u e_z_not_allowed[] = N_("E66: \\z( not allowed here");
|
static char_u e_z_not_allowed[] = N_("E66: \\z( not allowed here");
|
||||||
static char_u e_z1_not_allowed[] = N_("E67: \\z1 et al. not allowed here");
|
static char_u e_z1_not_allowed[] = N_("E67: \\z1 et al. not allowed here");
|
||||||
#endif
|
#endif
|
||||||
|
static char_u e_missing_sb[] = N_("E69: Missing ] after %s%%[");
|
||||||
|
|
||||||
#define NOT_MULTI 0
|
#define NOT_MULTI 0
|
||||||
#define MULTI_ONE 1
|
#define MULTI_ONE 1
|
||||||
@@ -1173,6 +1174,16 @@ get_coll_element(pp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void get_cpo_flags __ARGS((void));
|
||||||
|
static int reg_cpo_lit; /* 'cpoptions' contains 'l' flag */
|
||||||
|
static int reg_cpo_bsl; /* 'cpoptions' contains '\' flag */
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_cpo_flags()
|
||||||
|
{
|
||||||
|
reg_cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
|
||||||
|
reg_cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skip over a "[]" range.
|
* Skip over a "[]" range.
|
||||||
@@ -1183,15 +1194,10 @@ get_coll_element(pp)
|
|||||||
skip_anyof(p)
|
skip_anyof(p)
|
||||||
char_u *p;
|
char_u *p;
|
||||||
{
|
{
|
||||||
int cpo_lit; /* 'cpoptions' contains 'l' flag */
|
|
||||||
int cpo_bsl; /* 'cpoptions' contains '\' flag */
|
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
int l;
|
int l;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
|
|
||||||
cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
|
|
||||||
|
|
||||||
if (*p == '^') /* Complement of range. */
|
if (*p == '^') /* Complement of range. */
|
||||||
++p;
|
++p;
|
||||||
if (*p == ']' || *p == '-')
|
if (*p == ']' || *p == '-')
|
||||||
@@ -1210,9 +1216,9 @@ skip_anyof(p)
|
|||||||
mb_ptr_adv(p);
|
mb_ptr_adv(p);
|
||||||
}
|
}
|
||||||
else if (*p == '\\'
|
else if (*p == '\\'
|
||||||
&& !cpo_bsl
|
&& !reg_cpo_bsl
|
||||||
&& (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
|
&& (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
|
||||||
|| (!cpo_lit && vim_strchr(REGEXP_ABBR, p[1]) != NULL)))
|
|| (!reg_cpo_lit && vim_strchr(REGEXP_ABBR, p[1]) != NULL)))
|
||||||
p += 2;
|
p += 2;
|
||||||
else if (*p == '[')
|
else if (*p == '[')
|
||||||
{
|
{
|
||||||
@@ -1251,6 +1257,7 @@ skip_regexp(startp, dirc, magic, newp)
|
|||||||
mymagic = MAGIC_ON;
|
mymagic = MAGIC_ON;
|
||||||
else
|
else
|
||||||
mymagic = MAGIC_OFF;
|
mymagic = MAGIC_OFF;
|
||||||
|
get_cpo_flags();
|
||||||
|
|
||||||
for (; p[0] != NUL; mb_ptr_adv(p))
|
for (; p[0] != NUL; mb_ptr_adv(p))
|
||||||
{
|
{
|
||||||
@@ -1462,6 +1469,7 @@ regcomp_start(expr, re_flags)
|
|||||||
reg_magic = MAGIC_OFF;
|
reg_magic = MAGIC_OFF;
|
||||||
reg_string = (re_flags & RE_STRING);
|
reg_string = (re_flags & RE_STRING);
|
||||||
reg_strict = (re_flags & RE_STRICT);
|
reg_strict = (re_flags & RE_STRICT);
|
||||||
|
get_cpo_flags();
|
||||||
|
|
||||||
num_complex_braces = 0;
|
num_complex_braces = 0;
|
||||||
regnpar = 1;
|
regnpar = 1;
|
||||||
@@ -1909,15 +1917,11 @@ regatom(flagp)
|
|||||||
{
|
{
|
||||||
char_u *ret;
|
char_u *ret;
|
||||||
int flags;
|
int flags;
|
||||||
int cpo_lit; /* 'cpoptions' contains 'l' flag */
|
|
||||||
int cpo_bsl; /* 'cpoptions' contains '\' flag */
|
|
||||||
int c;
|
int c;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int extra = 0;
|
int extra = 0;
|
||||||
|
|
||||||
*flagp = WORST; /* Tentatively. */
|
*flagp = WORST; /* Tentatively. */
|
||||||
cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
|
|
||||||
cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
|
|
||||||
|
|
||||||
c = getchr();
|
c = getchr();
|
||||||
switch (c)
|
switch (c)
|
||||||
@@ -2207,7 +2211,7 @@ regatom(flagp)
|
|||||||
while ((c = getchr()) != ']')
|
while ((c = getchr()) != ']')
|
||||||
{
|
{
|
||||||
if (c == NUL)
|
if (c == NUL)
|
||||||
EMSG2_RET_NULL(_("E69: Missing ] after %s%%["),
|
EMSG2_RET_NULL(_(e_missing_sb),
|
||||||
reg_magic == MAGIC_ALL);
|
reg_magic == MAGIC_ALL);
|
||||||
br = regnode(BRANCH);
|
br = regnode(BRANCH);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
@@ -2410,7 +2414,7 @@ collection:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Handle \o40, \x20 and \u20AC style sequences */
|
/* Handle \o40, \x20 and \u20AC style sequences */
|
||||||
if (endc == '\\' && !cpo_lit && !cpo_bsl)
|
if (endc == '\\' && !reg_cpo_lit && !reg_cpo_bsl)
|
||||||
endc = coll_get_char();
|
endc = coll_get_char();
|
||||||
|
|
||||||
if (startc > endc)
|
if (startc > endc)
|
||||||
@@ -2452,9 +2456,9 @@ collection:
|
|||||||
* Posix doesn't recognize backslash at all.
|
* Posix doesn't recognize backslash at all.
|
||||||
*/
|
*/
|
||||||
else if (*regparse == '\\'
|
else if (*regparse == '\\'
|
||||||
&& !cpo_bsl
|
&& !reg_cpo_bsl
|
||||||
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
|
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
|
||||||
|| (!cpo_lit
|
|| (!reg_cpo_lit
|
||||||
&& vim_strchr(REGEXP_ABBR,
|
&& vim_strchr(REGEXP_ABBR,
|
||||||
regparse[1]) != NULL)))
|
regparse[1]) != NULL)))
|
||||||
{
|
{
|
||||||
|
@@ -686,13 +686,8 @@ nfa_regatom()
|
|||||||
int startc = -1;
|
int startc = -1;
|
||||||
int endc = -1;
|
int endc = -1;
|
||||||
int oldstartc = -1;
|
int oldstartc = -1;
|
||||||
int cpo_lit; /* 'cpoptions' contains 'l' flag */
|
|
||||||
int cpo_bsl; /* 'cpoptions' contains '\' flag */
|
|
||||||
int glue; /* ID that will "glue" nodes together */
|
int glue; /* ID that will "glue" nodes together */
|
||||||
|
|
||||||
cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL;
|
|
||||||
cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL;
|
|
||||||
|
|
||||||
c = getchr();
|
c = getchr();
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@@ -1224,10 +1219,10 @@ collection:
|
|||||||
* Posix doesn't recognize backslash at all.
|
* Posix doesn't recognize backslash at all.
|
||||||
*/
|
*/
|
||||||
if (*regparse == '\\'
|
if (*regparse == '\\'
|
||||||
&& !cpo_bsl
|
&& !reg_cpo_bsl
|
||||||
&& regparse + 1 <= endp
|
&& regparse + 1 <= endp
|
||||||
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
|
&& (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
|
||||||
|| (!cpo_lit
|
|| (!reg_cpo_lit
|
||||||
&& vim_strchr(REGEXP_ABBR, regparse[1])
|
&& vim_strchr(REGEXP_ABBR, regparse[1])
|
||||||
!= NULL)
|
!= NULL)
|
||||||
)
|
)
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1119,
|
||||||
/**/
|
/**/
|
||||||
1118,
|
1118,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user