grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v2.20-57-g01d9f71


From: Jim Meyering
Subject: grep branch, master, updated. v2.20-57-g01d9f71
Date: Tue, 07 Oct 2014 14:54:53 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  01d9f718410b583ab17d5e0e14d1f9e31fd878ba (commit)
      from  00f3b29027df6af21db4b3989e25c67d982cc03d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=01d9f718410b583ab17d5e0e14d1f9e31fd878ba


commit 01d9f718410b583ab17d5e0e14d1f9e31fd878ba
Author: Norihiro Tanaka <address@hidden>
Date:   Sun Oct 5 20:03:25 2014 -0700

    dfa: factor out a new nontrivial block of duplicated code
    
    * src/dfa.c (State_transition): New macro.
    (dfaexec_main): Use it twice.

diff --git a/src/dfa.c b/src/dfa.c
index 7cbe247..2e61982 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3348,26 +3348,38 @@ dfaexec_main (struct dfa *d, char const *begin, char 
*end,
                   goto done;
                 }
 
-              /* Can match with a multibyte character (and multi character
-                 collating element).  Transition table might be updated.  */
-              s = transit_state (d, s, &p, (unsigned char *) end);
-
-              if (p[-1] == eol)
-                {
-                  if ((char *) p > end)
-                    {
-                      p = NULL;
-                      goto done;
-                    }
-
-                  nlcount++;
-
-                  if (!allow_nl)
-                    s = 0;
-                }
+              /* The following code is used twice.
+                 Use a macro to avoid the risk that they diverge.  */
+#define State_transition()                                              \
+  do {                                                                  \
+              /* Can match with a multibyte character (and multi-character \
+                 collating element).  Transition table might be updated.  */ \
+              s = transit_state (d, s, &p, (unsigned char *) end);      \
+                                                                        \
+              /* If previous character is newline after a transition    \
+                 for ANYCHAR or MBCSET in non-UTF8 multibyte locales,   \
+                 check whether current position is beyond the end of    \
+                 the input buffer.  Also, transit to initial state if   \
+                 !ALLOW_NL, even if RE_DOT_NEWLINE is set. */           \
+              if (p[-1] == eol)                                         \
+                {                                                       \
+                  if ((char *) p > end)                                 \
+                    {                                                   \
+                      p = NULL;                                         \
+                      goto done;                                        \
+                    }                                                   \
+                                                                        \
+                  nlcount++;                                            \
+                                                                        \
+                  if (!allow_nl)                                        \
+                    s = 0;                                              \
+                }                                                       \
+                                                                        \
+              mbp = p;                                                  \
+              trans = d->trans;                                         \
+  } while (0)
 
-              mbp = p;
-              trans = d->trans;
+              State_transition();
             }
         }
       else
@@ -3410,28 +3422,7 @@ dfaexec_main (struct dfa *d, char const *begin, char 
*end,
 
           s1 = s;
           if (multibyte)
-            {
-              /* Can match with a multibyte character (and multicharacter
-                 collating element).  Transition table might be updated.  */
-              s = transit_state (d, s, &p, (unsigned char *) end);
-
-              if (p[-1] == eol)
-                {
-                  if ((char *) p > end)
-                    {
-                      p = NULL;
-                      goto done;
-                    }
-
-                  nlcount++;
-
-                  if (!allow_nl)
-                    s = 0;
-                }
-
-              mbp = p;
-              trans = d->trans;
-            }
+            State_transition();
           else
             s = d->fails[s][*p++];
           continue;

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |   73 ++++++++++++++++++++++++++----------------------------------
 1 files changed, 32 insertions(+), 41 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]