autoconf-commit
[Top][All Lists]
Advanced

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

[SCM] GNU Autoconf source repository branch, master, updated. v2.63-231-


From: Eric Blake
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.63-231-g580ada8
Date: Tue, 25 Nov 2008 16:38:44 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Autoconf source repository".

http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=580ada8c2e37468e1a896003bdd15b39f6dd4452

The branch, master has been updated
       via  580ada8c2e37468e1a896003bdd15b39f6dd4452 (commit)
       via  fb70cde184087a6abc547629aa3ecb771b7a4e87 (commit)
      from  b74085770f3517505ab6d35bfca7157ba93fa9e8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 580ada8c2e37468e1a896003bdd15b39f6dd4452
Author: Eric Blake <address@hidden>
Date:   Tue Nov 25 09:28:43 2008 -0700

    Add m4_cleardivert.
    
    * lib/m4sugar/m4sugar.m4 (m4_cleardivert): New macro.
    * lib/autotest/general.m4 (AT_INIT): Use it.
    * lib/autoconf/general.m4 (_AC_INIT_NOTICE): Likewise.
    * tests/m4sugar.at (m4@&address@hidden): Test it.
    * doc/autoconf.texi (Diversion support) <m4_cleardivert>: Document
    it.
    * NEWS: Likewise.
    Suggested by Paolo Bonzini.
    
    Signed-off-by: Eric Blake <address@hidden>

commit fb70cde184087a6abc547629aa3ecb771b7a4e87
Author: Eric Blake <address@hidden>
Date:   Mon Nov 24 13:52:01 2008 -0700

    Add safety check for m4_expand vs. diversions.
    
    * lib/m4sugar/m4sugar.m4 (m4_expand): Make more robust against
    diverted text.
    * doc/autoconf.texi (Evaluation Macros) <m4_expand>: Document new
    safety check.
    
    Signed-off-by: Eric Blake <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog               |   18 ++++++++++++++++++
 NEWS                    |   10 +++++-----
 doc/autoconf.texi       |   40 ++++++++++++++++++++++++++++++++++++++--
 lib/autoconf/general.m4 |    4 ++--
 lib/autotest/general.m4 |   10 +++++-----
 lib/m4sugar/m4sugar.m4  |   34 ++++++++++++++++++++++++++++++----
 tests/m4sugar.at        |   13 ++++++++++++-
 7 files changed, 110 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c6c7109..34dc21d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2008-11-25  Eric Blake  <address@hidden>
+
+       Add m4_cleardivert.
+       * lib/m4sugar/m4sugar.m4 (m4_cleardivert): New macro.
+       * lib/autotest/general.m4 (AT_INIT): Use it.
+       * lib/autoconf/general.m4 (_AC_INIT_NOTICE): Likewise.
+       * tests/m4sugar.at (m4@&address@hidden): Test it.
+       * doc/autoconf.texi (Diversion support) <m4_cleardivert>: Document
+       it.
+       * NEWS: Likewise.
+       Suggested by Paolo Bonzini.
+
+       Add safety check for m4_expand vs. diversions.
+       * lib/m4sugar/m4sugar.m4 (m4_expand): Make more robust against
+       diverted text.
+       * doc/autoconf.texi (Evaluation Macros) <m4_expand>: Document new
+       safety check.
+
 2008-11-24  Eric Blake  <address@hidden>
 
        Fix typo in AS_MESSAGE_LOG_FD patch.
diff --git a/NEWS b/NEWS
index 3edc6bc..86bf8d5 100644
--- a/NEWS
+++ b/NEWS
@@ -93,11 +93,11 @@ GNU Autoconf NEWS - User visible changes.
    allowing the output of unbalanced parentheses in more contexts.
 
 ** The following m4sugar macros are new:
-   m4_joinall  m4_mapall  m4_mapall_sep  m4_reverse  m4_set_add
-   m4_set_add_all  m4_set_contains  m4_set_contents  m4_set_delete
-   m4_set_difference  m4_set_dump  m4_set_empty  m4_set_foreach
-   m4_set_intersection  m4_set_list  m4_set_listc  m4_set_remove
-   m4_set_size  m4_set_union
+   m4_cleardivert  m4_joinall  m4_mapall  m4_mapall_sep  m4_reverse
+   m4_set_add  m4_set_add_all  m4_set_contains  m4_set_contents
+   m4_set_delete  m4_set_difference  m4_set_dump  m4_set_empty
+   m4_set_foreach  m4_set_intersection  m4_set_list  m4_set_listc
+   m4_set_remove  m4_set_size  m4_set_union
 
 ** The following m4sugar macros now accept multiple arguments, as is the
    case with underlying m4:
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 957b8be..1decd4b 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10725,10 +10725,37 @@ dubious syntactic constructs, incorrectly ordered 
macro calls.
 M4sugar makes heavy use of diversions, because it is often the case that
 text that must appear early in the output is not discovered until late
 in the input.  Additionally, some of the topological sorting algorithms
-used in resolving macro dependencies use diversions.  Therefore, most
+used in resolving macro dependencies use diversions.  However, most
 macros should not need to change diversions directly, but rather rely on
 higher-level M4sugar macros to manage diversions transparently.
 
+In the rare case that it is necessary to write a macro that explicitly
+outputs text to a different diversion, it is important to be aware of an
+M4 limitation regarding diversions: text only goes to a diversion if it
+is not part of argument collection.  Therefore, any macro that changes
+the current diversion cannot be used as an unquoted argument to another
+macro, but must be expanded at the top level.  The macro
address@hidden will diagnose any attempt to change diversions, since
+it is generally useful only as an argument to another macro.  The
+following example shows what happens when diversion manipulation is
+attempted within macro arguments:
+
address@hidden
+m4_do([normal text]
+m4_divert_push([KILL])unwanted[]m4_divert_pop([KILL])
+[m4_divert_push([KILL])discarded[]m4_divert_pop([KILL])])dnl
address@hidden text
address@hidden
address@hidden example
+
address@hidden
+Notice that the unquoted text @code{unwanted} is output, even though it
+was processed while the current diversion was @code{KILL}, because it
+was collected as part of the argument to @code{m4_do}.  However, the
+text @code{discarded} disappeared as desired, because the diversion
+changes were single-quoted, and were not expanded until the top-level
+rescan of the output of @code{m4_do}.
+
 To make diversion management easier, M4sugar uses the concept of named
 diversions.  Rather than using diversion numbers directly, it is nicer
 to associate a name with each diversion; the diversion number associated
@@ -10788,6 +10815,12 @@ remaining diversions of Autotest, are not documented.  
In other words,
 intentionally outputting text into an undocumented diversion is subject
 to breakage in a future release of Autoconf.
 
address@hidden m4_cleardivert (@address@hidden)
address@hidden
+Permanently discard any text that has been diverted into
address@hidden
address@hidden defmac
+
 @defmac m4_divert_once (@var{diversion}, @ovar{content})
 @msindex{divert_once}
 Similar to @code{m4_divert_text}, except that @var{content} is only
@@ -11295,7 +11328,10 @@ whitespace is preserved, even after the expansion of 
macros contained in
 @var{arg}.  Additionally, @code{m4_expand} is able to expand text that
 would involve an unterminated comment, whereas expanding that same text
 as the argument to @code{m4_quote} runs into difficulty in finding the
-end of the argument.
+end of the argument.  Since manipulating diversions during argument
+collection is inherently unsafe, @code{m4_expand} issues an error if
address@hidden attempts to change the current diversion (@pxref{Diversion
+support}).
 
 @example
 m4_define([active], [ACT, IVE])dnl
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 50b6eae..bcf8720 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -344,8 +344,8 @@ m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])
 # ---------------
 # Provide useful headers; override the HEADER-COMMENT created by M4sh.
 m4_define([_AC_INIT_NOTICE],
-[m4_divert_text([KILL], [m4_undivert([HEADER-COMMENT])])dnl
-m4_divert_text([HEADER-COMMENT],
+[m4_cleardivert([HEADER-COMMENT])]dnl
+[m4_divert_text([HEADER-COMMENT],
 address@hidden:@ Guess values for system-dependent variables and create 
Makefiles.
 @%:@ Generated by m4_PACKAGE_STRING[]dnl
 m4_ifset([AC_PACKAGE_STRING], [ for AC_PACKAGE_STRING]).])
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index f391503..3462cc0 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -216,13 +216,13 @@ m4_define([AT_INIT],
 [m4_define([AT_help_all], [])]
 [m4_map_args([_m4_popdef], _AT_DEFINE_INIT_LIST)]
 [m4_wrap([_AT_FINISH])]
-[AS_INIT[]dnl
+[AS_INIT[]]dnl
 dnl We don't use m4sh's BODY diversion, but AS_INIT sticks a banner there.
 dnl This trick removes that banner, since it adds nothing to autotest.
-m4_divert_text([KILL], [m4_undivert([BODY])])dnl
-AS_ME_PREPARE[]dnl
-m4_divert_push([DEFAULTS])dnl
-AT_COPYRIGHT(
+[m4_cleardivert([BODY])]dnl
+[AS_ME_PREPARE[]]dnl
+[m4_divert_push([DEFAULTS])]dnl
+[AT_COPYRIGHT(
 [Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 Free Software Foundation, Inc.
 This test suite is free software; the Free Software Foundation gives
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index fd443ca..e3b712a 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -832,8 +832,11 @@ m4_define([m4_echo], address@hidden)
 # this), and should not contain the unlikely delimiters -=<{( or
 # )}>=-.  It is possible to have unbalanced quoted `(' or `)', as well
 # as unbalanced unquoted `)'.  m4_expand can handle unterminated
-# comments or dnl on the final line, at the expense of speed, while
-# _m4_expand is faster but must be given a terminated expansion.
+# comments or dnl on the final line, at the expense of speed; it also
+# aids in detecting attempts to incorrectly change the current
+# diversion inside ARG.  Meanwhile, _m4_expand is faster but must be
+# given a terminated expansion, and has no safety checks for
+# mis-diverted text.
 #
 # Exploit that extra unquoted () will group unquoted commas and the
 # following whitespace.  m4_bpatsubst can't handle newlines inside $1,
@@ -848,8 +851,11 @@ m4_define([m4_echo], address@hidden)
 # this time with one more `(' in the second argument and in the
 # open-quote delimiter.  We must also ignore the slop from the
 # previous try.  The final macro is thus half line-noise, half art.
-m4_define([m4_expand], [m4_chomp(_$0([$1
-]))])
+m4_define([m4_expand],
+[m4_pushdef([m4_divert], _m4_defn([_m4_divert_unsafe]))]dnl
+[m4_pushdef([m4_divert_push], _m4_defn([_m4_divert_unsafe]))]dnl
+[m4_chomp(_$0([$1
+]))_m4_popdef([m4_divert], [m4_divert_push])])
 
 m4_define([_m4_expand], [$0_([$1], [(], -=<{($1)}>=-, [}>=-])])
 
@@ -1295,6 +1301,17 @@ m4_define([_m4_stack_reverse],
 ## --------------------------- ##
 
 
+# m4_cleardivert(DIVERSION-NAME...)
+# ---------------------------------
+# Discard any text in DIVERSION-NAME.
+#
+# This works even inside m4_expand.
+m4_define([m4_cleardivert],
+[m4_if([$#], [0], [m4_fatal([$0: missing argument])],
+       [m4_builtin([divert], [-1])m4_undivert($@)m4_builtin([divert],
+        _m4_divert(_m4_defn([_m4_divert_diversion])))])])
+
+
 # _m4_divert(DIVERSION-NAME or NUMBER)
 # ------------------------------------
 # If DIVERSION-NAME is the name of a diversion, return its number,
@@ -1380,6 +1397,15 @@ m4_define([m4_divert_once],
 [m4_expand_once([m4_divert_text([$1], [$2])])])
 
 
+# _m4_divert_unsafe(DIVERSION-NAME)
+# ---------------------------------
+# Issue a warning that the attempt to change the current diversion to
+# DIVERSION-NAME is unsafe, because this macro is being expanded
+# during argument collection of m4_expand.
+m4_define([_m4_divert_unsafe],
+[m4_fatal([$0: cannot change diversion to `$1' inside m4_expand])])
+
+
 # m4_undivert(DIVERSION-NAME...)
 # ------------------------------
 # Undivert DIVERSION-NAME.  Unlike the M4 version, this requires at
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 4bdc06c..36787fc 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -248,7 +248,7 @@ AT_CLEANUP
 
 AT_SETUP([m4@&address@hidden)
 AT_KEYWORDS([m4@&address@hidden m4@&address@hidden m4@&address@hidden
-m4@&address@hidden)
+m4@&address@hidden m4@&address@hidden m4@&address@hidden)
 
 AT_CHECK_M4SUGAR_TEXT([[1.m4_divert_stack
 m4_divert_push([10])2.m4_divert_stack
@@ -272,6 +272,17 @@ script.4s:2: m4@&address@hidden: 0
 script.4s:1: m4@&address@hidden: KILL
 ]])
 
+AT_CHECK_M4SUGAR_TEXT([[dnl
+m4_divert_text([3], [three])dnl
+m4_divert_text([4], [four])dnl
+m4_divert_text([1], [one])dnl
+m4_divert_text([2], [two])dnl
+m4_cleardivert([2], [3])dnl
+]],
+[[one
+four
+]])
+
 AT_DATA_M4SUGAR([script.4s],
 [[m4_divert_pop
 ]])


hooks/post-receive
--
GNU Autoconf source repository




reply via email to

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