From 80a28172c1e8e17210ccbb9f3e366a828b9247c8 Mon Sep 17 00:00:00 2001
From: Norihiro Tanaka <noritnk@kcn.ne.jp>
Date: Tue, 2 Dec 2014 22:58:37 +0900
Subject: [PATCH 2/2] dfa: simplify dfaexec

* src/dfa.c (dfaexec): Simplify by rearrangement of IF conditions.
This commit induces no semantic change, and reverts part of commit
v2.5.4-144-gbafa134.
---
 src/dfa.c | 39 +++++++++++++++------------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index a04f77c..806cb04 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3459,13 +3459,23 @@ dfaexec_main (struct dfa *d, char const *begin, char *end,
             }
         }

-      if ((char *) p > end)
+      if (s < 0)
         {
-          p = NULL;
-          goto done;
+          if ((char *) p > end || p[-1] != eol || d->newlines[s1] < 0)
+            {
+              p = NULL;
+              goto done;
+            }
+
+          /* The previous character was a newline, count it, and skip
+             checking of multibyte character boundary until here.  */
+          nlcount++;
+          mbp = p;
+
+          s = allow_nl ? d->newlines[s1] : 0;
         }

-      if (s >= 0 && d->fails[s])
+      if (d->fails[s])
         {
           if (d->success[s] & sbit[*p])
             {
@@ -3479,32 +3489,13 @@ dfaexec_main (struct dfa *d, char const *begin, char *end,
             State_transition();
           else
             s = d->fails[s][*p++];
-          continue;
-        }
-
-      /* If the previous character was a newline, count it, and skip
-         checking of multibyte character boundary until here.  */
-      if (p[-1] == eol)
-        {
-          nlcount++;
-          mbp = p;
         }
-
-      if (s >= 0)
+      else
         {
           if (!d->trans[s])
             build_state (s, d);
           trans = d->trans;
-          continue;
         }
-
-      if (p[-1] != eol || d->newlines[s1] < 0)
-        {
-          p = NULL;
-          goto done;
-        }
-
-      s = allow_nl ? d->newlines[s1] : 0;
     }

  done:
-- 
2.2.0

