m4-commit
[Top][All Lists]
Advanced

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

[SCM] GNU M4 source repository branch, master, updated. 91b8f5afc665a8ba


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, master, updated. 91b8f5afc665a8ba0cc2b0f06f371d4ae475809a
Date: Mon, 29 Oct 2007 03:26:53 +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 M4 source repository".

http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=91b8f5afc665a8ba0cc2b0f06f371d4ae475809a

The branch, master has been updated
       via  91b8f5afc665a8ba0cc2b0f06f371d4ae475809a (commit)
       via  d9274c9c964e7c610833e77eca4fb9fd37b00200 (commit)
      from  63e4aec38e5573ec8a774f5a6e467332826f5d95 (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 91b8f5afc665a8ba0cc2b0f06f371d4ae475809a
Author: Eric Blake <address@hidden>
Date:   Sun Oct 28 21:26:41 2007 -0600

    More test coverage for autoconf usage patterns.
    
    * doc/m4.texinfo (Shift): Document cond macro, and add new test.
    * tests/macros.at (Rescanning macros): New test.
    * tests/builtins.at (include): Augment test.
    
    Signed-off-by: Eric Blake <address@hidden>

commit d9274c9c964e7c610833e77eca4fb9fd37b00200
Author: Ralf Wildenhues <address@hidden>
Date:   Sun Oct 28 18:27:38 2007 -0600

    ChangeLog for previous commit.

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

Summary of changes:
 ChangeLog         |   11 ++++++++
 doc/m4.texinfo    |   71 +++++++++++++++++++++++++++++++++++++++++++++++-----
 tests/builtins.at |    9 ++++++
 tests/macros.at   |   29 +++++++++++++++++++++
 4 files changed, 113 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6f56dee..a78c048 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-10-28  Eric Blake  <address@hidden>
+
+       More test coverage for autoconf usage patterns.
+       * doc/m4.texinfo (Shift): Document cond macro, and add new test.
+       * tests/macros.at (Rescanning macros): New test.
+       * tests/builtins.at (include): Augment test.
+
+2007-10-28  Ralf Wildenhues  <address@hidden>
+
+       * Makefile.am: Adjust getopt handling to latest gnulib layout.
+
 2007-10-27  Eric Blake  <address@hidden>
 
        Document one use of changequote(`(',`)').
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index f84f4d3..54884a3 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -1508,16 +1508,16 @@ empty string.
 
 @cindex rescanning
 The output of macro evaluations is always rescanned.  The following
-example would yield the string @samp{de}, exactly as if @code{m4}
-has been given @address@hidden(`abcde', `3', `2')}} as input:
+example would yield the string @samp{bcd}, exactly as if @code{m4}
+has been given @address@hidden(`abcde', `1', `3')}} as input:
 
 @example
 define(`x', `substr(ab')
 @result{}
-define(`y', `cde, `3', `2')')
+define(`y', `cde, `1', `3')')
 @result{}
 x`'y
address@hidden
address@hidden
 @end example
 
 Unquoted strings on either side of a quoted string are subject to
@@ -2800,7 +2800,7 @@ as a multibranch, depending on the number of arguments 
supplied:
 @deffnx {Builtin (m4)} ifelse (@var{string-1}, @var{string-2}, @var{equal}, @
   @ovar{not-equal})
 @deffnx {Builtin (m4)} ifelse (@var{string-1}, @var{string-2}, @var{equal-1}, @
-  @var{string-3}, @var{string-4}, @var{equal-2}, @dots{})
+  @var{string-3}, @var{string-4}, @var{equal-2}, @dots{}, @ovar{not-equal})
 Used with only one argument, the @code{ifelse} simply discards it and
 produces no output.
 
@@ -2944,8 +2944,65 @@ reverse(`foo', `bar', `gnats', `and gnus')
 
 While not a very interesting macro, it does show how simple loops can be
 made with @code{shift}, @code{ifelse} and recursion.  It also shows
-that @code{shift} is usually used with @samp{$@@}.  Sometimes, a
-recursive algorithm requires adding quotes to each element:
+that @code{shift} is usually used with @samp{$@@}.  Another example of
+this is an implementation of a short-circuiting conditional operator.
+
address@hidden short-circuiting conditional
address@hidden conditional, short-circuiting
address@hidden Composite cond (@var{test-1}, @var{string-1}, @var{equal-1}, @
+  @ovar{test-2}, @ovar{string-2}, @ovar{equal-2}, @dots{}, @ovar{not-equal})
+Similar to @code{ifelse}, where an equal comparison between the first
+two strings results in the third, otherwise the first three arguments
+are discarded and the process repeats.  The difference is that each
address@hidden<n>} is expanded only when it is encountered.  This means that
+every third argument to @code{cond} is normally given one more level of
+quoting than the corresponding argument to @code{ifelse}.
address@hidden deffn
+
+Here is the implementation of @code{cond}, along with a demonstration of
+how it can short-circuit the side effects in @code{side}.  Notice how
+all the unquoted side effects happen regardless of how many comparisons
+are made with @code{ifelse}, compared with only the relevant effects
+with @code{cond}.
+
address@hidden
+define(`cond',
+`ifelse(`$#', `1', `$1',
+        `ifelse($1, `$2', `$3',
+                `$0(shift(shift(shift($@@))))')')')dnl
+define(`side', `define(`counter', incr(counter))$1')dnl
+define(`example1',
+`define(`counter', `0')dnl
+ifelse(side(`$1'), `yes', `one comparison: ',
+       side(`$1'), `no', `two comparisons: ',
+       side(`$1'), `maybe', `three comparisons: ',
+       `side(`default answer: ')')counter')dnl
+define(`example2',
+`define(`counter', `0')dnl
+cond(`side(`$1')', `yes', `one comparison: ',
+     `side(`$1')', `no', `two comparisons: ',
+     `side(`$1')', `maybe', `three comparisons: ',
+     `side(`default answer: ')')counter')dnl
+example1(`yes')
address@hidden comparison: 3
+example1(`no')
address@hidden comparisons: 3
+example1(`maybe')
address@hidden comparisons: 3
+example1(`feeling rather indecisive today')
address@hidden answer: 4
+example2(`yes')
address@hidden comparison: 1
+example2(`no')
address@hidden comparisons: 2
+example2(`maybe')
address@hidden comparisons: 3
+example2(`feeling rather indecisive today')
address@hidden answer: 4
address@hidden example
+
+Sometimes, a recursive algorithm requires adding quotes to each element,
+or treating multiple arguments as a single element:
 
 @deffn Composite quote (@dots{})
 @deffnx Composite dquote (@dots{})
diff --git a/tests/builtins.at b/tests/builtins.at
index 35b8a6b..a23aaa9 100644
--- a/tests/builtins.at
+++ b/tests/builtins.at
@@ -424,6 +424,15 @@ m4:include.m4:6: include: cannot open `NOFILE': No such 
file or directory
 
 AT_CHECK_M4([include.m4], 1, expout, experr)
 
+dnl make sure files are handled correctly even via builtin
+AT_DATA([foo], [[bar
+]])
+AT_DATA([in], [[builtin(`include', `foo')dnl
+]])
+
+AT_CHECK_M4([in], [0], [[bar
+]])
+
 AT_CLEANUP
 
 
diff --git a/tests/macros.at b/tests/macros.at
index fd9b176..3596baf 100644
--- a/tests/macros.at
+++ b/tests/macros.at
@@ -515,3 +515,32 @@ AT_CHECK_M4([in], [0], [[
 ]], [ignore])
 
 AT_CLEANUP
+
+
+## ----------------- ##
+## Rescanning macros ##
+## ----------------- ##
+
+AT_SETUP([Rescanning macros])
+
+dnl This is a series of tests that used to be included as undocumented tests
+dnl in the branch m4.texinfo.  They exercise rescanning issues not stressed
+dnl anywhere else in the suite, but which are used by autoconf.
+AT_DATA([in], [[define(`x1', `len(`$1'')dnl
+define(`y1', ``$1')')dnl
+x1(`01234567890123456789')y1(`98765432109876543210')
+]])
+
+AT_CHECK_M4([in], [0], [[40
+]])
+
+AT_DATA([in], [[define(`echo', `$@')dnl
+len((echo(`01234567890123456789',
+          `01234567890123456789')echo(`98765432109876543210',
+                                      `98765432109876543210')))
+]])
+
+AT_CHECK_M4([in], [0], [[84
+]])
+
+AT_CLEANUP


hooks/post-receive
--
GNU M4 source repository




reply via email to

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