On Fri, 2 Sep 2016 22:07:18 -0700
Paul Eggert <egg...@cs.ucla.edu> wrote:

> Norihiro Tanaka wrote:
> > You say we can simplified by the changes for
> > multithreading, but two changes in the patch are needed.
> 
> Thanks, I missed that. I installed your patch, along with the attached minor 
> cleanup, and am closing this bug report.

I tested the new feature in gawk, and found lost some changes in original
patch.  I send the patch to fix them again.  After applying the patch,
I confirmed that all tests were success in gawk.
From 3d798417fc725a60ee149dfb6fb5e2469d9c44d6 Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <nori...@kcn.ne.jp>
Date: Fri, 9 Sep 2016 01:34:47 +0900
Subject: [PATCH] dfa: additional change new option for anchored searches

* src/dfa.c (dfaexec_main): Do it.
---
 src/dfa.c |   45 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 5c045ac..4c41fa6 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -1461,7 +1461,7 @@ lex (struct dfa *dfa)
             {
               zeroset (ccl);
               for (c2 = 0; c2 < NOTCHAR; ++c2)
-                if (unibyte_word_constituent (dfa, c2))
+                if (dfa->syntax.sbit[c2] == CTX_LETTER)
                   setbit (c2, ccl);
               if (c == 'W')
                 notset (ccl);
@@ -2178,11 +2178,10 @@ charclass_context (struct dfa const *dfa, charclass c)
   int context = 0;
   unsigned int j;
 
-  if (tstbit (dfa->syntax.eolbyte, c))
-    context |= CTX_NEWLINE;
-
   for (j = 0; j < CHARCLASS_WORDS; ++j)
     {
+      if (c[j] & dfa->syntax.newline[j])
+        context |= CTX_NEWLINE;
       if (c[j] & dfa->syntax.letters[j])
         context |= CTX_LETTER;
       if (c[j] & ~(dfa->syntax.letters[j] | dfa->syntax.newline[j]))
@@ -2676,13 +2675,27 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
      is to fail miserably.  */
   if (d->searchflag)
     {
+      int c;
+
       state_newline = 0;
       state_letter = d->min_trcount - 1;
       state = d->initstate_notbol;
 
-      for (i = 0; i < NOTCHAR; ++i)
-        trans[i] = unibyte_word_constituent (d, i) ? state_letter : state;
-      trans[d->syntax.eolbyte] = state_newline;
+      for (c = 0; c < NOTCHAR; ++c)
+        {
+          switch (d->syntax.sbit[c])
+            {
+            case CTX_NEWLINE:
+              trans[c] = state_newline;
+              break;
+            case CTX_LETTER:
+              trans[c] = state_letter;
+              break;
+            default:
+              trans[c] = state;
+              break;
+            }
+        }
     }
   else
     for (i = 0; i < NOTCHAR; ++i)
@@ -2785,12 +2798,18 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
             {
               int c = j * CHARCLASS_WORD_BITS + k;
 
-              if (c == d->syntax.eolbyte)
-                trans[c] = state_newline;
-              else if (unibyte_word_constituent (d, c))
-                trans[c] = state_letter;
-              else if (c < NOTCHAR)
-                trans[c] = state;
+              switch (d->syntax.sbit[c])
+                {
+                case CTX_NEWLINE:
+                  trans[c] = state_newline;
+                  break;
+                case CTX_LETTER:
+                  trans[c] = state_letter;
+                  break;
+                default:
+                  trans[c] = state;
+                  break;
+                }
             }
     }
 
-- 
1.7.1

Reply via email to