On Fri, 2 Sep 2016 15:35:22 -0700 Paul Eggert <egg...@cs.ucla.edu> wrote:
> Norihiro Tanaka wrote: > > However, the patch adds an argument to dfasyntax(). To synchronize > > between grep and dfa easily, I expect it is applied before dfa is moved > > to gnulib. > > Since we're already changing the DFA API already, how about if we have a > flags arg that combines all these little Boolean arguments? That will make > future changes less disruptive. Although the existing code supports any > newline terminator, in practice only '\0' and '\n' are useful, so it's really > just a boolean. > > Most of the changes in your proposed patch are subsumed by the changes for > multithreading, so the patch can be simplified now. I installed the attached, > and plan to follow up shortly about the corresponding Gawk changes that I'll > propose. Thanks for reviewing. You say we can simplified by the changes for multithreading, but two changes in the patch are needed.
From fb1fe06e6f912039d524d42a6fff274550f55463 Mon Sep 17 00:00:00 2001 From: Norihiro Tanaka <nori...@kcn.ne.jp> Date: Sat, 3 Sep 2016 12:02:37 +0900 Subject: [PATCH] dfa: additional change new option for anchored searches * src/dfa.c (dfaexec_main): Do it. --- src/dfa.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/src/dfa.c b/src/dfa.c index e009bc6..41b0ffb 100644 --- a/src/dfa.c +++ b/src/dfa.c @@ -3172,10 +3172,18 @@ dfaexec_main (struct dfa *d, char const *begin, char *end, bool allow_nl, mbp = p; s = allow_nl ? d->newlines[s1] : 0; + + s = (allow_nl ? d->newlines[s1] + : (d->syntax.sbit[eol] == CTX_NEWLINE ? 0 + : (d->syntax.sbit[eol] == CTX_LETTER ? d->min_trcount - 1 + : d->initstate_notbol))); } else if (d->fails[s]) { - if (d->success[s] & d->syntax.sbit[*p]) + if ((d->success[s] & d->syntax.sbit[*p]) + || ((char *) p == end + && ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NEWLINE, s, + *d))) goto done; if (multibyte && s < d->min_trcount) -- 1.7.1