summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-07-15 22:31:52 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-07-15 22:31:52 +0300
commit32e0339ca70c201298571394909558c18b4b2a37 (patch)
treee39e1672da6070750a4f4a7399441dc239ef8673
parent848eeca1caa9221b3b9cc3bc7678787040a03657 (diff)
parent44cce0245a8113885ecedc34ac955aca6a021ca9 (diff)
downloadgawk-32e0339ca70c201298571394909558c18b4b2a37.tar.gz
Merge branch 'master' into feature/api-mpfr
-rw-r--r--ChangeLog9
-rw-r--r--re.c15
2 files changed, 21 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2044a27b..2e53b5d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-07-15 Arnold D. Robbins <arnold@skeeve.com>
+
+ Revert change of 2016-07-24 that always runs the dfa
+ matcher. Based on a bug report from Alexandre Oliva
+ <lxoliva@fsfla.org>, DFA can cause gawk to hang, even
+ in the C locale.
+
+ * re.c (research): Don't use dfa if need_start is true.
+
2017-07-11 Arnold D. Robbins <arnold@skeeve.com>
* awk.h (is_letter): Add declaration.
diff --git a/re.c b/re.c
index cf369a97..c522aeb9 100644
--- a/re.c
+++ b/re.c
@@ -268,17 +268,26 @@ research(Regexp *rp, char *str, int start,
rp->pat.not_bol = 1;
/*
- * Always do dfa search if can; if it fails, we won't bother
- * with the regex search.
+ * Always do dfa search if can; if it fails, then even if
+ * need_start is true, we won't bother with the regex search.
*
* The dfa matcher doesn't have a no_bol flag, so don't bother
* trying it in that case.
*
+ * 7/2008: Skip the dfa matcher if need_start. The dfa matcher
+ * has bugs in certain multibyte cases and it's too difficult
+ * to try to special case things.
+ * 7/2017: Apparently there are some cases where DFA gets
+ * stuck, even in the C locale, so we use dfa only if not need_start.
+ *
+ * Should that issue ever get resolved, note this comment:
+ *
* 7/2016: The dfa matcher can't handle a case where searching
* starts in the middle of a string, so don't bother trying it
* in that case.
+ * if (rp->dfa && ! no_bol && start == 0) ...
*/
- if (rp->dfareg != NULL && ! no_bol && start == 0) {
+ if (rp->dfareg != NULL && ! no_bol && ! need_start) {
struct dfa *superset = dfasuperset(rp->dfareg);
if (superset)
ret = dfaexec(superset, str+start, str+start+len,