diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-09-20 21:37:48 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-09-20 21:37:48 +0300 |
commit | d64da79c830daee5b0c9e125320f240a22aa4110 (patch) | |
tree | d46aaf2311624509d8dab4c1bb3822c05bcab056 /re.c | |
parent | d6493fae8856653b4eaa866e859f51b7218e4446 (diff) | |
parent | 491c127c5c78f0729f3e75bc0d07d49285a2041b (diff) | |
download | egawk-d64da79c830daee5b0c9e125320f240a22aa4110.tar.gz egawk-d64da79c830daee5b0c9e125320f240a22aa4110.tar.bz2 egawk-d64da79c830daee5b0c9e125320f240a22aa4110.zip |
Merge branch 'master' into feature/nocopy
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -49,7 +49,6 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) int c, c2; static bool first = true; static bool no_dfa = false; - bool has_anchor = false; reg_syntax_t dfa_syn; int i; @@ -160,9 +159,6 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) } /* switch */ } else { c = *src; - if (c == '^' || c == '$') - has_anchor = true; - *dest++ = *src++; /* not '\\' */ } if (gawk_mb_cur_max > 1 && is_multibyte) @@ -228,11 +224,10 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) if (dfa && ! no_dfa) { rp->dfareg = dfaalloc(); dfasyntax(rp->dfareg, & localeinfo, dfa_syn, - ignorecase ? DFA_CASE_FOLD : 0); + (ignorecase ? DFA_CASE_FOLD : 0) | DFA_ANCHOR); dfacomp(buf, len, rp->dfareg, true); } else rp->dfareg = NULL; - rp->has_anchor = has_anchor; /* Additional flags that help with RS as regexp. */ for (i = 0; i < len; i++) { @@ -287,7 +282,7 @@ research(Regexp *rp, char *str, int start, ret = dfaexec(superset, str+start, str+start+len, true, NULL, NULL); - if (ret && ((! need_start && ! rp->has_anchor) + if (ret && (! need_start || (! superset && dfaisfast(rp->dfareg)))) ret = dfaexec(rp->dfareg, str+start, str+start+len, true, NULL, &try_backref); @@ -298,7 +293,6 @@ research(Regexp *rp, char *str, int start, || start != 0 || no_bol || need_start - || rp->has_anchor || try_backref) { /* * Passing NULL as last arg speeds up search for cases |