diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-06-05 12:43:09 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-06-05 12:43:09 +0200 |
commit | 1cd3f2c4507ad242a6ed50270009f19fa49e5a7b (patch) | |
tree | 6650142d4b9105920890ac38612fba2b7c88a609 /src/regexp.c | |
parent | e2b8cb3b15c47107c1b05d698ce267ed1ea05079 (diff) | |
download | vim-git-1cd3f2c4507ad242a6ed50270009f19fa49e5a7b.tar.gz |
updated for version 7.3.1119v7.3.1119
Problem: Flags in 'cpo' are search for several times.
Solution: Store the result and re-use the flags.
Diffstat (limited to 'src/regexp.c')
-rw-r--r-- | src/regexp.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/regexp.c b/src/regexp.c index 3450f3aa9..853d25573 100644 --- a/src/regexp.c +++ b/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_z1_not_allowed[] = N_("E67: \\z1 et al. not allowed here"); #endif +static char_u e_missing_sb[] = N_("E69: Missing ] after %s%%["); #define NOT_MULTI 0 #define MULTI_ONE 1 @@ -1173,6 +1174,16 @@ get_coll_element(pp) 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. @@ -1183,15 +1194,10 @@ get_coll_element(pp) skip_anyof(p) char_u *p; { - int cpo_lit; /* 'cpoptions' contains 'l' flag */ - int cpo_bsl; /* 'cpoptions' contains '\' flag */ #ifdef FEAT_MBYTE int l; #endif - cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL; - cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL; - if (*p == '^') /* Complement of range. */ ++p; if (*p == ']' || *p == '-') @@ -1210,9 +1216,9 @@ skip_anyof(p) mb_ptr_adv(p); } else if (*p == '\\' - && !cpo_bsl + && !reg_cpo_bsl && (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; else if (*p == '[') { @@ -1251,6 +1257,7 @@ skip_regexp(startp, dirc, magic, newp) mymagic = MAGIC_ON; else mymagic = MAGIC_OFF; + get_cpo_flags(); for (; p[0] != NUL; mb_ptr_adv(p)) { @@ -1462,6 +1469,7 @@ regcomp_start(expr, re_flags) reg_magic = MAGIC_OFF; reg_string = (re_flags & RE_STRING); reg_strict = (re_flags & RE_STRICT); + get_cpo_flags(); num_complex_braces = 0; regnpar = 1; @@ -1909,15 +1917,11 @@ regatom(flagp) { char_u *ret; int flags; - int cpo_lit; /* 'cpoptions' contains 'l' flag */ - int cpo_bsl; /* 'cpoptions' contains '\' flag */ int c; char_u *p; int extra = 0; *flagp = WORST; /* Tentatively. */ - cpo_lit = vim_strchr(p_cpo, CPO_LITERAL) != NULL; - cpo_bsl = vim_strchr(p_cpo, CPO_BACKSL) != NULL; c = getchr(); switch (c) @@ -2207,7 +2211,7 @@ regatom(flagp) while ((c = getchr()) != ']') { if (c == NUL) - EMSG2_RET_NULL(_("E69: Missing ] after %s%%["), + EMSG2_RET_NULL(_(e_missing_sb), reg_magic == MAGIC_ALL); br = regnode(BRANCH); if (ret == NULL) @@ -2410,7 +2414,7 @@ collection: } /* 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(); if (startc > endc) @@ -2452,9 +2456,9 @@ collection: * Posix doesn't recognize backslash at all. */ else if (*regparse == '\\' - && !cpo_bsl + && !reg_cpo_bsl && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL - || (!cpo_lit + || (!reg_cpo_lit && vim_strchr(REGEXP_ABBR, regparse[1]) != NULL))) { |