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-70-g


From: Eric Blake
Subject: [SCM] GNU Autoconf source repository branch, master, updated. v2.62-70-gce0298d
Date: Tue, 12 Aug 2008 21:58:09 +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=ce0298d64eb08c59d5116b07ff4e090111d289ed

The branch, master has been updated
       via  ce0298d64eb08c59d5116b07ff4e090111d289ed (commit)
       via  430dd8892be28702114f5f82971475c8a18b3a23 (commit)
      from  1c379f06c2def4173f6a7165314890bd7694290b (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 ce0298d64eb08c59d5116b07ff4e090111d289ed
Author: Eric Blake <address@hidden>
Date:   Tue Aug 12 15:23:56 2008 -0600

    Optimize m4_bmatch.
    
    * lib/m4sugar/foreach.m4 (m4_bmatch): Provide linear
    implementation for m4 1.4.x.
    * tests/m4sugar.at (m4@&address@hidden): New test.
    (recursion): Test the linear nature.
    * NEWS: Document the fix.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 430dd8892be28702114f5f82971475c8a18b3a23
Author: Eric Blake <address@hidden>
Date:   Tue Aug 12 09:18:53 2008 -0600

    Fix m4_cond corner case.
    
    * lib/m4sugar/foreach.m4 (_m4_cond): Ensure alternate
    implementation allows concatenation with subsequent text.
    * tests/m4sugar.at (m4@&address@hidden): Enhance test.
    
    Signed-off-by: Eric Blake <address@hidden>

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

Summary of changes:
 ChangeLog              |   12 ++++++++++++
 NEWS                   |    5 +++--
 lib/m4sugar/foreach.m4 |   46 ++++++++++++++++++++++++++++++++++++++++------
 tests/m4sugar.at       |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 101 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c1faa2..aa82465 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2008-08-12  Eric Blake  <address@hidden>
 
+       Optimize m4_bmatch.
+       * lib/m4sugar/foreach.m4 (m4_bmatch): Provide linear
+       implementation for m4 1.4.x.
+       * tests/m4sugar.at (m4@&address@hidden): New test.
+       (recursion): Test the linear nature.
+       * NEWS: Document the fix.
+
+       Fix m4_cond corner case.
+       * lib/m4sugar/foreach.m4 (_m4_cond): Ensure alternate
+       implementation allows concatenation with subsequent text.
+       * tests/m4sugar.at (m4@&address@hidden): Enhance test.
+
        Add test for m4_cond.
        * tests/m4sugar.at (m4@&address@hidden): New test.
        Reported by Ralf Wildenhues.
diff --git a/NEWS b/NEWS
index dbff114..2cf6747 100644
--- a/NEWS
+++ b/NEWS
@@ -38,8 +38,9 @@ GNU Autoconf NEWS - User visible changes.
    previously had linear scaling with m4 1.6 but quadratic scaling
    when using m4 1.4.x.  All macros built on top of these also gain
    the scaling improvements.
-   m4_bpatsubsts  m4_case  m4_cond  m4_do  m4_dquote_elt  m4_foreach
-   m4_join  m4_list_cmp  m4_map  m4_map_sep  m4_max  m4_min  m4_shiftn
+   m4_bmatch  m4_bpatsubsts  m4_case  m4_cond  m4_do  m4_dquote_elt
+   m4_foreach  m4_join  m4_list_cmp  m4_map  m4_map_sep  m4_max
+   m4_min  m4_shiftn
 
 ** AT_KEYWORDS once again performs expansion on its argument, such that
    AT_KEYWORDS([m4_if([$1], [], [default])]) no longer complains about
diff --git a/lib/m4sugar/foreach.m4 b/lib/m4sugar/foreach.m4
index 78779c4..816ee60 100644
--- a/lib/m4sugar/foreach.m4
+++ b/lib/m4sugar/foreach.m4
@@ -121,6 +121,39 @@ m4_define([m4_case],
 m4_define([_m4_case_],
 [[[$$1],[$$2],[$$3],]])
 
+# m4_bmatch(SWITCH, RE1, VAL1, RE2, VAL2, ..., DEFAULT)
+# -----------------------------------------------------
+# m4 equivalent of
+#
+# if (SWITCH =~ RE1)
+#   VAL1;
+# elif (SWITCH =~ RE2)
+#   VAL2;
+# elif ...
+#   ...
+# else
+#   DEFAULT
+#
+# We build the temporary macro _m4_b:
+#   m4_define([_m4_b], _m4_defn([_m4_bmatch]))_m4_b([$1], [$2], [$3])...
+#   _m4_b([$1], [$m-1], [$m])_m4_b([], [], [$m+1]_m4_popdef([_m4_b]))
+# then invoke m4_unquote(_m4_b($@)), for concatenation with later text.
+m4_define([m4_bmatch],
+[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
+       [$#], 1, [m4_fatal([$0: too few arguments: $#: $1])],
+       [$#], 2, [$2],
+       [m4_define([_m4_b], m4_pushdef([_m4_b])[m4_define([_m4_b],
+  _m4_defn([_$0]))]_m4_for([_m4_b], [3], m4_eval([($# + 1) / 2 * 2 - 1]),
+  [2], [_$0_([1], m4_decr(_m4_b), _m4_b)])[_m4_b([], [],]m4_dquote(
+  [$]m4_incr(_m4_b))[_m4_popdef([_m4_b]))])m4_unquote(_m4_b($@))])])
+
+m4_define([_m4_bmatch],
+[m4_if(m4_bregexp([$1], [$2]), [-1], [], [[$3]m4_define([$0])])])
+
+m4_define([_m4_bmatch_],
+[[_m4_b([$$1], [$$2], [$$3])]])
+
+
 # m4_cond(TEST1, VAL1, IF-VAL1, TEST2, VAL2, IF-VAL2, ..., [DEFAULT])
 # -------------------------------------------------------------------
 # Similar to m4_if, except that each TEST is expanded when encountered.
@@ -132,17 +165,18 @@ m4_define([_m4_case_],
 # m4_cond already guarantees either 3*n or 3*n + 1 arguments, 1 <= n.
 # We only have to speed up _m4_cond, by building the temporary _m4_c:
 #   m4_define([_m4_c], _m4_defn([m4_unquote]))_m4_c([m4_if(($1), [($2)],
-#   [$3[]m4_define([_m4_c])])])_m4_c([m4_if(($4), [($5)],
-#   [$6[]m4_define([_m4_c])])])..._m4_c([m4_if(($m-2), [($m-1)],
-#   [$m[]m4_define([_m4_c])])])_m4_c([$m+1]_m4_popdef([_m4_c]))
+#   [[$3]m4_define([_m4_c])])])_m4_c([m4_if(($4), [($5)],
+#   [[$6]m4_define([_m4_c])])])..._m4_c([m4_if(($m-2), [($m-1)],
+#   [[$m]m4_define([_m4_c])])])_m4_c([[$m+1]]_m4_popdef([_m4_c]))
+# We invoke m4_unquote(_m4_c($@)), for concatenation with later text.
 m4_define([_m4_cond],
 [m4_define([_m4_c], m4_pushdef([_m4_c])[m4_define([_m4_c],
   _m4_defn([m4_unquote]))]_m4_for([_m4_c], [2], m4_eval([$# / 3 * 3 - 1]), [3],
-  [$0_(m4_decr(_m4_c), _m4_c, m4_incr(_m4_c))])[_m4_c(]m4_dquote(
-  [$]m4_eval([$# / 3 * 3 + 1]))[_m4_popdef([_m4_c]))])_m4_c($@)])
+  [$0_(m4_decr(_m4_c), _m4_c, m4_incr(_m4_c))])[_m4_c(]m4_dquote(m4_dquote(
+  [$]m4_eval([$# / 3 * 3 + 1])))[_m4_popdef([_m4_c]))])m4_unquote(_m4_c($@))])
 
 m4_define([_m4_cond_],
-[[_m4_c([m4_if(($$1), [($$2)], [$$3[]m4_define([_m4_c])])])]])
+[[_m4_c([m4_if(($$1), [($$2)], [[$$3]m4_define([_m4_c])])])]])
 
 # m4_bpatsubsts(STRING, RE1, SUBST1, RE2, SUBST2, ...)
 # ----------------------------------------------------
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index b52b833..8e9885a 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -214,6 +214,10 @@ m4_cond([[a,a]], [a,a], [yes])
 m4_cond([a,a], [a,b], [yes], [no])
 m4_cond([a,a], [a,b], [yes])
 m4_cond([m4_eval([0xa])])
+m4_define([ab], [AB])dnl
+m4_cond([a])b
+m4_cond([1], [1], [a])b
+m4_cond([1], [2], [3], [a])b
 ]], [[
 a
 c
@@ -223,6 +227,9 @@ yes
 no
 
 10
+AB
+AB
+AB
 ]], [[1
 2
 2
@@ -566,6 +573,38 @@ AT_CHECK_M4RE([m4_re_string], address@hidden)
 
 AT_CLEANUP
 
+## ----------- ##
+## m4_bmatch.  ##
+## ----------- ##
+
+AT_SETUP([m4@&address@hidden)
+
+AT_CHECK_M4SUGAR_TEXT(
+[[m4_bmatch([abc], [default\])
+m4_bmatch([abc], [^a], [yes])
+m4_bmatch([abc], [^a], [yes], [no])
+m4_bmatch([abc], [^.a], [yes])
+m4_bmatch([abc], [^.a], [yes], [no\])
+m4_bmatch([abc], [a], [1], [b], [2])
+m4_bmatch([abc], [A], [1], [b], [2])
+m4_define([ab], [AB])dnl
+m4_bmatch([$*], [a])b
+m4_bmatch([$*], [\*], [a])b
+m4_bmatch([$*], [1], [2], [a])b
+]], [[default\
+yes
+yes
+
+no\
+1
+2
+AB
+AB
+AB
+]])
+
+AT_CLEANUP
+
 ## --------------- ##
 ## m4_bpatsubsts.  ##
 ## --------------- ##
@@ -863,7 +902,8 @@ AT_SETUP([recursion])
 
 AT_KEYWORDS([m4@&address@hidden m4@&address@hidden m4@&address@hidden 
m4@&address@hidden
 m4@&address@hidden m4@&address@hidden m4@&address@hidden m4@&address@hidden 
m4@&address@hidden
-m4@&address@hidden m4@&address@hidden m4@&address@hidden m4@&address@hidden 
m4@&address@hidden m4@&address@hidden)
+m4@&address@hidden m4@&address@hidden m4@&address@hidden m4@&address@hidden 
m4@&address@hidden m4@&address@hidden
+m4@&address@hidden)
 
 dnl This test completes in a reasonable time if m4_foreach is linear,
 dnl but thrashes if it is quadratic.  If we are testing with m4 1.4.x,
@@ -888,6 +928,7 @@ m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
 m4_for([i], [1], [10000], [], [m4_define(i)])dnl
 m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
 m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
+m4_bmatch([9997]m4_for([i], [1], [10000], [], [,^i$]))
 m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
 m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops]) j
 m4_divert_pop(0)
@@ -903,6 +944,7 @@ end
 0
 0
 A
+^9998$
 9990 9990
 ]])
 
@@ -919,6 +961,7 @@ end
 0
 0
 A
+^9998$
 9990 9990
 m4_exit([0])])
 m4_init
@@ -938,6 +981,7 @@ m4_list_cmp([0m4_for([i], [1], [10000], [], [,0])], [0])
 m4_for([i], [1], [10000], [], [m4_define(i)])dnl
 m4_undefine(1m4_for([i], [2], [10000], [], [,i]))dnl
 m4_bpatsubsts([a1]m4_for([i], [1], [10000], [], [,i]), [a2], [A])
+m4_bmatch([9997]m4_for([i], [1], [10000], [], [,^i$]))
 m4_define([up], [m4_define([$1], m4_incr($1))$1])m4_define([j], 0)dnl
 m4_cond(m4_for([i], [1], [10000], [], [[up([j])], [9990], i,]) [oops])
 m4_divert_pop(0)
@@ -953,6 +997,7 @@ end
 0
 0
 A
+^9998$
 9990 9990
 ]])
 


hooks/post-receive
--
GNU Autoconf source repository




reply via email to

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