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.62-48-g


From: Eric Blake
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.62-48-g36d8106
Date: Sat, 19 Jul 2008 19:40:19 +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=36d8106f6dadede2d202cc1a71cb7dbbd7924fc9

The branch, master has been updated
       via  36d8106f6dadede2d202cc1a71cb7dbbd7924fc9 (commit)
       via  8c938c72f01272d23a5b7f110b8c0c0abbdf20f6 (commit)
       via  434bdc105b409a017f572b1cf882466ba8a6a58c (commit)
       via  65ff0e8f8876e4b4e354c8b23fba1b6e2c077689 (commit)
      from  6d04538831ab9e02826bbb951de43ff62ccd72e6 (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 36d8106f6dadede2d202cc1a71cb7dbbd7924fc9
Author: Eric Blake <address@hidden>
Date:   Fri Jul 18 14:26:41 2008 -0600

    Support multiple arguments to m4_defn, m4_popdef, and m4_undefine.
    
    * lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Loop
    through all variables, per POSIX and newer m4.
    (_m4_text_wrap): Exploit the looping capabilities.
    * tests/m4sugar.at (m4@&address@hidden): Test this.
    * NEWS: Document it.
    * doc/autoconf.texi (Redefined M4 Macros) <m4_defn, m4_popdef>
    <m4_undefine>: Likewise.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 8c938c72f01272d23a5b7f110b8c0c0abbdf20f6
Author: Eric Blake <address@hidden>
Date:   Sat Jul 19 10:53:10 2008 -0600

    Reduce overhead of m4_builtin([defn]).
    
    * lib/m4sugar/m4sugar.m4 (_m4_defn, _m4_popdef, _m4_undefine): New
    internal macros, which are slightly more efficient than
    m4_builtin([defn]) and company.
    (m4_defn, m4_popdef, m4_undefine, m4_warn, m4_ifset)
    (_m4_dumpdefs_up, _m4_dumpdefs_down, _m4_wrap, m4_for)
    (_m4_divert_n_stack, m4_divert_pop, m4_expansion_stack_push)
    (m4_expansion_stack_dump, _m4_defun_pro, _m4_defun_epi)
    (_m4_defun_epi_outer, _m4_require_call, m4_combine, m4_append)
    (_m4_append_uniq, m4_append_uniq_w, _m4_text_wrap, m4_text_box)
    (m4_version_prereq): Use them.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 434bdc105b409a017f572b1cf882466ba8a6a58c
Author: Eric Blake <address@hidden>
Date:   Fri Jul 18 12:05:43 2008 -0600

    Use warnings from m4 when available.
    
    * lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Don't
    define slower wrapper if m4 will warn on our behalf; key off of
    __m4_version__, added alongside the new warnings in m4 1.6.
    * tests/m4sugar.at (m4@&address@hidden): New test.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 65ff0e8f8876e4b4e354c8b23fba1b6e2c077689
Author: Eric Blake <address@hidden>
Date:   Fri Jul 18 08:30:07 2008 -0600

    Add m4_joinall.
    
    * lib/m4sugar/m4sugar.m4 (m4_joinall, _m4_joinall): New macros.
    * tests/m4sugar.at (m4@&address@hidden): Test them.
    * doc/autoconf.texi (Text processing Macros) <m4_join>: Document
    m4_joinall.
    * NEWS: Likewise.
    
    Signed-off-by: Eric Blake <address@hidden>

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

Summary of changes:
 ChangeLog              |   38 +++++++++++
 NEWS                   |    7 ++
 doc/autoconf.texi      |   40 +++++++-----
 lib/m4sugar/m4sugar.m4 |  163 +++++++++++++++++++++++++++---------------------
 tests/m4sugar.at       |   55 ++++++++++++++++
 5 files changed, 215 insertions(+), 88 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index da65cc7..47c73b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+2008-07-19  Eric Blake  <address@hidden>
+
+       Support multiple arguments to m4_defn, m4_popdef, and m4_undefine.
+       * lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Loop
+       through all variables, per POSIX and newer m4.
+       (_m4_text_wrap): Exploit the looping capabilities.
+       * tests/m4sugar.at (m4@&address@hidden): Test this.
+       * NEWS: Document it.
+       * doc/autoconf.texi (Redefined M4 Macros) <m4_defn, m4_popdef>
+       <m4_undefine>: Likewise.
+
+       Reduce overhead of m4_builtin([defn]).
+       * lib/m4sugar/m4sugar.m4 (_m4_defn, _m4_popdef, _m4_undefine): New
+       internal macros, which are slightly more efficient than
+       m4_builtin([defn]) and company.
+       (m4_defn, m4_popdef, m4_undefine, m4_warn, m4_ifset)
+       (_m4_dumpdefs_up, _m4_dumpdefs_down, _m4_wrap, m4_for)
+       (_m4_divert_n_stack, m4_divert_pop, m4_expansion_stack_push)
+       (m4_expansion_stack_dump, _m4_defun_pro, _m4_defun_epi)
+       (_m4_defun_epi_outer, _m4_require_call, m4_combine, m4_append)
+       (_m4_append_uniq, m4_append_uniq_w, _m4_text_wrap, m4_text_box)
+       (m4_version_prereq): Use them.
+
+       Use warnings from m4 when available.
+       * lib/m4sugar/m4sugar.m4 (m4_defn, m4_popdef, m4_undefine): Don't
+       define slower wrapper if m4 will warn on our behalf; key off of
+       __m4_version__, added alongside the new warnings in m4 1.6.
+       * tests/m4sugar.at (m4@&address@hidden): New test.
+
+2008-07-18  Eric Blake  <address@hidden>
+
+       Add m4_joinall.
+       * lib/m4sugar/m4sugar.m4 (m4_joinall, _m4_joinall): New macros.
+       * tests/m4sugar.at (m4@&address@hidden): Test them.
+       * doc/autoconf.texi (Text processing Macros) <m4_join>: Document
+       m4_joinall.
+       * NEWS: Likewise.
+
 2008-07-17  Stepan Kasal  <address@hidden>
        and Eric Blake  <address@hidden>
 
diff --git a/NEWS b/NEWS
index 06b705f..232ec86 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,13 @@ GNU Autoconf NEWS - User visible changes.
 ** Two new quadrigraphs have been introduced: @{:@ for (, and @:}@ for ),
    allowing the output of unbalanced parantheses in more contexts.
 
+** The following m4sugar macros are new:
+   m4_joinall
+
+** The following m4sugar macros now accept multiple arguments, as is the
+   case with underlying m4:
+   m4_defn  m4_popdef  m4_undefine
+
 ** AT_KEYWORDS once again performs expansion on its argument, such that
    AT_KEYWORDS([m4_if([$1], [], [default])]) no longer complains about
    the possibly unexpanded m4_if [regression introduced in 2.62].
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index bfe5c1b..efb6540 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -10323,12 +10323,14 @@ is kept for future versions of M4sugar, once 
@acronym{GNU} M4 2.0 is
 released and supports extended regular expression syntax.
 @end defmac
 
address@hidden m4_defn (@var{macro})
address@hidden m4_defn (@address@hidden)
 @msindex{defn}
-Unlike the M4 builtin, this macro fails if @var{macro} is not
-defined.  Also, while newer M4 can concatenate multiple definitions,
-this version currently only supports a single @var{macro}.  See
address@hidden
+This macro fails if @var{macro} is not defined, even when using older
+versions of M4 that did not warn.  See @code{m4_undefine}.
+Unfortunately, in order to support these older versions of M4, there are
+some situations involving unbalanced quotes where concatenating multiple
+macros together will work in newer M4 but not in m4sugar; use
+quadrigraphs to work around this.
 @end defmac
 
 @defmac m4_divert (@var{diversion})
@@ -10380,26 +10382,23 @@ and both have the secure semantics regardless of 
which macro the
 underlying M4 provides.
 @end defmac
 
address@hidden m4_popdef (@var{macro})
address@hidden m4_popdef (@address@hidden)
 @msindex{popdef}
-Unlike the M4 builtin, this macro fails if @var{macro} is not
-defined.  Also, while newer M4 can pop multiple definitions at once,
-this version currently only supports a single @var{macro}.  See
address@hidden
+This macro fails if @var{macro} is not defined, even when using older
+versions of M4 that did not warn.  See @code{m4_undefine}.
 @end defmac
 
address@hidden m4_undefine (@var{macro})
address@hidden m4_undefine (@address@hidden)
 @msindex{undefine}
-Unlike the M4 builtin, this macro fails if @var{macro} is not
-defined.  Also, while newer M4 can undefine multiple definitions at
-once, this version currently only supports a single @var{macro}.  Use
+This macro fails if @var{macro} is not defined, even when using older
+versions of M4 that did not warn.  Use
 
 @example
 m4_ifdef(address@hidden, [m4_undefine(address@hidden)])
 @end example
 
 @noindent
-to recover the behavior of the builtin.
+if you are not sure whether @var{macro} is defined.
 @end defmac
 
 @defmac m4_undivert (@var{diversion})
@@ -11163,14 +11162,19 @@ still a quoted string.
 @end defmac
 
 @defmac m4_join (@ovar{separator}, @address@hidden)
address@hidden m4_joinall (@ovar{separator}, @address@hidden)
 @msindex{join}
-Concatenate each @var{arg}, separated by @var{separator}, with the
-exception that no back-to-back separators are issued for empty
-arguments.  The result is a quoted string.
address@hidden
+Concatenate each @var{arg}, separated by @var{separator}.
address@hidden uses every argument, while @code{join} omits empty
+arguments so that there are no back-to-back separators in the output.
+The result is a quoted string.
 @example
 m4_define([active], [ACTIVE])dnl
 m4_join([|], [one], [], [active], [two])
 @result{}one|active|two
+m4_joinall([|], [one], [], [active], [two])
address@hidden||active|two
 @end example
 
 Note that if all you intend to do is join @var{args} with commas between
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index c6993ee..5ef7836 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -151,7 +151,7 @@ m4_undefine([maketemp])],
 [m4_rename_m4([maketemp])
 m4_copy([m4_maketemp], [m4_mkstemp])])
 m4_rename([patsubst], [m4_bpatsubst])
-m4_undefine([popdef])
+m4_rename_m4([popdef])
 m4_rename_m4([pushdef])
 m4_rename([regexp], [m4_bregexp])
 m4_rename_m4([shift])
@@ -234,7 +234,7 @@ m4_define([_m4_warn], [])
 m4_define([m4_warn],
 [_m4_warn([$1], [$2],
 m4_ifdef([m4_expansion_stack],
-        [m4_defn([m4_expansion_stack])
+        [_m4_defn([m4_expansion_stack])
 m4_location[: the top level]]))dnl
 ])
 
@@ -335,7 +335,7 @@ m4_define([m4_ifvaln],
 # expand IF-FALSE, otherwise IF-TRUE.
 m4_define([m4_ifset],
 [m4_ifdef([$1],
-         [m4_ifval(m4_defn([$1]), [$2], [$3])],
+         [m4_ifval(_m4_defn([$1]), [$2], [$3])],
          [$3])])
 
 
@@ -505,24 +505,36 @@ m4_define([m4_default],
 
 # m4_defn(NAME)
 # -------------
-# Like the original, except don't tolerate popping something which is
-# undefined, and only support one argument.
+# Like the original, except guarantee a warning when using something which is
+# undefined (unlike M4 1.4.x).  This replacement is not a full-featured
+# replacement: if any of the defined macros contain unbalanced quoting, but
+# when pasted together result in a well-quoted string, then only native m4
+# support is able to get it correct.  But that's where quadrigraphs come in
+# handy, if you really need unbalanced quotes inside your macros.
 #
 # This macro is called frequently, so minimize the amount of additional
-# expansions by skipping m4_ifndef.
-m4_define([m4_defn],
+# expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
+# (added in M4 1.6), then let m4 do the job for us.
+#
+# _m4_defn is for internal use only - it bypasses the wrapper, so it
+# must only be used on one argument at a time, and only on macros
+# known to be defined.  Make sure this still works if the user renames
+# m4_defn but not _m4_defn.
+m4_copy([m4_defn], [_m4_defn])
+m4_ifdef([__m4_version__], [],
+[m4_define([m4_defn],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[m4_builtin([defn], [$1])])
+[_m4_defn([$1])m4_if([$#], [1], [], [$0(m4_shift($@))])])])
 
 
 # _m4_dumpdefs_up(NAME)
 # ---------------------
 m4_define([_m4_dumpdefs_up],
 [m4_ifdef([$1],
-         [m4_pushdef([_m4_dumpdefs], m4_defn([$1]))dnl
+         [m4_pushdef([_m4_dumpdefs], _m4_defn([$1]))dnl
 m4_dumpdef([$1])dnl
-m4_popdef([$1])dnl
+_m4_popdef([$1])dnl
 _m4_dumpdefs_up([$1])])])
 
 
@@ -530,8 +542,8 @@ _m4_dumpdefs_up([$1])])])
 # -----------------------
 m4_define([_m4_dumpdefs_down],
 [m4_ifdef([_m4_dumpdefs],
-         [m4_pushdef([$1], m4_defn([_m4_dumpdefs]))dnl
-m4_popdef([_m4_dumpdefs])dnl
+         [m4_pushdef([$1], _m4_defn([_m4_dumpdefs]))dnl
+_m4_popdef([_m4_dumpdefs])dnl
 _m4_dumpdefs_down([$1])])])
 
 
@@ -546,15 +558,22 @@ _m4_dumpdefs_down([$1])])
 
 # m4_popdef(NAME)
 # ---------------
-# Like the original, except don't tolerate popping something which is
-# undefined, and only support one argument.
+# Like the original, except guarantee a warning when using something which is
+# undefined (unlike M4 1.4.x).
 #
 # This macro is called frequently, so minimize the amount of additional
-# expansions by skipping m4_ifndef.
-m4_define([m4_popdef],
+# expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
+# (added in M4 1.6), then let m4 do the job for us.
+#
+# _m4_popdef is for internal use only - it bypasses the wrapper, so it
+# must only be used on macros known to be defined.  Make sure this
+# still works if the user renames m4_popdef but not _m4_popdef.
+m4_copy([m4_popdef], [_m4_popdef])
+m4_ifdef([__m4_version__], [],
+[m4_define([m4_popdef],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[m4_builtin([popdef], [$1])])
+[_m4_popdef([$1])m4_if([$#], [1], [], [$0(m4_shift($@))])])])
 
 
 # m4_shiftn(N, ...)
@@ -603,26 +622,32 @@ m4_define([_m4_shift3],
 
 # m4_undefine(NAME)
 # -----------------
-# Like the original, except don't tolerate undefining something which is
-# undefined, and only support one argument.
+# Like the original, except guarantee a warning when using something which is
+# undefined (unlike M4 1.4.x).
 #
 # This macro is called frequently, so minimize the amount of additional
-# expansions by skipping m4_ifndef.
-m4_define([m4_undefine],
+# expansions by skipping m4_ifndef.  Better yet, if __m4_version__ exists,
+# (added in M4 1.6), then let m4 do the job for us.
+#
+# _m4_undefine is for internal use only - it bypasses the wrapper, so
+# it must only be used on macros known to be defined.  Make sure this
+# still works if the user renames m4_undefine but not _m4_undefine.
+m4_copy([m4_undefine], [_m4_undefine])
+m4_ifdef([__m4_version__], [],
+[m4_define([m4_undefine],
 [m4_ifdef([$1], [],
          [m4_fatal([$0: undefined macro: $1])])]dnl
-[m4_builtin([undefine], [$1])])
+[_m4_undefine([$1])m4_if([$#], [1], [], [$0(m4_shift($@))])])])
 
 # _m4_wrap(PRE, POST)
 # -------------------
 # Helper macro for m4_wrap and m4_wrap_lifo.  Allows nested calls to
-# m4_wrap within wrapped text.
-# Skip m4_defn and m4_popdef for speed.
+# m4_wrap within wrapped text.  Use _m4_defn and _m4_popdef for speed.
 m4_define([_m4_wrap],
 [m4_ifdef([$0_text],
-         [m4_define([$0_text], [$1]m4_builtin([defn], [$0_text])[$2])],
-         [m4_builtin([m4wrap], [m4_unquote(m4_builtin([defn],
-  [$0_text])m4_builtin([popdef], [$0_text]))])m4_define([$0_text], [$1$2])])])
+         [m4_define([$0_text], [$1]_m4_defn([$0_text])[$2])],
+         [m4_builtin([m4wrap], [m4_unquote(
+  _m4_defn([$0_text])_m4_popdef([$0_text]))])m4_define([$0_text], [$1$2])])])
 
 # m4_wrap(TEXT)
 # -------------
@@ -793,21 +818,21 @@ m4_define([m4_unquote], [$*])
 # Expand EXPRESSION defining VARIABLE to FROM, FROM + 1, ..., TO with
 # increments of STEP.
 # Both limits are included, and bounds are checked for consistency.
-# The algorithm is robust to indirect VARIABLE names, and uses m4_builtin
-# to avoid some of the m4_defn overhead.
+# The algorithm is robust to indirect VARIABLE names, and uses _m4_defn
+# where possible for speed.
 m4_define([m4_for],
 [m4_pushdef([$1], m4_eval([$2]))dnl
-m4_cond([m4_eval(([$3]) > m4_builtin([defn], [$1]))], 1,
+m4_cond([m4_eval(([$3]) > _m4_defn([$1]))], 1,
 [m4_pushdef([_m4_step], m4_eval(m4_default([$4], 1)))dnl
 m4_assert(_m4_step > 0)dnl
-_m4_for([$1], m4_eval((([$3]) - m4_builtin([defn], [$1]))
-                     / _m4_step * _m4_step + m4_builtin([defn], [$1])),
+_m4_for([$1], m4_eval((([$3]) - _m4_defn([$1]))
+                     / _m4_step * _m4_step + _m4_defn([$1])),
        _m4_step, [$5])],
-       [m4_eval(([$3]) < m4_builtin([defn], [$1]))], 1,
+       [m4_eval(([$3]) < _m4_defn([$1]))], 1,
 [m4_pushdef([_m4_step], m4_eval(m4_default([$4], -1)))dnl
 m4_assert(_m4_step < 0)dnl
-_m4_for([$1], m4_eval((m4_builtin([defn], [$1]) - ([$3]))
-                     / -(_m4_step) * _m4_step + m4_builtin([defn], [$1])),
+_m4_for([$1], m4_eval((_m4_defn([$1]) - ([$3]))
+                     / -(_m4_step) * _m4_step + _m4_defn([$1])),
        _m4_step, [$5])],
        [m4_pushdef([_m4_step])dnl
 $5])[]dnl
@@ -1005,7 +1030,7 @@ m4_define([_m4_divert()],                0)
 # Print m4_divert_stack with newline prepended, if it's nonempty.
 m4_define([_m4_divert_n_stack],
 [m4_ifdef([m4_divert_stack], [
-m4_defn([m4_divert_stack])])])
+_m4_defn([m4_divert_stack])])])
 
 
 # m4_divert(DIVERSION-NAME)
@@ -1042,7 +1067,7 @@ m4_popdef([m4_divert_stack])dnl
 m4_popdef([_m4_divert_diversion])dnl
 m4_builtin([divert],
           m4_ifdef([_m4_divert_diversion],
-                   [_m4_divert(m4_defn([_m4_divert_diversion]))],
+                   [_m4_divert(_m4_defn([_m4_divert_diversion]))],
                    -1))dnl
 ])
 
@@ -1354,11 +1379,10 @@ m4_define([m4_undivert],
 
 # m4_expansion_stack_push(TEXT)
 # -----------------------------
-# Use m4_builtin to avoid m4_defn overhead.
 m4_define([m4_expansion_stack_push],
 [m4_pushdef([m4_expansion_stack],
            [$1]m4_ifdef([m4_expansion_stack], [
-m4_builtin([defn], [m4_expansion_stack])]))])
+_m4_defn([m4_expansion_stack])]))])
 
 
 # m4_expansion_stack_pop
@@ -1372,7 +1396,7 @@ m4_define([m4_expansion_stack_pop],
 # Dump the expansion stack.
 m4_define([m4_expansion_stack_dump],
 [m4_ifdef([m4_expansion_stack],
-         [m4_errprintn(m4_defn([m4_expansion_stack]))])dnl
+         [m4_errprintn(_m4_defn([m4_expansion_stack]))])dnl
 m4_errprintn(m4_location[: the top level])])
 
 
@@ -1403,7 +1427,7 @@ m4_define([_m4_divert(GROW)],       10000)
 # by avoiding dnl and m4_defn overhead.
 m4_define([_m4_defun_pro],
 m4_do([[m4_ifdef([m4_expansion_stack], [], [_m4_defun_pro_outer[]])]],
-      [[m4_expansion_stack_push(m4_builtin([defn],
+      [[m4_expansion_stack_push(_m4_defn(
          [m4_location($1)])[: $1 is expanded from...])]],
       [[m4_pushdef([_m4_expanding($1)])]]))
 
@@ -1418,15 +1442,13 @@ m4_define([_m4_defun_pro_outer],
 # This is called frequently, so minimize the number of macro invocations
 # by avoiding dnl and m4_popdef overhead.
 m4_define([_m4_defun_epi],
-m4_do([[m4_builtin([popdef], [_m4_expanding($1)])]],
+m4_do([[_m4_popdef([_m4_expanding($1)])]],
       [[m4_expansion_stack_pop()]],
       [[m4_ifdef([m4_expansion_stack], [], [_m4_defun_epi_outer[]])]],
       [[m4_provide([$1])]]))
 
 m4_define([_m4_defun_epi_outer],
-m4_do([[m4_builtin([undefine], [_m4_divert_dump])]],
-      [[m4_divert_pop([GROW])]],
-      [[m4_undivert([GROW])]]))
+[_m4_undefine([_m4_divert_dump])m4_divert_pop([GROW])m4_undivert([GROW])])
 
 
 # m4_defun(NAME, EXPANSION)
@@ -1544,7 +1566,7 @@ m4_provide_if([$1],
              [],
              [m4_warn([syntax],
                       [$1 is m4_require'd but not m4_defun'd])])]],
-      [[m4_divert(m4_builtin([defn], [_m4_divert_dump]))]],
+      [[m4_divert(_m4_defn([_m4_divert_dump]))]],
       [[m4_undivert(_m4_divert_grow)]],
       [[m4_divert_pop(_m4_divert_grow)]],
       [[m4_define([_m4_divert_grow], m4_incr(_m4_divert_grow))]]))
@@ -1846,6 +1868,13 @@ m4_define([_m4_join],
 [m4_if([$#$2], [2], [],
        [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift2($@))])])
 
+# m4_joinall(SEP, ARG1, ARG2...)
+# ------------------------------
+# Produce ARG1SEPARG2...SEPARGn.  An empty ARG results in back-to-back SEP.
+# No expansion is performed on SEP or ARGs.
+m4_define([m4_joinall], [[$2]_$0([$1], m4_shift($@))])
+m4_define([_m4_joinall],
+[m4_if([$#], [2], [], [[$1$3]$0([$1], m4_shift2($@))])])
 
 # m4_combine([SEPARATOR], PREFIX-LIST, [INFIX], SUFFIX...)
 # --------------------------------------------------------
@@ -1859,20 +1888,19 @@ m4_define([_m4_join],
 #   => a-1, a-2, a-3, b-1, b-2, b-3, c-1, c-2, c-3
 #
 # In order to have the correct number of SEPARATORs, we use a temporary
-# variable that redefines itself after the first use.  We use m4_builtin
-# to avoid m4_defn overhead, but must use defn rather than overquoting
-# in case PREFIX or SUFFIX contains $1.  Likewise, we compute the m4_shift3
-# only once, rather than in each iteration of the outer m4_foreach.
+# variable that redefines itself after the first use.  We must use defn
+# rather than overquoting in case PREFIX or SUFFIX contains $1, but use
+# _m4_defn for speed.  Likewise, we compute the m4_shift3 only once,
+# rather than in each iteration of the outer m4_foreach.
 m4_define([m4_combine],
 [m4_if(m4_eval([$# > 3]), [1],
        [m4_pushdef([m4_Separator], [m4_define([m4_Separator],
-                                   m4_builtin([defn], [m4_echo]))])]]dnl
+                                   _m4_defn([m4_echo]))])]]dnl
 [[m4_foreach([m4_Prefix], [$2],
             [m4_foreach([m4_Suffix], ]m4_dquote(m4_dquote(m4_shift3($@)))[,
-                        [m4_Separator([$1])[]m4_builtin([defn],
-                                     [m4_Prefix])[$3]m4_builtin([defn],
+       [m4_Separator([$1])[]_m4_defn([m4_Prefix])[$3]_m4_defn(
                                                      [m4_Suffix])])])]]dnl
-[[m4_builtin([popdef], [m4_Separator])])])
+[[_m4_popdef([m4_Separator])])])
 
 
 # m4_append(MACRO-NAME, STRING, [SEPARATOR])
@@ -1929,10 +1957,9 @@ m4_define([m4_combine],
 # storage only occurs at the end of a macro, so the existing contents must
 # always be moved).
 #
-# Use m4_builtin to avoid overhead of m4_defn.
+# Use _m4_defn for speed.
 m4_define([m4_append],
-[m4_define([$1],
-          m4_ifdef([$1], [m4_builtin([defn], [$1])[$3]])[$2])])
+[m4_define([$1], m4_ifdef([$1], [_m4_defn([$1])[$3]])[$2])])
 
 
 # m4_append_uniq(MACRO-NAME, STRING, [SEPARATOR], [IF-UNIQ], [IF-DUP])
@@ -1951,7 +1978,7 @@ m4_define([m4_append_uniq],
                                [$0: `$2' contains `$3'])])])_$0($@)])
 m4_define([_m4_append_uniq],
 [m4_ifdef([$1],
-         [m4_if(m4_index([$3]m4_builtin([defn], [$1])[$3], [$3$2$3]), [-1],
+         [m4_if(m4_index([$3]_m4_defn([$1])[$3], [$3$2$3]), [-1],
                 [m4_append([$1], [$2], [$3])$4], [$5])],
          [m4_define([$1], [$2])$4])])
 
@@ -1960,10 +1987,10 @@ m4_define([_m4_append_uniq],
 # For each of the words in the whitespace separated list STRINGS, append
 # only the unique strings to the definition of MACRO-NAME.
 #
-# Avoid overhead of m4_defn by using m4_builtin.
+# Use _m4_defn for speed.
 m4_define([m4_append_uniq_w],
 [m4_foreach_w([m4_Word], [$2],
-             [_m4_append_uniq([$1], m4_builtin([defn], [m4_Word]), [ ])])])
+             [_m4_append_uniq([$1], _m4_defn([m4_Word]), [ ])])])
 
 
 # m4_text_wrap(STRING, [PREFIX], [FIRST-PREFIX], [WIDTH])
@@ -2009,7 +2036,7 @@ m4_define([m4_append_uniq_w],
 #
 # The algorithm uses a helper that uses $2 through $4 directly, rather than
 # using local variables, to avoid m4_defn overhead, or expansion swallowing
-# any $.  It also bypasses m4_popdef overhead with m4_builtin since no user
+# any $.  It also bypasses m4_popdef overhead with _m4_popdef since no user
 # macro expansion occurs in the meantime.  Also, the definition is written
 # with m4_do, to avoid time wasted on dnl during expansion (since this is
 # already a time-consuming macro).
@@ -2037,17 +2064,14 @@ dnl if not, insert the separator (usually a space)
 dnl either way, insert the word
 [[m4_foreach_w([m4_Word], [$1],
   [m4_define([m4_Cursor],
-            m4_eval(m4_Cursor + m4_qlen(m4_builtin([defn], [m4_Word]))
+            m4_eval(m4_Cursor + m4_qlen(_m4_defn([m4_Word]))
                     + 1))m4_if(m4_eval(m4_Cursor > ([$4])),
       [1], [m4_define([m4_Cursor],
-                     m4_eval(m4_Indent
-                             + m4_qlen(m4_builtin([defn], [m4_Word])) + 1))
+                     m4_eval(m4_Indent + m4_qlen(_m4_defn([m4_Word])) + 1))
 [$2]],
-      [m4_Separator[]])m4_builtin([defn], [m4_Word])])]],
+      [m4_Separator[]])_m4_defn([m4_Word])])]],
 dnl finally, clean up the local variabls
-[[m4_builtin([popdef], [m4_Separator])]],
-[[m4_builtin([popdef], [m4_Cursor])]],
-[[m4_builtin([popdef], [m4_Indent])]]))
+[[_m4_popdef([m4_Separator], [m4_Cursor], [m4_Indent])]]))
 
 
 # m4_text_box(MESSAGE, [FRAME-CHARACTER = `-'])
@@ -2063,8 +2087,7 @@ m4_define([m4_text_box],
                        [ ], m4_if([$2], [], [[-]], [[$2]])))dnl
 @%:@@%:@ m4_Border @%:@@%:@
 @%:@@%:@ $1 @%:@@%:@
address@hidden:@@%:@ m4_Border @%:@@%:@dnl
-m4_builtin([popdef], [m4_Border])dnl
address@hidden:@@%:@ m4_Border @%:@@%:@_m4_popdef([m4_Border])dnl
 ])
 
 
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 69cb74b..9dd953a 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -53,6 +53,47 @@ AT_CHECK_M4SUGAR([-o-],, [$2], [$3])
 # uses m4_split code.
 
 ## --------- ##
+## m4_defn.  ##
+## --------- ##
+
+AT_SETUP([m4@&address@hidden)
+
+AT_KEYWORDS([m4@&address@hidden m4@&address@hidden)
+
+# Ensure that m4sugar dies when dereferencing undefined macros, whether
+# this is provided by m4 natively or faked by wrappers in m4sugar.
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_define([good])
+m4_defn([good], [oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
+AT_CHECK([grep 'm4@&address@hidden: undefined.*oops' stderr], [0], [ignore])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_define([good])
+m4_popdef([good], [oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
+AT_CHECK([grep 'm4@&address@hidden: undefined.*oops' stderr], [0], [ignore])
+
+AT_DATA_M4SUGAR([script.4s],
+[[m4_define([good])
+m4_undefine([good], [oops])
+]])
+
+AT_CHECK_M4SUGAR([-o-], 1, [], [stderr])
+AT_CHECK([grep good stderr], [1])
+AT_CHECK([grep 'm4@&address@hidden: undefined.*oops' stderr], [0], [ignore])
+
+AT_CLEANUP
+
+
+## --------- ##
 ## m4_warn.  ##
 ## --------- ##
 
@@ -284,6 +325,8 @@ AT_CLEANUP
 
 AT_SETUP([m4@&address@hidden)
 
+AT_KEYWORDS([m4@&address@hidden)
+
 AT_CHECK_M4SUGAR_TEXT(
 [[m4_define([active], [ACTIVE])
 m4_join
@@ -297,6 +340,12 @@ m4_join([], ,,,[two])
 m4_join([], [two],,,)
 m4_join([ active ], [one], , [two])
 m4_join([], [one], [two])
+m4_joinall([-], [one], [], [two])
+m4_joinall([-], [], [], [three], [], [])
+m4_joinall([], [one], [], [two])
+m4_joinall
+m4_joinall([-])
+m4_joinall([-], [one])
 ]],
 [[
 
@@ -310,6 +359,12 @@ two
 two
 one active two
 onetwo
+one--two
+--three--
+onetwo
+
+
+one
 ]])
 
 AT_CLEANUP


hooks/post-receive
--
GNU Autoconf source repository




reply via email to

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