Subject: bug#19306: [PATCH 1/2] dfa: avoid execution for a pattern including an unsupported expression

From: Norihiro Tanaka <[email-masked]>
Date: Tue, 21 Jul 2015 00:14:25 +0900

On Sun, 19 Jul 2015 20:14:52 -0700
Jim Meyering <[email-masked]> wrote:

> Thank you for the additional information and the test script.
> I like most of this patch, but not the fact that it causes the
> word-delim-multibyte test to fail. I do see that also applying your
> following patch makes that test pass once again.  However, it does so
> at the cost of forcing a new class of regexps (any that contain a use
> of \b, \<  or \>) from DFA into the slower regex matcher.

I think DFA forces regex for BEGWORD, LIMWORD, ENDWORD, instead of
whether patching or not.  Could you remark code in dfassbuild() without
patching?  It seem that DFA rejects their words from before.

        case BEGWORD:
        case ENDWORD:
        case LIMWORD:
        case NOTLIMWORD:
          if (d->multibyte)
            {
              /* These constraints aren't supported in a multibyte locale.
                 Ignore them in the superset DFA, and treat them as
                 backreferences in the main DFA.  */
              sup->tokens[j++] = EMPTY;
              d->tokens[i] = BACKREF;  <<<<
              break;
            }

DFA does not handle word context in multibyte correctly.  Perhaps, if we
fix it, DFA will take a performance penalty.