Detect empty list in AS_FOR.

* lib/m4sugar/m4sh.m4 (AS_FOR): Handle iteration over $@
properly.
* tests/m4sh.at (AS@&t@_FOR): Enhance test to catch it.
Reported by Paolo Bonzini.

Signed-off-by: Eric Blake <ebb9@byu.net>
This commit is contained in:
Eric Blake 2008-11-17 06:20:27 -07:00
parent 541df95c2e
commit 7ad7019cf7
3 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2008-11-17 Eric Blake <ebb9@byu.net>
Detect empty list in AS_FOR.
* lib/m4sugar/m4sh.m4 (AS_FOR): Handle iteration over $@
properly.
* tests/m4sh.at (AS@&t@_FOR): Enhance test to catch it.
Reported by Paolo Bonzini.
2008-11-16 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Use a different workaround for an automake quirk.

View File

@ -552,7 +552,7 @@ m4_define([AS_EXIT],
# substitution, shell quoting, globs, or quadrigraphs). Inline the
# m4_defn for speed.
m4_defun([AS_FOR],
[m4_pushdef([$1], m4_if(m4_translit([$3], ]dnl
[m4_pushdef([$1], m4_if([$3], [], [[$$2]], m4_translit([$3], ]dnl
m4_dquote(_m4_defn([m4_cr_symbols2]))[[%+=:,./-]), [], [[$3]], [[$$2]]))]dnl
[for $2[]m4_ifval([$3], [ in $3])
do

View File

@ -934,7 +934,7 @@ AS_FOR([m4var], [shvar], [\'],
# Syntax checks: cope with empty arguments.
set f g
AS_FOR([], [shvar], [],
[echo "$shvar"])
[echo "m4_defn([]) $shvar"])
rm -f file
AS_FOR([], [shvar], [`touch file`])
test -f file || exit 1
@ -963,8 +963,8 @@ e e
d e d e
$list $list
' '
f
g
f f
g g
h
j
]])