m4-patches
[Top][All Lists]
Advanced

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

13-m4-undivert-culprit.patch


From: Akim Demaille
Subject: 13-m4-undivert-culprit.patch
Date: Mon, 20 Aug 2001 17:43:00 +0200

I was wondering why the Autoconf test suite started failing with
Libtool (thanks God for foreign.at...  BTW, Gary, I'd be happy if you
could peek at this Autoconf test file, and strengthen it if needed).

undivert was complaining in an obscure way.  With this patch, I now
prefer working with CVS M4 over 1.4 with Autoconf :)

testsuite.log:
@@ -0,0 +1,3 @@
+/usr/local/bin/m4: configure.in: 3401: Non-numeric argument to `divert': NOTICE
+/usr/local/bin/m4: configure.in: 3401: Non-numeric argument to `divert': NOTICE
+/usr/local/bin/m4: configure.in: 3401: Non-numeric argument to `divert': NOTICE

Aaaarg :(  Yet it starts again: people use internals without asking.

I understand there can be needs we don't fulfilf, but you have to tell
us.  I would have provided Libtool with a _macro_, definitely not a
diversion name.

Anyway, now that I see what it is used for, it is clear to me that
pseudo `echo' is something that M4sh must provide (and as a matter of
fact I had removed NOTICE precisely to introduce M4SH-INIT, a very
early diversion used by M4sh to output its initialization stuff before
Autoconf's).  So that diversion name will no longer be needed.  And I
guess there are many other sh idioms to move from Libtool to M4sh.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * m4/utility.c (m4_numeric_arg): Spell out the culprit.
        * modules/m4.c (undivert): Disable the possibility of undiverting
        several files at once: it is not documented, it is inconsistent
        with the other macros, it can be straightforwardly mocked by
        several invocations, and most importantly, it prevents the
        possibility of other kinds of extension.
        Use `m4_numeric_arg'.

Index: m4/utility.c
--- m4/utility.c Fri, 10 Aug 2001 14:01:13 +0200 akim
+++ m4/utility.c Sun, 19 Aug 2001 10:53:33 +0200 akim
@@ -168,12 +168,12 @@
 {
   char *endp;

-  if (*arg == 0 || (*valuep = strtol (m4_skip_space(arg), &endp, 10),
-                   *m4_skip_space(endp) != 0))
+  if (*arg == 0 || (*valuep = strtol (m4_skip_space (arg), &endp, 10),
+                   *m4_skip_space (endp) != 0))
     {
       M4ERROR ((warning_status, 0,
-               _("Non-numeric argument to builtin `%s'"),
-               M4_TOKEN_DATA_TEXT (macro)));
+               _("Non-numeric argument to `%s': %s"),
+               M4_TOKEN_DATA_TEXT (macro), arg));
       return FALSE;
     }
   return TRUE;
@@ -319,4 +319,3 @@
   obstack_finish (data->obs);
   qsort ((char *) data->base, data->size, sizeof (m4_symbol *), dumpdef_cmp);
 }
-
Index: modules/m4.c
--- modules/m4.c Sat, 18 Aug 2001 10:08:06 +0200 akim
+++ modules/m4.c Sun, 19 Aug 2001 10:52:09 +0200 akim
@@ -450,42 +450,38 @@
   m4_shipout_int (obs, m4_current_diversion);
 }

-/*-----------------------------------------------------------------------.
-| Bring back the diversion given by the argument list.  If none is      |
-| specified, bring back all diversions.  GNU specific is the option of  |
-| undiverting named files, by passing a non-numeric argument to undivert |
-| ().                                                                   |
-`-----------------------------------------------------------------------*/
+/*------------------------------------------------------------------.
+| Bring back the diversion given by the argument list.  If none is  |
+| specified, bring back all diversions.  GNU specific is the option |
+| of undiverting the named file, by passing a non-numeric argument  |
+| to undivert ().                                                   |
+`------------------------------------------------------------------*/

 M4BUILTIN_HANDLER (undivert)
 {
-  int i, file;
-  FILE *fp;
+  int i = 0;

   if (argc == 1)
     m4_undivert_all ();
   else
-    for (i = 1; i < argc; i++)
-      {
-       if (sscanf (M4ARG (i), "%d", &file) == 1)
-         m4_insert_diversion (file);
-       else if (no_gnu_extensions)
-         M4ERROR ((warning_status, 0,
-                   _("Non-numeric argument to %s"),
-                   M4_TOKEN_DATA_TEXT (argv[0])));
-       else
-         {
-           fp = m4_path_search (M4ARG (i), (char **)NULL);
-           if (fp != NULL)
-             {
-               m4_insert_file (fp);
-               fclose (fp);
-             }
-           else
-             M4ERROR ((warning_status, errno,
-                       _("Cannot undivert %s"), M4ARG (i)));
-         }
-      }
+    {
+      if (sscanf (M4ARG (1), "%d", &i) == 1)
+       m4_insert_diversion (i);
+      else if (no_gnu_extensions)
+       m4_numeric_arg (argv[0], M4ARG (1), &i);
+      else
+       {
+         FILE *fp = m4_path_search (M4ARG (1), (char **) NULL);
+         if (fp != NULL)
+           {
+             m4_insert_file (fp);
+             fclose (fp);
+           }
+         else
+           M4ERROR ((warning_status, errno,
+                     _("Cannot undivert %s"), M4ARG (1)));
+       }
+    }
 }

 



reply via email to

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