]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/m4sugar/m4sugar.m4 (m4_shift2, m4_shift3): New macros.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 3 Oct 2007 20:06:08 +0000 (13:06 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 3 Oct 2007 20:06:08 +0000 (13:06 -0700)
(m4_shiftn): Remove no-longer-needed optimization.  Perhaps we
should remove m4_shiftn entirely?
(m4_case, b4_bmatch, m4_map_sep, m4_bpatsubsts, m4_join):
Prefer m4_shift2 and m4_shift3 to m4_shiftn.
* lib/autoconf/lang.m4 (_AC_LANG_DISPATCH): Likewise.
* lib/m4sugar/m4sh.m4 (AS_CASE, AS_IF): Likewise.
* tests/autotest.at (AT_CHECK_AT_TEST): Likewise.

ChangeLog
lib/autoconf/lang.m4
lib/m4sugar/m4sh.m4
lib/m4sugar/m4sugar.m4
tests/autotest.at

index 8bc9ff5207bd184e8a38fae17977a2ccd553335a..d37b8b5aa5a9cd9a3b013ea42f96f281dbc4f326 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-10-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * lib/m4sugar/m4sugar.m4 (m4_shift2, m4_shift3): New macros.
+       (m4_shiftn): Remove no-longer-needed optimization.  Perhaps we
+       should remove m4_shiftn entirely?
+       (m4_case, b4_bmatch, m4_map_sep, m4_bpatsubsts, m4_join):
+       Prefer m4_shift2 and m4_shift3 to m4_shiftn.
+       * lib/autoconf/lang.m4 (_AC_LANG_DISPATCH): Likewise.
+       * lib/m4sugar/m4sh.m4 (AS_CASE, AS_IF): Likewise.
+       * tests/autotest.at (AT_CHECK_AT_TEST): Likewise.
+
 2007-10-03  Eric Blake  <ebb9@byu.net>
 
        Comment touchups.
index 6532f8697ffeca73e4c6a6005ba6a43461d392bb..b659b9feba5f73e86dd65e1c3a75b6c0e74f0579 100644 (file)
@@ -83,7 +83,7 @@ m4_define([AC_LANG_CASE],
 # unavailable.
 m4_define([_AC_LANG_DISPATCH],
 [m4_ifdef([$1($2)],
-       [m4_indir([$1($2)], m4_shiftn(2, $@))],
+       [m4_indir([$1($2)], m4_shift2($@))],
        [AC_FATAL([$1: unknown language: $2])])])
 
 
index 6f9e9a6d94abcddfacfc6be7e5b72b382521addd..682a85049ab940615dee9956a914b20ffa4bb465 100644 (file)
@@ -462,7 +462,7 @@ m4_define([_AS_CASE],
        [$#], 1, [  *) $1 ;;],
        [$#], 2, [  $1) m4_default([$2], [:]) ;;],
        [  $1) m4_default([$2], [:]) ;;
-$0(m4_shiftn(2, $@))])dnl
+$0(m4_shift2($@))])dnl
 ])
 m4_defun([AS_CASE],
 [m4_ifval([$2$3],
@@ -504,7 +504,7 @@ m4_define([_AS_IF],
 [m4_ifval([$2$3],
 [elif $1; then
   m4_default([$2], [:])
-m4_ifval([$3], [$0(m4_shiftn(2, $@))])],
+m4_ifval([$3], [$0(m4_shift2($@))])],
 [m4_ifvaln([$1],
 [else
   $1])dnl
@@ -514,7 +514,7 @@ m4_defun([AS_IF],
 [m4_ifval([$2$3],
 [if $1; then
   m4_default([$2], [:])
-m4_ifval([$3], [_$0(m4_shiftn(2, $@))])[]dnl
+m4_ifval([$3], [_$0(m4_shift2($@))])[]dnl
 fi
 ])dnl
 ])# AS_IF
index 4a3a1f795d6089080a77ed17d657f9732cef1b63..c835fed957c8a048903c95ff8ebba61d5e69e43f 100644 (file)
@@ -362,7 +362,7 @@ m4_define([m4_case],
        [$#], 1, [],
        [$#], 2, [$2],
        [$1], [$2], [$3],
-       [$0([$1], m4_shiftn(3, $@))])])
+       [$0([$1], m4_shift3($@))])])
 
 
 # m4_bmatch(SWITCH, RE1, VAL1, RE2, VAL2, ..., DEFAULT)
@@ -384,7 +384,7 @@ m4_define([m4_bmatch],
 [m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
        [$#], 1, [m4_fatal([$0: too few arguments: $#: $1])],
        [$#], 2, [$2],
-       [m4_if(m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shiftn(3, $@))],
+       [m4_if(m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shift3($@))],
              [$3])])])
 
 
@@ -442,7 +442,7 @@ m4_define([m4_map_sep],
 # due to quotation problems, I need to double quote $1 below, therefore
 # the anchors are broken :(  I can't let users be trapped by that.
 #
-# Recall that m4_shiftn always results in an argument.  Hence, we need
+# Recall that m4_shift3 always results in an argument.  Hence, we need
 # to distinguish between a final deletion vs. ending recursion.
 m4_define([m4_bpatsubsts],
 [m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
@@ -452,7 +452,7 @@ m4_define([m4_bpatsubsts],
 m4_define([_m4_bpatsubsts],
 [m4_if([$#], 2, [$1],
        [$0(m4_builtin([patsubst], [[$1]], [$2], [$3]),
-          m4_shiftn(3, $@))])])
+          m4_shift3($@))])])
 
 
 
@@ -560,22 +560,21 @@ m4_define([m4_noquote],
 # m4_shiftn(N, ...)
 # -----------------
 # Returns ... shifted N times.  Useful for recursive "varargs" constructs.
-#
-# Internally, other m4sugar macros frequently use m4_shiftn(2, $@) and
-# m4_shiftn(3, $@).  Optimize these cases to avoid extra recursion and
-# expansion.
 m4_define([m4_shiftn],
-[m4_if(m4_eval(($1 >= 0) && ($# > $1)), 0,
-        [m4_assert(($1 >= 0) && ($# > $1))],
-       [$1], 2, [m4_shift(m4_shift(m4_shift($@)))],
-       [$1], 3, [m4_shift(m4_shift(m4_shift(m4_shift($@))))],
-       [_m4_shiftn($@)])])
+[m4_assert(0 <= $1 && $1 < $#)dnl
+_m4_shiftn($@)])
 
 m4_define([_m4_shiftn],
 [m4_if([$1], 0,
        [m4_shift($@)],
        [_m4_shiftn(m4_eval([$1]-1), m4_shift(m4_shift($@)))])])
 
+# m4_shift2(...)
+# m4_shift3(...)
+# -----------------
+# Returns ... shifted twice, and three times.  Faster than m4_shiftn.
+m4_define([m4_shift2], [m4_shift(m4_shift($@))])
+m4_define([m4_shift3], [m4_shift(m4_shift(m4_shift($@)))])
 
 # m4_undefine(NAME)
 # -----------------
@@ -1522,7 +1521,7 @@ m4_defun([m4_join],
 [m4_case([$#],
         [1], [],
         [2], [[$2]],
-        [[$2][$1]$0([$1], m4_shiftn(2, $@))])])
+        [[$2][$1]$0([$1], m4_shift2($@))])])
 
 
 
index 61481f367540f3a8cc2bceaeb62039d36dbd0922..b9384f8a23c93b61ea948b49b32544b68024ec53 100644 (file)
@@ -63,7 +63,7 @@ AT_INIT([artificial test suite])
 AT_SETUP([my only test])
 $2
 AT_CLEANUP
-]], m4_shiftn(2, $@))])
+]], m4_shift2($@))])
 
 # Here documents for these tests contain forbidden macros.
 m4_pattern_allow([^AT_])