m4-patches
[Top][All Lists]
Advanced

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

more POSIX improvements


From: Eric Blake
Subject: more POSIX improvements
Date: Fri, 12 Jan 2007 19:09:42 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

My quest to improve POSIX has been paying off.  Yesterday (my 30th birthday, no 
less), XCU ERNs 130 and 131 were approved for the next revision of POSIX: 
http://www.opengroup.org/austin/mailarchives/ag/msg10168.html.  130 dealt with 
whether we are allowed to have blind macros (ie. "decr" evaluates to `decr' 
rather than `-1', as contrasted with "decr()").  131 dealt with the behavior of 
changecom when handed empty arguments.

I'm checking this in to head, and may backport some of the doc change to the 
branch before cutting 1.4.9.  I'm still debating about adding a warning on the 
branch that $11 is deprecated, and that ${11} will be the new syntax, as 
recommended by POSIX; my first cut at adding such a warning unconditionally 
broke autoconf, so the warning would have to be a command-line selectable, plus 
I will have to fix autoconf to quit triggering the warning.  Besides the 
warning, the branch would not behave any differently, but head can actually 
start recognizing ${11}.  Ultimately, I also want stuff like ${1-default}, 
borrowing from sh syntax, so that a macro can provide a default expansion if 
the user passed an empty string.

2007-01-12  Eric Blake  <address@hidden>

        * m4/syntax.c (m4_set_comment): XCU ERN 131 was approved by
        POSIX, so update the comment.
        * doc/m4.texinfo (Inhibiting Invocation): XCU ERN 130 was
        approved by POSIX, so we can always have blind macros, even when
        POSIXLY_CORRECT.
        (Ifelse): Mention the term `blind builtin'.


Index: doc/m4.texinfo
===================================================================
RCS file: /sources/m4/m4/doc/m4.texinfo,v
retrieving revision 1.90
diff -u -r1.90 m4.texinfo
--- doc/m4.texinfo      9 Jan 2007 05:10:19 -0000       1.90
+++ doc/m4.texinfo      12 Jan 2007 19:00:30 -0000
@@ -1257,18 +1257,21 @@
 @code{m4} offers several mechanisms or techniques for inhibiting the
 recognition of names as macro calls.
 
-First of all, many builtin macros cannot meaningfully be called
-without arguments.  For any of these macros, whenever an opening
-parenthesis does not immediately follow their name, the builtin macro
-call is not triggered.  This solves the most usual cases, like for
address@hidden or @samp{eval}.  Later in this document, the sentence
-``This macro is recognized only with parameters'' refers to this
-specific provision.
-
address@hidden FIXME - The feature of blind macros is incompatible with
address@hidden @acronym{POSIX} and @comment traditional implementations.
address@hidden Should we  suppress it with the @comment @option{--traditional}
address@hidden or @option{-G} command line option?
address@hidden @acronym{GNU} extensions
address@hidden blind macro
address@hidden macro, blind
+First of all, many builtin macros cannot meaningfully be called without
+arguments.  As a @acronym{GNU} extension, for any of these macros,
+whenever an opening parenthesis does not immediately follow their name,
+the builtin macro call is not triggered.  This solves the most usual
+cases, like for @samp{include} or @samp{eval}.  Later in this document,
+the sentence ``This macro is recognized only with parameters'' refers to
+this specific provision of @acronym{GNU} M4, also known as a blind
+builtin macro.  For the builtins defined by @acronym{POSIX} that bear
+this disclaimer, @acronym{POSIX} specifically states that invoking those
+builtins without arguments is unspecified, because many other
+implementations simply invoke the builtin as though it were given one
+empty argument instead.
 
 @example
 $ @kbd{m4}
@@ -1278,16 +1281,6 @@
 @result{}1
 @end example
 
address@hidden options: -G
address@hidden xfail
address@hidden
-$ @kbd{m4 -G}
-eval
address@hidden
-eval(`1')
address@hidden
address@hidden example
-
 There is also a command line option (@option{--prefix-builtins}, or
 @option{-P}, @pxref{Operation modes, , Invoking m4}) that renames all
 builtin macros with a prefix of @samp{m4_} at startup.  The option has
@@ -2588,10 +2581,12 @@
 @result{}false
 @end example
 
address@hidden macro, blind
address@hidden blind macro
 Notice how the first argument was used unquoted; it is common to compare
 the expansion of a macro with a string.  With this macro, you can now
-reproduce the behavior of many of the builtins, where the macro is
-recognized only with arguments.
+reproduce the behavior of blind builtins, where the macro is recognized
+only with arguments.
 
 @example
 define(`foo', `ifelse(`$#', `0', ``$0'', `arguments:$#')')
Index: m4/syntax.c
===================================================================
RCS file: /sources/m4/m4/m4/syntax.c,v
retrieving revision 1.19
diff -u -r1.19 syntax.c
--- m4/syntax.c 23 Dec 2006 00:02:20 -0000      1.19
+++ m4/syntax.c 12 Jan 2007 19:00:30 -0000
@@ -1,6 +1,6 @@
 /* GNU m4 -- A simple macro processor
-   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2002, 2004, 2006 Free
-   Software Foundation, Inc.
+   Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 2002, 2004, 2006, 2007
+   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
@@ -611,13 +611,13 @@
   free (syntax->bcomm.string);
   free (syntax->ecomm.string);
 
-  /* POSIX requires no arguments to disable comments.  It requires
-     empty arguments to be used as-is, but this is counter to
-     traditional behavior, because a non-null begin and null end makes
-     it impossible to end a comment.  An aardvark has been filed:
-     http://www.opengroup.org/austin/mailarchives/ag-review/msg02168.html
-     This implementation assumes the aardvark will be approved.  See
-     the texinfo for what some other implementations do.  */
+  /* POSIX requires no arguments to disable comments, and that one
+     argument use newline as the close-comment.  POSIX XCU ERN 131
+     states that empty arguments invoke implementation-defined
+     behavior.  We allow an empty begin comment to disable comments,
+     and a non-empty begin comment will always create a non-empty end
+     comment.  See the texinfo for what some other implementations
+     do.  */
   if (!bc)
     bc = ec = "";
   else if (!ec || (*bc && !*ec))






reply via email to

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