m4-commit
[Top][All Lists]
Advanced

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

[SCM] GNU M4 source repository branch, branch-1_4, updated. 8a5bc4007100


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, branch-1_4, updated. 8a5bc4007100cbd296aa642cd42f803a9c23bf71
Date: Mon, 22 Oct 2007 17:33:27 +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 "GNU M4 source repository".

http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=8a5bc4007100cbd296aa642cd42f803a9c23bf71

The branch, branch-1_4 has been updated
       via  8a5bc4007100cbd296aa642cd42f803a9c23bf71 (commit)
      from  ab8d0f0e20729f31f2295f4d12afda955990297e (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 -----------------------------------------------------------------
commit 8a5bc4007100cbd296aa642cd42f803a9c23bf71
Author: Eric Blake <address@hidden>
Date:   Mon Oct 22 11:13:32 2007 -0600

    Add DEBUG_REGEX debugging information.
    
    * src/m4.h (DEBUG_REGEX): New debug macro.
    * src/m4.c (main) [DEBUG_REGEX]: Open regex trace file when
    requested.
    * src/builtin.c (m4_patsubst, m4_regexp, compile_pattern)
    [DEBUG_REGEX]: Trace regex usage.
    
    Signed-off-by: Eric Blake <address@hidden>

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

Summary of changes:
 ChangeLog     |    7 +++++++
 src/builtin.c |   35 +++++++++++++++++++++++++++++++----
 src/m4.c      |   18 ++++++++++++++++++
 src/m4.h      |    1 +
 4 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 33278ae..c8bc357 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2007-10-22  Eric Blake  <address@hidden>
 
+       Add DEBUG_REGEX debugging information.
+       * src/m4.h (DEBUG_REGEX): New debug macro.
+       * src/m4.c (main) [DEBUG_REGEX]: Open regex trace file when
+       requested.
+       * src/builtin.c (m4_patsubst, m4_regexp, compile_pattern)
+       [DEBUG_REGEX]: Trace regex usage.
+
        Never let printf failures go undetected.
        * m4/gnulib-cache.m4: Augment with 'gnulib-tool --import
        xprintf'.
diff --git a/src/builtin.c b/src/builtin.c
index 5983ac2..0b7f5c1 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -252,6 +252,10 @@ typedef struct m4_regex m4_regex;
 /* Storage for the cache of regular expressions.  */
 static m4_regex regex_cache[REGEX_CACHE_SIZE];
 
+#ifdef DEBUG_REGEX
+extern FILE *trace_file;
+#endif /* DEBUG_REGEX */
+
 /*------------------------------------------------------------------.
 | Compile STR, with length LEN, into a regex.  On success, set BUF  |
 | and REGS to the compiled regex.  Compilation is cached, so do not |
@@ -278,12 +282,20 @@ compile_pattern (const char *str, size_t len, struct 
re_pattern_buffer **buf,
        *buf = regex_cache[i].buf;
        *regs = &regex_cache[i].regs;
        regex_cache[i].count++;
+#ifdef DEBUG_REGEX
+       if (trace_file)
+         xfprintf (trace_file, "cached:{%s}\n", str);
+#endif /* DEBUG_REGEX */
        return NULL;
       }
 
   /* Next, check if STR can be compiled.  */
   new_buf = xzalloc (sizeof *new_buf);
   msg = re_compile_pattern (str, len, new_buf);
+#ifdef DEBUG_REGEX
+  if (trace_file)
+    xfprintf (trace_file, "compile:{%s}\n", str);
+#endif /* DEBUG_REGEX */
   if (msg)
     {
       regfree (new_buf);
@@ -313,6 +325,10 @@ compile_pattern (const char *str, size_t len, struct 
re_pattern_buffer **buf,
   victim->len = len;
   if (victim->str)
     {
+#ifdef DEBUG_REGEX
+      if (trace_file)
+       xfprintf (trace_file, "flush:{%s}\n", victim->str);
+#endif /* DEBUG_REGEX */
       free (victim->str);
       regfree (victim->buf);
       free (victim->buf);
@@ -1958,10 +1974,10 @@ m4_translit (struct obstack *obs, int argc, token_data 
**argv)
     }
 }
 
-/*----------------------------------------------------------------------.
-| Frontend for printf like formatting.  The function format () lives in |
-| the file format.c.                                                   |
-`----------------------------------------------------------------------*/
+/*--------------------------------------------------------------.
+| Frontend for *printf like formatting.  The function format () |
+| lives in the file format.c.                                   |
+`--------------------------------------------------------------*/
 
 static void
 m4_format (struct obstack *obs, int argc, token_data **argv)
@@ -2097,6 +2113,12 @@ m4_regexp (struct obstack *obs, int argc, token_data 
**argv)
       return;
     }
 
+#ifdef DEBUG_REGEX
+  if (trace_file)
+    xfprintf (trace_file, "r:{%s}:%s%s%s\n", regexp,
+             argc == 3 ? "" : "{", repl, argc == 3 ? "" : "}");
+#endif /* DEBUG_REGEX */
+
   msg = compile_pattern (regexp, strlen (regexp), &buf, &regs);
   if (msg != NULL)
     {
@@ -2161,6 +2183,11 @@ m4_patsubst (struct obstack *obs, int argc, token_data 
**argv)
       return;
     }
 
+#ifdef DEBUG_REGEX
+  if (trace_file)
+    xfprintf (trace_file, "p:{%s}:{%s}\n", regexp, repl);
+#endif /* DEBUG_REGEX */
+
   msg = compile_pattern (regexp, strlen (regexp), &buf, &regs);
   if (msg != NULL)
     {
diff --git a/src/m4.c b/src/m4.c
index f22788e..401ce4b 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -318,6 +318,10 @@ process_file (const char *name)
 #define OPTSTRING "-B:D:EF:GH:I:L:N:PQR:S:T:U:d::eil:o:st:"
 #endif
 
+#ifdef DEBUG_REGEX
+FILE *trace_file;
+#endif /* DEBUG_REGEX */
+
 int
 main (int argc, char *const *argv, char *const *envp)
 {
@@ -338,6 +342,16 @@ main (int argc, char *const *argv, char *const *envp)
   retcode = EXIT_SUCCESS;
   atexit (close_stdin);
 
+#ifdef DEBUG_REGEX
+  {
+    const char *name = getenv ("M4_TRACE_FILE");
+    if (name)
+      trace_file = fopen (name, "a");
+    if (trace_file)
+      fputs ("m4:\n", trace_file);
+  }
+#endif /* DEBUG_REGEX */
+
   include_init ();
   debug_init ();
 #ifdef USE_STACKOVF
@@ -591,5 +605,9 @@ main (int argc, char *const *argv, char *const *envp)
     }
   output_exit ();
   free_regex ();
+#ifdef DEBUG_REGEX
+  if (trace_file)
+    fclose (trace_file);
+#endif /* DEBUG_REGEX */
   exit (retcode);
 }
diff --git a/src/m4.h b/src/m4.h
index a0b54f6..ce7bdc0 100644
--- a/src/m4.h
+++ b/src/m4.h
@@ -462,6 +462,7 @@ void reload_frozen_state (const char *);
 # define DEBUG_INPUT  1
 # define DEBUG_MACRO  1
 # define DEBUG_OUTPUT 1
+# define DEBUG_REGEX  1
 # define DEBUG_STKOVF 1
 # define DEBUG_SYM    1
 #endif


hooks/post-receive
--
GNU M4 source repository




reply via email to

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