bug-m4
[Top][All Lists]
Advanced

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

branch-1_4 debian bug 96075 - blind macros


From: Eric Blake
Subject: branch-1_4 debian bug 96075 - blind macros
Date: Mon, 31 Jul 2006 07:19:36 -0600
User-agent: Thunderbird 1.5.0.5 (Windows/20060719)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=96075 complains:

> "format", "divert" and "shift" are all English words that
> might occur in text.  And they are all recognised without
> arguments - the default behaviour of m4 is to make these
> words disappear

format is a GNU extension, and as such, I already made it blind (along
with indir) in m4 1.4.5.

divert is required by POSIX to accept 0 arguments as shorthand for
divert(0).  The best I can do is to document this; however, I did add
words to the 1.4.5 documentation to the effect that you can make any macro
blind by yourself:
define(`divert', `ifelse(`$#', `0', ``$0'', `builtin(`$0', $@)')')

You can also use the -P/--prefix-builtins command line option to put all
builtins in the m4_ namespace, so they don't clash with English
words/shell keywords.

That leaves shift.  I previously asked whether this should be changed now
or wait for m4 2.0, and the decision for 1.4.5 was to leave status quo
alone: http://lists.gnu.org/archive/html/bug-m4/2006-07/msg00002.html

However, this patch will do what you request (as well as for errprint and
m4wrap).  I will need some feedback before applying this patch to 1.4.6;
otherwise, you will have to wait for m4 2.0.  Plus I would need to
document the change in the .texinfo and NEWS.

2006-07-31  Eric Blake  <address@hidden>

        * src/builtin.c (m4_errprint, m4_m4wrap, m4_shift): Make blind,
        per debian bug 96075.
        * doc/m4.texinfo (Loops): Adjust test accordingly.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEzgNn84KuGfSFAYARAmxNAJ9ksrlDnL6J72lyMQOvnZeU1ZZEgQCgyzKW
THIJsqWIoo2rKuScUicT2r0=
=LJ8n
-----END PGP SIGNATURE-----
Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.1.1.1.2.56
diff -u -p -r1.1.1.1.2.56 m4.texinfo
--- doc/m4.texinfo      30 Jul 2006 21:46:10 -0000      1.1.1.1.2.56
+++ doc/m4.texinfo      31 Jul 2006 13:15:21 -0000
@@ -1842,7 +1842,7 @@ argument, separated by commas, with each
 
 @example
 shift
address@hidden
address@hidden
 shift(`bar')
 @result{}
 shift(`foo', `bar', `baz')
Index: src/builtin.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/builtin.c,v
retrieving revision 1.1.1.1.2.30
diff -u -p -r1.1.1.1.2.30 builtin.c
--- src/builtin.c       30 Jul 2006 23:46:51 -0000      1.1.1.1.2.30
+++ src/builtin.c       31 Jul 2006 13:15:21 -0000
@@ -112,7 +112,7 @@ builtin_tab[] =
   { "divnum",          FALSE,  FALSE,  FALSE,  m4_divnum },
   { "dnl",             FALSE,  FALSE,  FALSE,  m4_dnl },
   { "dumpdef",         FALSE,  FALSE,  FALSE,  m4_dumpdef },
-  { "errprint",                FALSE,  FALSE,  FALSE,  m4_errprint },
+  { "errprint",                FALSE,  FALSE,  TRUE,   m4_errprint },
   { "esyscmd",         TRUE,   FALSE,  TRUE,   m4_esyscmd },
   { "eval",            FALSE,  FALSE,  TRUE,   m4_eval },
   { "format",          TRUE,   FALSE,  TRUE,   m4_format },
@@ -124,13 +124,13 @@ builtin_tab[] =
   { "indir",           TRUE,   FALSE,  TRUE,   m4_indir },
   { "len",             FALSE,  FALSE,  TRUE,   m4_len },
   { "m4exit",          FALSE,  FALSE,  FALSE,  m4_m4exit },
-  { "m4wrap",          FALSE,  FALSE,  FALSE,  m4_m4wrap },
+  { "m4wrap",          FALSE,  FALSE,  TRUE,   m4_m4wrap },
   { "maketemp",                FALSE,  FALSE,  TRUE,   m4_maketemp },
   { "patsubst",                TRUE,   FALSE,  TRUE,   m4_patsubst },
   { "popdef",          FALSE,  FALSE,  TRUE,   m4_popdef },
   { "pushdef",         FALSE,  TRUE,   TRUE,   m4_pushdef },
   { "regexp",          TRUE,   FALSE,  TRUE,   m4_regexp },
-  { "shift",           FALSE,  FALSE,  FALSE,  m4_shift },
+  { "shift",           FALSE,  FALSE,  TRUE,   m4_shift },
   { "sinclude",                FALSE,  FALSE,  TRUE,   m4_sinclude },
   { "substr",          FALSE,  FALSE,  TRUE,   m4_substr },
   { "syscmd",          FALSE,  FALSE,  TRUE,   m4_syscmd },
@@ -1088,6 +1088,8 @@ m4_dnl (struct obstack *obs, int argc, t
 static void
 m4_shift (struct obstack *obs, int argc, token_data **argv)
 {
+  if (bad_argc (argv[0], argc, 2, -1))
+    return;
   dump_args (obs, argc - 1, argv + 1, ",", TRUE);
 }
 
@@ -1223,8 +1225,11 @@ m4_maketemp (struct obstack *obs, int ar
 static void
 m4_errprint (struct obstack *obs, int argc, token_data **argv)
 {
+  if (bad_argc (argv[0], argc, 2, -1))
+    return;
   dump_args (obs, argc, argv, " ", FALSE);
   obstack_1grow (obs, '\0');
+  debug_flush_files ();
   fprintf (stderr, "%s", (char *) obstack_finish (obs));
   fflush (stderr);
 }
@@ -1294,6 +1299,8 @@ m4_m4exit (struct obstack *obs, int argc
 static void
 m4_m4wrap (struct obstack *obs, int argc, token_data **argv)
 {
+  if (bad_argc (argv[0], argc, 2, -1))
+    return;
   if (no_gnu_extensions)
     obstack_grow (obs, ARG (1), strlen (ARG (1)));
   else

reply via email to

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