m4-commit
[Top][All Lists]
Advanced

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

Changes to m4/src/Attic/builtin.c,v [branch-1_4]


From: Eric Blake
Subject: Changes to m4/src/Attic/builtin.c,v [branch-1_4]
Date: Mon, 22 Oct 2007 17:34:23 +0000

CVSROOT:        /sources/m4
Module name:    m4
Branch:         branch-1_4
Changes by:     Eric Blake <ericb>      07/10/22 17:34:22

Index: src/builtin.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/builtin.c,v
retrieving revision 1.1.1.1.2.67
retrieving revision 1.1.1.1.2.68
diff -u -b -r1.1.1.1.2.67 -r1.1.1.1.2.68
--- src/builtin.c       22 Oct 2007 16:38:33 -0000      1.1.1.1.2.67
+++ src/builtin.c       22 Oct 2007 17:34:22 -0000      1.1.1.1.2.68
@@ -252,6 +252,10 @@
 /* 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 @@
        *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 @@
   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 @@
     }
 }
 
-/*----------------------------------------------------------------------.
-| 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 @@
       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 @@
       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)
     {




reply via email to

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