m4-patches
[Top][All Lists]
Advanced

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

20-fyi-fix-defn-arity.patch


From: Akim Demaille
Subject: 20-fyi-fix-defn-arity.patch
Date: Sat, 13 Oct 2001 10:57:31 +0200

Now M4 is usable again with Autoconf.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * tests/macros.at (Arity and defn): New failing test.
        (Arity, defn, and freeze): New.

        Fix `Arity and defn'.

        * m4/input.c (m4_push_macro): Don't forget the arity.
        * modules/m4.c (defn): Likewise.

Index: m4/input.c
--- m4/input.c Sat, 13 Oct 2001 08:43:17 +0200 akim
+++ m4/input.c Sat, 13 Oct 2001 10:27:42 +0200 akim
@@ -391,7 +391,8 @@
 };

 void
-m4_push_macro (m4_builtin_func *func, lt_dlhandle handle, int flags)
+m4_push_macro (m4_builtin_func *func, lt_dlhandle handle,
+              int min, int max, int flags)
 {
   input_block *i;

@@ -407,6 +408,8 @@

   i->u.u_m.func                = func;
   i->u.u_m.handle      = handle;
+  i->u.u_m.min_args    = min;
+  i->u.u_m.max_args    = max;
   i->u.u_m.flags       = flags;
   i->u.u_m.read                = FALSE;

Index: m4/m4module.h
--- m4/m4module.h Sat, 13 Oct 2001 09:51:29 +0200 akim
+++ m4/m4module.h Sat, 13 Oct 2001 10:26:44 +0200 akim
@@ -395,7 +395,7 @@

 extern void    m4_push_file    (FILE *, const char *);
 extern void    m4_push_single  (int ch);
-extern void    m4_push_macro   (m4_builtin_func *, lt_dlhandle, int);
+extern void    m4_push_macro   (m4_builtin_func *, lt_dlhandle, int, int, int);
 extern struct obstack *m4_push_string_init (void);
 extern const char *m4_push_string_finish (void);
 extern void    m4_push_wrapup  (const char *);
Index: m4/macro.c
--- m4/macro.c Sat, 13 Oct 2001 09:27:31 +0200 akim
+++ m4/macro.c Sat, 13 Oct 2001 10:16:32 +0200 akim
@@ -293,11 +293,9 @@ ERROR: Recursion limit of %d exceeded, u
     m4_trace_pre (name, my_call_id, argc, argv);

   expansion = m4_push_string_init ();
-  {
-    if (!m4_bad_argc (argc, argv,
-                     SYMBOL_MIN_ARGS (symbol), SYMBOL_MAX_ARGS (symbol)))
-      m4_call_macro (symbol, argc, argv, expansion);
-  }
+  if (!m4_bad_argc (argc, argv,
+                   SYMBOL_MIN_ARGS (symbol), SYMBOL_MAX_ARGS (symbol)))
+    m4_call_macro (symbol, argc, argv, expansion);
   expanded = m4_push_string_finish ();

   if (traced)
Index: modules/m4.c
--- modules/m4.c Sat, 13 Oct 2001 09:51:29 +0200 akim
+++ modules/m4.c Sat, 13 Oct 2001 10:23:48 +0200 akim
@@ -351,11 +351,12 @@
   switch (SYMBOL_TYPE (symbol))
     {
     case M4_TOKEN_TEXT:
-      m4_shipout_string(obs, SYMBOL_TEXT (symbol), 0, TRUE);
+      m4_shipout_string (obs, SYMBOL_TEXT (symbol), 0, TRUE);
       return;

     case M4_TOKEN_FUNC:
       m4_push_macro (SYMBOL_FUNC (symbol), SYMBOL_HANDLE (symbol),
+                    SYMBOL_MIN_ARGS (symbol), SYMBOL_MAX_ARGS (symbol),
                     SYMBOL_FLAGS (symbol));
       return;

Index: tests/macros.at
--- tests/macros.at Sat, 13 Oct 2001 10:06:58 +0200 akim
+++ tests/macros.at Sat, 13 Oct 2001 10:36:47 +0200 akim
@@ -23,6 +23,82 @@
 # arguments and so on).

 ## ---------------- ##
+## Arity and defn.  ##
+## ---------------- ##
+
+AT_SETUP([Arity and defn])
+
+# Check that the arity checking of define is correctly propagated.
+
+AT_DATA([[input.m4]],
+[[define(`defun', defn(`define'))
+define
+define(`foo')
+define(`foo', `bar')
+define(`foo', `bar', baz')
+
+defun
+defun(`foo')
+defun(`foo', `bar')
+defun(`foo', `bar', baz')
+]])
+
+AT_DATA([[expout]],
+[[
+define
+
+
+
+
+defun
+
+
+
+]])
+
+AT_CHECK_M4([input.m4], 0, [expout],
+[[m4: input.m4: 5: Warning: define: too many arguments (ignored): 3 > 2
+m4: input.m4: 10: Warning: defun: too many arguments (ignored): 3 > 2
+]])
+
+AT_CLEANUP
+
+
+## ------------------------- ##
+## Arity, defn, and freeze.  ##
+## ------------------------- ##
+
+AT_SETUP([Arity, defn, and freeze])
+
+AT_DATA([[freezeme.m4]],
+[[define(`defun', defn(`define'))dnl
+undefine(`define')dnl
+]])
+
+AT_CHECK_M4([--freeze-state=frozen.m4f freezeme.m4], 0)
+
+AT_DATA([[input.m4]],
+[[defun
+defun(`foo')
+defun(`foo', `bar')
+defun(`foo', `bar', baz')
+]])
+
+AT_DATA([[expout]],
+[[defun
+
+
+
+]])
+
+AT_CHECK_M4([--reload-state=frozen.m4f input.m4], 0, expout,
+[[m4: input.m4: 4: Warning: defun: too many arguments (ignored): 3 > 2
+]])
+
+AT_CLEANUP(freezeme.m4 frozen.m4f)
+
+
+## ---------------- ##
 ## pushdef/popdef.  ##
 ## ---------------- ##




reply via email to

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