grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.21-54-g8f675e7


From: Jim Meyering
Subject: grep branch, master, updated. v2.21-54-g8f675e7
Date: Mon, 20 Jul 2015 03:17:03 +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  8f675e7c026ce56a8ef0cc33dc5fcd37f49f38a2 (commit)
      from  1616111f67ca533140878b9693d3a3e1e39ad1f9 (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=8f675e7c026ce56a8ef0cc33dc5fcd37f49f38a2


commit 8f675e7c026ce56a8ef0cc33dc5fcd37f49f38a2
Author: Norihiro Tanaka <address@hidden>
Date:   Sat Mar 22 17:00:36 2014 +0900

    dfa: DEBUG: print detail of DFA states
    
    When compiled with -DDEBUG, grep outputs tokens etc.
    With this change, also print DFA states and transitions.
    This change is very useful when debugging those.
    
    * src/dfa.c (prtok) [DEBUG]: Change `%c' to `%02x' in printf format.
    (state_index) [DEBUG]: Print detail of new state.
    (dfastate) [DEBUG]: Print detail of DFA states.
    Reported as http://debbugs.gnu.org/18707

diff --git a/src/dfa.c b/src/dfa.c
index f9b3da9..b5ca825 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -509,8 +509,8 @@ prtok (token t)
     fprintf (stderr, "END");
   else if (t < NOTCHAR)
     {
-      int ch = t;
-      fprintf (stderr, "%c", ch);
+      unsigned int ch = t;
+      fprintf (stderr, "0x%02x", ch);
     }
   else
     {
@@ -2139,6 +2139,28 @@ state_index (struct dfa *d, position_set const *s, int 
context)
         return i;
     }
 
+#ifdef DEBUG
+  fprintf (stderr, "new state %zd\n nextpos:", i);
+  for (j = 0; j < s->nelem; ++j)
+    {
+      fprintf (stderr, " %zu:", s->elems[j].index);
+      prtok (d->tokens[s->elems[j].index]);
+    }
+  fprintf (stderr, "\n context:");
+  if (context ^ CTX_ANY)
+    {
+      if (context & CTX_NONE)
+        fprintf (stderr, " CTX_NONE");
+      if (context & CTX_LETTER)
+        fprintf (stderr, " CTX_LETTER");
+      if (context & CTX_NEWLINE)
+        fprintf (stderr, " CTX_NEWLINE");
+    }
+  else
+    fprintf (stderr, " CTX_ANY");
+  fprintf (stderr, "\n");
+#endif
+
   /* We'll have to create a new state.  */
   d->states = maybe_realloc (d->states, d->sindex, &d->salloc,
                              sizeof *d->states);
@@ -2369,7 +2391,7 @@ dfaanalyze (struct dfa *d, int searchflag)
   fprintf (stderr, "dfaanalyze:\n");
   for (i = 0; i < d->tindex; ++i)
     {
-      fprintf (stderr, " %zd:", i);
+      fprintf (stderr, " %zu:", i);
       prtok (d->tokens[i]);
     }
   putc ('\n', stderr);
@@ -2483,7 +2505,7 @@ dfaanalyze (struct dfa *d, int searchflag)
         }
 #ifdef DEBUG
       /* ... balance the above nonsyntactic #ifdef goo...  */
-      fprintf (stderr, "node %zd:", i);
+      fprintf (stderr, "node %zu:", i);
       prtok (d->tokens[i]);
       putc ('\n', stderr);
       fprintf (stderr,
@@ -2491,13 +2513,13 @@ dfaanalyze (struct dfa *d, int searchflag)
       fprintf (stderr, " firstpos:");
       for (j = stk[-1].nfirstpos; j-- > 0;)
         {
-          fprintf (stderr, " %zd:", firstpos[j].index);
+          fprintf (stderr, " %zu:", firstpos[j].index);
           prtok (d->tokens[firstpos[j].index]);
         }
       fprintf (stderr, "\n lastpos:");
       for (j = stk[-1].nlastpos; j-- > 0;)
         {
-          fprintf (stderr, " %zd:", lastpos[j].index);
+          fprintf (stderr, " %zu:", lastpos[j].index);
           prtok (d->tokens[lastpos[j].index]);
         }
       putc ('\n', stderr);
@@ -2512,12 +2534,12 @@ dfaanalyze (struct dfa *d, int searchflag)
         || d->tokens[i] >= CSET)
       {
 #ifdef DEBUG
-        fprintf (stderr, "follows(%zd:", i);
+        fprintf (stderr, "follows(%zu:", i);
         prtok (d->tokens[i]);
         fprintf (stderr, "):");
         for (j = d->follows[i].nelem; j-- > 0;)
           {
-            fprintf (stderr, " %zd:", d->follows[i].elems[j].index);
+            fprintf (stderr, " %zu:", d->follows[i].elems[j].index);
             prtok (d->tokens[d->follows[i].elems[j].index]);
           }
         putc ('\n', stderr);
@@ -2607,6 +2629,10 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
   bool next_isnt_1st_byte = false; /* We can't add state0.  */
   size_t i, j, k;
 
+#ifdef DEBUG
+  fprintf (stderr, "build state %td\n", s);
+#endif
+
   zeroset (matches);
 
   for (i = 0; i < d->states[s].elems.nelem; ++i)
@@ -2658,6 +2684,16 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
             continue;
         }
 
+#ifdef DEBUG
+      fprintf (stderr, " nextpos %zu:", pos.index);
+      prtok (d->tokens[pos.index]);
+      fprintf (stderr, " of");
+      for (j = 0; j < NOTCHAR; j++)
+      if (tstbit (j,  matches))
+        fprintf (stderr, " 0x%02zx", j);
+      fprintf (stderr, "\n");
+#endif
+
       for (j = 0; j < ngrps; ++j)
         {
           /* If matches contains a single character only, and the current
@@ -2818,6 +2854,29 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
       else
         state_letter = state;
 
+#ifdef DEBUG
+      fprintf (stderr, "group %zu\n nextpos:", i);
+      for (j = 0; j < grps[i].nelem; ++j)
+        {
+          fprintf (stderr, " %zu:", grps[i].elems[j]);
+          prtok (d->tokens[grps[i].elems[j]]);
+        }
+      fprintf (stderr, "\n follows:");
+      for (j = 0; j < follows.nelem; ++j)
+        {
+          fprintf (stderr, " %zu:", follows.elems[j].index);
+          prtok (d->tokens[follows.elems[j].index]);
+        }
+      fprintf (stderr, "\n states:");
+      if (possible_contexts & CTX_NEWLINE)
+        fprintf (stderr, " CTX_NEWLINE:%td", state_newline);
+      if (possible_contexts & CTX_LETTER)
+        fprintf (stderr, " CTX_LETTER:%td", state_letter);
+      if (possible_contexts & CTX_NONE)
+        fprintf (stderr, " CTX_NONE:%td", state);
+      fprintf (stderr, "\n");
+#endif
+
       /* Set the transitions for each character in the current label.  */
       for (j = 0; j < CHARCLASS_WORDS; ++j)
         for (k = 0; k < CHARCLASS_WORD_BITS; ++k)
@@ -2834,6 +2893,17 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
             }
     }
 
+#ifdef DEBUG
+  fprintf (stderr, "trans table %td", s);
+  for (i = 0; i < NOTCHAR; ++i)
+    {
+      if (!(i & 0xf))
+        fprintf (stderr, "\n");
+      fprintf (stderr, " %2td", trans[i]);
+    }
+  fprintf (stderr, "\n");
+#endif
+
   for (i = 0; i < ngrps; ++i)
     free (grps[i].elems);
   free (follows.elems);

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

Summary of changes:
 src/dfa.c |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 78 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

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