m4-patches
[Top][All Lists]
Advanced

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

18-location-eof.patch


From: Akim Demaille
Subject: 18-location-eof.patch
Date: Thu, 18 Oct 2001 23:30:46 +0200

Something I always wanted in M4.

errprint()
errprint(






NONE:0: /usr/bin/m4: ERROR: EOF in argument list

lt-m4: /tmp/foo.m4:2: EOF in argument list


I must say I don't understand the weird trick we do with
error_print_program instead of good old calls to error and
error_at_line.  In addition, I don't understand why M4ERROR wraps
error.  It's more a burden than an actual help: it is in capitals
(eek), and requires more characters than a plain error with a single
() pair.

I also don't understand why we shout ERROR before errors.  After all
those are errors on which we die, I fail to see the point of dying so
loudly.



Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * m4/macro.c (expand_argument): Display where was opened what is
        not closed.

Index: m4/macro.c
--- m4/macro.c Sat, 13 Oct 2001 12:59:48 +0200 akim
+++ m4/macro.c Thu, 18 Oct 2001 23:09:00 +0200 akim
@@ -1,5 +1,6 @@
 /* GNU m4 -- A simple macro processor
-   Copyright 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+   Copyright 1989, 1990, 1991, 1992, 1993, 1994, 2001
+   Free Software Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -110,7 +111,9 @@
   m4_token_t t;
   m4_token td;
   char *text;
-  int paren_level;
+  int paren_level = 0;
+  const char *current_file = m4_current_file;
+  int current_line = m4_current_line;

   TOKEN_TYPE (argp) = M4_TOKEN_VOID;

@@ -121,16 +124,13 @@
     }
   while (t == M4_TOKEN_SPACE);

-  paren_level = 0;
-
   while (1)
     {
-
       switch (t)
        {                       /* TOKSW */
        case M4_TOKEN_SIMPLE:
          text = TOKEN_TEXT (&td);
-         if ((M4_IS_COMMA(*text) || M4_IS_CLOSE(*text)) && paren_level == 0)
+         if ((M4_IS_COMMA (*text) || M4_IS_CLOSE (*text)) && paren_level == 0)
            {

              /* The argument MUST be finished, whether we want it or not.  */
@@ -142,19 +142,19 @@
                  TOKEN_TYPE (argp) = M4_TOKEN_TEXT;
                  TOKEN_TEXT (argp) = text;
                }
-             return (boolean) (M4_IS_COMMA(*TOKEN_TEXT (&td)));
+             return (boolean) (M4_IS_COMMA (*TOKEN_TEXT (&td)));
            }

-         if (M4_IS_OPEN(*text))
+         if (M4_IS_OPEN (*text))
            paren_level++;
-         else if (M4_IS_CLOSE(*text))
+         else if (M4_IS_CLOSE (*text))
            paren_level--;
          expand_token (obs, t, &td);
          break;

        case M4_TOKEN_EOF:
-         M4ERROR ((EXIT_FAILURE, 0,
-                   _("ERROR: EOF in argument list")));
+         error_at_line (EXIT_FAILURE, 0, current_file, current_line,
+                        _("EOF in argument list"));
          break;

        case M4_TOKEN_WORD:



reply via email to

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