m4-commit
[Top][All Lists]
Advanced

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

[SCM] GNU M4 source repository branch, master, updated. cvs-readonly-149


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, master, updated. cvs-readonly-149-gacb5619
Date: Mon, 04 Aug 2008 04:41:44 +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=acb5619a320c331d846e1a4ad51cf9b72829e5c9

The branch, master has been updated
       via  acb5619a320c331d846e1a4ad51cf9b72829e5c9 (commit)
      from  aefa7adecf8d255496f5d06ffa35491c86793d47 (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 acb5619a320c331d846e1a4ad51cf9b72829e5c9
Author: Eric Blake <address@hidden>
Date:   Sun Aug 3 22:23:11 2008 -0600

    Stage 26: Allow embedded NUL in macro definitions.
    
    * m4/m4module.h (m4_arg_len): Add parameter.
    (M4ARGLEN): Provide default for the parameter.
    * m4/m4private.h (includes): Share xmemdup0.h among all libm4
    files.
    * m4/macro.c (m4_arg_len): Fail if builtins are not flattened.
    * m4/syntax.c (includes): Rely on m4private.h for xmemdup0.
    * m4/symtab.c (includes): Likewise.
    (m4_symbol_value_copy): Use xmemdup0.
    * m4/module.c (install_macro_table): Likewise.
    * src/freeze.c (reload_frozen_state): Likewise.
    * tests/freeze.at (reloading nul): Enhance test.
    * tests/null.m4: Likewise.
    * tests/null.err: Update expected output.
    * tests/null.out: Likewise.
    
    Signed-off-by: Eric Blake <address@hidden>

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

Summary of changes:
 ChangeLog       |   21 +++++++++++++++++++++
 m4/m4module.h   |    4 ++--
 m4/m4private.h  |    1 +
 m4/macro.c      |   23 ++++++++++-------------
 m4/module.c     |    3 +--
 m4/symtab.c     |    5 ++---
 m4/syntax.c     |    1 -
 src/freeze.c    |    4 ++--
 tests/freeze.at |    4 ++--
 tests/null.err  |  Bin 599 -> 639 bytes
 tests/null.m4   |  Bin 7200 -> 7223 bytes
 tests/null.out  |  Bin 524 -> 548 bytes
 12 files changed, 41 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c08f6f1..b94dbe0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2008-08-03  Eric Blake  <address@hidden>
 
+       Stage 26: Allow embedded NUL in macro definitions.
+       Clean up final few locations that did not track macro definitions
+       by length, to allow embedded NUL.  Make m4_arg_len callers aware
+       of issue of flattening builtins when determining length.
+       Memory impact: none.
+       Speed impact: none noticed.
+       * m4/m4module.h (m4_arg_len): Add parameter.
+       (M4ARGLEN): Provide default for the parameter.
+       * m4/m4private.h (includes): Share xmemdup0.h among all libm4
+       files.
+       * m4/macro.c (m4_arg_len): Fail if builtins are not flattened.
+       * m4/syntax.c (includes): Rely on m4private.h for xmemdup0.
+       * m4/symtab.c (includes): Likewise.
+       (m4_symbol_value_copy): Use xmemdup0.
+       * m4/module.c (install_macro_table): Likewise.
+       * src/freeze.c (reload_frozen_state): Likewise.
+       * tests/freeze.at (reloading nul): Enhance test.
+       * tests/null.m4: Likewise.
+       * tests/null.err: Update expected output.
+       * tests/null.out: Likewise.
+
        Fix regression in commenting unbalanced quotes, from 2008-02-16.
        * m4/m4private.h (m4__token_type): Add M4_TOKEN_COMMENT.
        * m4/input.c (m4__next_token, m4_print_token): Supply new token
diff --git a/m4/m4module.h b/m4/m4module.h
index 70a062e..c17c98a 100644
--- a/m4/m4module.h
+++ b/m4/m4module.h
@@ -165,7 +165,7 @@ struct m4_string_pair
 /* Grab the length of the text contents of argument I, or abort if the
    argument is not text.  Assumes that `m4 *context' and
    `m4_macro_args *argv' are in scope.  */
-#define M4ARGLEN(i) m4_arg_len (context, argv, i)
+#define M4ARGLEN(i) m4_arg_len (context, argv, i, false)
 
 extern bool    m4_bad_argc        (m4 *, size_t, const m4_call_info *, size_t,
                                    size_t, bool);
@@ -362,7 +362,7 @@ extern const char *m4_arg_text              (m4 *, 
m4_macro_args *, size_t, bool);
 extern bool    m4_arg_equal            (m4 *, m4_macro_args *, size_t,
                                         size_t);
 extern bool    m4_arg_empty            (m4_macro_args *, size_t);
-extern size_t  m4_arg_len              (m4 *, m4_macro_args *, size_t);
+extern size_t  m4_arg_len              (m4 *, m4_macro_args *, size_t, bool);
 extern m4_builtin_func *m4_arg_func    (m4_macro_args *, size_t);
 extern m4_obstack *m4_arg_scratch      (m4 *);
 extern m4_macro_args *m4_make_argv_ref (m4 *, m4_macro_args *, const char *,
diff --git a/m4/m4private.h b/m4/m4private.h
index 603af64..71249af 100644
--- a/m4/m4private.h
+++ b/m4/m4private.h
@@ -25,6 +25,7 @@
 #include <ltdl.h>
 
 #include "cloexec.h"
+#include "xmemdup0.h"
 
 typedef struct m4__search_path_info m4__search_path_info;
 typedef struct m4__macro_arg_stacks m4__macro_arg_stacks;
diff --git a/m4/macro.c b/m4/macro.c
index 5653576..7e6ef47 100644
--- a/m4/macro.c
+++ b/m4/macro.c
@@ -1413,9 +1413,10 @@ m4_arg_empty (m4_macro_args *argv, size_t arg)
 }
 
 /* Given ARGV, return the length of argument ARG.  Abort if the
-   argument is not text.  Indices beyond argc return 0.  */
+   argument is not text and FLATTEN is not true.  Indices beyond argc
+   return 0.  */
 size_t
-m4_arg_len (m4 *context, m4_macro_args *argv, size_t arg)
+m4_arg_len (m4 *context, m4_macro_args *argv, size_t arg, bool flatten)
 {
   m4_symbol_value *value;
   m4__symbol_chain *chain;
@@ -1428,7 +1429,7 @@ m4_arg_len (m4 *context, m4_macro_args *argv, size_t arg)
     }
   if (argv->argc <= arg)
     return 0;
-  value = m4_arg_symbol (argv, arg);
+  value = arg_symbol (argv, arg, NULL, flatten);
   if (m4_is_symbol_value_text (value))
     return m4_get_symbol_value_len (value);
   assert (value->type == M4_SYMBOL_COMP);
@@ -1444,6 +1445,9 @@ m4_arg_len (m4 *context, m4_macro_args *argv, size_t arg)
        case M4__CHAIN_STR:
          len += chain->u.u_s.len;
          break;
+       case M4__CHAIN_FUNC:
+         assert (flatten);
+         break;
        case M4__CHAIN_ARGV:
          i = chain->u.u_a.index;
          limit = chain->u.u_a.argv->argc - i - chain->u.u_a.skip_last;
@@ -1454,15 +1458,8 @@ m4_arg_len (m4 *context, m4_macro_args *argv, size_t arg)
            len += (quotes->len1 + quotes->len2) * limit;
          len += limit - 1;
          while (limit--)
-           {
-             /* TODO handle concatenation of builtins.  */
-             if (m4_is_symbol_value_func (m4_arg_symbol (chain->u.u_a.argv,
-                                                         i)))
-               assert (argv->flatten);
-             else
-               len += m4_arg_len (context, chain->u.u_a.argv, i);
-             i++;
-           }
+           len += m4_arg_len (context, chain->u.u_a.argv, i++,
+                              flatten || chain->u.u_a.flatten);
          break;
        default:
          assert (!"m4_arg_len");
@@ -1470,7 +1467,7 @@ m4_arg_len (m4 *context, m4_macro_args *argv, size_t arg)
        }
       chain = chain->next;
     }
-  assert (len);
+  assert (len || flatten);
   return len;
 }
 
diff --git a/m4/module.c b/m4/module.c
index 58dad59..bb24573 100644
--- a/m4/module.c
+++ b/m4/module.c
@@ -179,8 +179,7 @@ install_macro_table (m4 *context, m4_module *module)
          /* Sanity check that builtins meet the required interface.  */
          assert (mp->min_args <= mp->max_args);
 
-         m4_set_symbol_value_text (value, xmemdup (mp->value, len + 1),
-                                   len, 0);
+         m4_set_symbol_value_text (value, xmemdup0 (mp->value, len), len, 0);
          VALUE_MODULE (value) = module;
          VALUE_MIN_ARGS (value) = mp->min_args;
          VALUE_MAX_ARGS (value) = mp->max_args;
diff --git a/m4/symtab.c b/m4/symtab.c
index 025fbcd..61c4a64 100644
--- a/m4/symtab.c
+++ b/m4/symtab.c
@@ -21,7 +21,6 @@
 #include <config.h>
 
 #include "m4private.h"
-#include "xmemdup0.h"
 
 /* Define this to see runtime debug info.  Implied by DEBUG.  */
 /*#define DEBUG_SYM */
@@ -504,8 +503,8 @@ m4_symbol_value_copy (m4 *context, m4_symbol_value *dest, 
m4_symbol_value *src)
        size_t len = m4_get_symbol_value_len (src);
        unsigned int age = m4_get_symbol_value_quote_age (src);
        m4_set_symbol_value_text (dest,
-                                 xmemdup (m4_get_symbol_value_text (src),
-                                          len + 1), len, age);
+                                 xmemdup0 (m4_get_symbol_value_text (src),
+                                           len), len, age);
       }
       break;
     case M4_SYMBOL_FUNC:
diff --git a/m4/syntax.c b/m4/syntax.c
index 8dda94e..1fb4815 100644
--- a/m4/syntax.c
+++ b/m4/syntax.c
@@ -21,7 +21,6 @@
 #include <config.h>
 
 #include "m4private.h"
-#include "xmemdup0.h"
 
 /* Define this to see runtime debug info.  Implied by DEBUG.  */
 /*#define DEBUG_SYNTAX */
diff --git a/src/freeze.c b/src/freeze.c
index 7261b09..d61a8df 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -27,6 +27,7 @@
 #include "binary-io.h"
 #include "close-stream.h"
 #include "quotearg.h"
+#include "xmemdup0.h"
 
 static void  produce_mem_dump          (FILE *, const char *, size_t);
 static void  produce_resyntax_dump     (m4 *, FILE *);
@@ -929,8 +930,7 @@ ill-formed frozen file, version 2 directive `%c' 
encountered"), 'T');
            if (number[2] > 0)
              module = m4__module_find (string[2]);
 
-           m4_set_symbol_value_text (token, xmemdup (string[1],
-                                                     number[1] + 1),
+           m4_set_symbol_value_text (token, xmemdup0 (string[1], number[1]),
                                      number[1], 0);
            VALUE_MODULE (token) = module;
            VALUE_MAX_ARGS (token) = -1;
diff --git a/tests/freeze.at b/tests/freeze.at
index a3b4b35..995c4a6 100644
--- a/tests/freeze.at
+++ b/tests/freeze.at
@@ -386,11 +386,11 @@ AT_KEYWORDS([frozen])
 
 dnl AT_DATA can't generate NUL bytes (at least, not in all shells).
 # Skip the test if printf(1) is insufficient.
-AT_CHECK([printf 'define(-\0-,hi)changequote([,\0])changecom(--\0)dnl
+AT_CHECK([printf 'define(-\0-,\0-\0)changequote([,\0])changecom(--\0)dnl
 divert(1)undivert(null.out)' || exit 77],
  [0], [stdout], [ignore])
 mv stdout frozen.m4
-printf 'divert(0)[divnum\0] @%:@-- indir(-\0-)\n' > unfrozen.m4
+printf 'divert(0)[divnum\0] @%:@-- len(indir(-\0-))\n' > unfrozen.m4
 
 # First generate the `expout' output by running over the sources before
 # freezing.
diff --git a/tests/null.err b/tests/null.err
index 9a3f322..74ec09d 100644
Binary files a/tests/null.err and b/tests/null.err differ
diff --git a/tests/null.m4 b/tests/null.m4
index 18a5e1d..77b6e67 100644
Binary files a/tests/null.m4 and b/tests/null.m4 differ
diff --git a/tests/null.out b/tests/null.out
index 9e48a6a..5f6df39 100644
Binary files a/tests/null.out and b/tests/null.out differ


hooks/post-receive
--
GNU M4 source repository




reply via email to

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