m4-patches
[Top][All Lists]
Advanced

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

16-fyi-bad-argc-interface.patch


From: Akim Demaille
Subject: 16-fyi-bad-argc-interface.patch
Date: Sat, 13 Oct 2001 10:57:11 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * m4/macro.c (expand_macro): Let m4_bad_argc handle the cases
        where no checking is needed.
        * m4/utility.c (m4_bad_argc): Use the usual (argc, argv, ...)
        interface instead of (name, argc...).
        Adjust callers.
        * modules/gnu.c (m4_patsubst_do): Don't check argc, done
        elsewhere.

Index: m4/m4module.h
--- m4/m4module.h Sat, 13 Oct 2001 08:43:17 +0200 akim
+++ m4/m4module.h Sat, 13 Oct 2001 09:18:47 +0200 akim
@@ -200,7 +200,7 @@
 #define DEF_BCOMM "#"
 #define DEF_ECOMM "\n"

-boolean m4_bad_argc (m4_token *, int, int, int);
+boolean m4_bad_argc (int, m4_token **, int, int);
 const char *m4_skip_space (const char *);
 boolean m4_numeric_arg (m4_token *, const char *, int *);
 void m4_shipout_int (struct obstack *, int);
Index: m4/macro.c
--- m4/macro.c Sat, 13 Oct 2001 08:43:17 +0200 akim
+++ m4/macro.c Sat, 13 Oct 2001 09:22:01 +0200 akim
@@ -294,14 +294,8 @@ ERROR: Recursion limit of %d exceeded, u

   expansion = m4_push_string_init ();
   {
-    boolean bad_args = FALSE;
-
-    /* If argument limits are set for this builtin, check them and
-       only call the builtin handler if the check passes.  */
-    if ((SYMBOL_MIN_ARGS (symbol) > 0) || (SYMBOL_MAX_ARGS (symbol) > 0))
-      bad_args = m4_bad_argc (argv[0], argc, SYMBOL_MIN_ARGS (symbol),
-                            SYMBOL_MAX_ARGS (symbol));
-    if (!bad_args)
+    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 ();
Index: m4/utility.c
--- m4/utility.c Sat, 13 Oct 2001 09:16:36 +0200 akim
+++ m4/utility.c Sat, 13 Oct 2001 09:20:04 +0200 akim
@@ -99,19 +99,18 @@

 
 /* Give friendly warnings if a builtin macro is passed an
-   inappropriate number of arguments.  NAME is macro name for
-   messages, ARGC is actual number of arguments, MIN is the minimum
-   number of acceptable arguments, negative if not applicable, MAX is
-   the maximum number, negative if not applicable.  ARGC, MIN, and MAX
-   count ARGV[0], the name of the macro.  */
+   inappropriate number of arguments.  ARGC/ARGV are the arguments,
+   MIN is the minimum number of acceptable arguments, negative if not
+   applicable, MAX is the maximum number, negative if not applicable.
+   ARGC, MIN, and MAX count ARGV[0], the name of the macro.  */
 boolean
-m4_bad_argc (m4_token *token, int argc, int min, int max)
+m4_bad_argc (int argc, m4_token **argv, int min, int max)
 {
   if (min > 0 && argc < min)
     {
       M4WARN ((warning_status, 0,
               _("Warning: %s: too few arguments: %d < %d"),
-              TOKEN_TEXT (token), argc - 1, min - 1));
+              M4ARG (0), argc - 1, min - 1));
       return TRUE;
     }

@@ -119,7 +118,7 @@
     {
       M4WARN ((warning_status, 0,
               _("Warning: %s: too many arguments (ignored): %d > %d"),
-              TOKEN_TEXT (token), argc - 1, max - 1));
+              M4ARG (0), argc - 1, max - 1));
       /* Return FALSE, otherwise it is not exactly `ignored'. */
       return FALSE;
     }
Index: modules/gnu.c
--- modules/gnu.c Sat, 13 Oct 2001 08:43:17 +0200 akim
+++ modules/gnu.c Sat, 13 Oct 2001 09:23:06 +0200 akim
@@ -375,9 +375,6 @@
   int offset;                  /* current match offset */
   int length;                  /* length of first argument */

-  if (m4_bad_argc (argv[0], argc, 3, 4))
-    return;
-
   regexp = M4ARG (2);
   victim = M4ARG (1);
   length = strlen (victim);
Index: modules/m4.c
--- modules/m4.c Sat, 13 Oct 2001 09:16:36 +0200 akim
+++ modules/m4.c Sat, 13 Oct 2001 09:25:20 +0200 akim
@@ -257,11 +257,11 @@
   if (argc == 2)
     return;

-  if (m4_bad_argc (argv[0], argc, 4, -1))
+  if (m4_bad_argc (argc, argv, 4, -1))
     return;
   else
     /* Diagnose excess arguments if 5, 8, 11, etc., actual arguments.  */
-    m4_bad_argc (argv[0], (argc + 2) % 3, -1, 1);
+    m4_bad_argc ((argc + 2) % 3, argv, -1, 1);

   argv++;
   argc--;



reply via email to

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