[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AS_IF whitespace cleanup
From: |
Eric Blake |
Subject: |
AS_IF whitespace cleanup |
Date: |
Tue, 21 Oct 2008 18:24:58 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
I noticed that _AS_VAR_APPEND_PREPARE was ending in:
fi
# AS_VAR_APPEND
rather than the desired
fi # AS_VAR_APPEND
For that matter, it should be possible to do
AS_IF(...) && ...
or even
AS_IF(...) > file
similar to many of the other AS_ macros that intentionally do not add a newline
at the end.
This series of four patches shuffles around the responsibility for who outputs
a newline. Autoconf itself has a number of places that either had extra
newlines (one from AS_IF, one from the client), or where the client was using
dnl to get rid of the second. After the patches, AS_IF no longer supplies a
newline after the fi, and the client must not use dnl unless dealing with the
new possibility of valid continuation of the shell list (or when passing AS_IF
as an argument to some other macro that does supply a newline, such as how
AS_IF continues to supply a newline to the if-true and if-false arguments).
The net result is fewer blank lines in the configure script. It also tweaks
semantics (for example, AS_IF over-optimized in the case of a condition that
has side effects, but when both if-true and if-false were empty).
Fortunately, neither a Google code search nor a grep of libtool turned up any
instances of these four macros where the user was suppressing a second newline
with dnl (and which would now cause a script syntax error with the first
newline removed by this patch). The latter two macros are just newly
documented, so I'm not as worried about them, but does anyone know of uses in
the wild where the user suppressed a newline after AS_{IF,CASE}, and will now
be broken?
Eric Blake (4):
Allow AS_IF in shell lists.
Allow AS_CASE in shell lists.
Allow AS_VAR_IF in shell lists.
Allow AS_VAR_SET_IF in shell lists.
I'll apply this tomorrow unless I get feedback first.
$ git pull git://repo.or.cz/autoconf/ericb.git spacing
>From b7e2dc1f0365e0898ae15985aacc1e0e8c708661 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 20 Oct 2008 16:18:05 -0600
Subject: [PATCH] Allow AS_IF in shell lists.
* lib/m4sugar/m4sh.m4 (AS_IF): Always execute test, in case of
side effects. Allow continuation of script on same line as fi.
(_AS_DETECT_BETTER_SHELL): Adjust clients.
(AS_VAR_IF, AS_VAR_SET_IF): For now, supply newline no longer
given by AS_IF.
* lib/autoconf/c.m4 (_AC_PROG_PREPROC_WORKS_IFELSE): Likewise.
* lib/autoconf/general.m4 (_AC_ENABLE_IF): Likewise.
(AC_EGREP_CPP, _AC_RUN_IFELSE): Adjust client.
* lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Likewise.
* doc/autoconf.texi (Common Shell Constructs) <AS_IF>: Fix typo.
(Polymorphic Variables): Move mention of dnl to the only two
AS_VAR functions that need it.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 16 ++++++++++++++++
doc/autoconf.texi | 8 ++++----
lib/autoconf/c.m4 | 3 ++-
lib/autoconf/general.m4 | 6 +++---
lib/autoconf/libs.m4 | 2 +-
lib/m4sugar/m4sh.m4 | 22 +++++++++++-----------
tests/m4sh.at | 11 +++++++++++
7 files changed, 48 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f98b708..3195c7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2008-10-21 Eric Blake <address@hidden>
+
+ Allow AS_IF in shell lists.
+ * lib/m4sugar/m4sh.m4 (AS_IF): Always execute test, in case of
+ side effects. Allow continuation of script on same line as fi.
+ (_AS_DETECT_BETTER_SHELL): Adjust clients.
+ (AS_VAR_IF, AS_VAR_SET_IF): For now, supply newline no longer
+ given by AS_IF.
+ * lib/autoconf/c.m4 (_AC_PROG_PREPROC_WORKS_IFELSE): Likewise.
+ * lib/autoconf/general.m4 (_AC_ENABLE_IF): Likewise.
+ (AC_EGREP_CPP, _AC_RUN_IFELSE): Adjust client.
+ * lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Likewise.
+ * doc/autoconf.texi (Common Shell Constructs) <AS_IF>: Fix typo.
+ (Polymorphic Variables): Move mention of dnl to the only two
+ AS_VAR functions that need it.
+
2008-10-21 Paolo Bonzini <address@hidden>
and Eric Blake <address@hidden>
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index eed40c5..28fc123 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -11952,7 +11952,7 @@ Common Shell Constructs
Run shell code @var{test1}. If @var{test1} exits with a zero status then
run shell code @var{run-if-true1}, else examine further tests. If no test
exits with a zero status, run shell code @var{run-if-false}, with
-simplifications if either @var{run-if-true1} or @var{run-if-false1}
+simplifications if either @var{run-if-true1} or @var{run-if-false}
is empty. For example,
@example
@@ -12046,8 +12046,7 @@ Polymorphic Variables
to write a macro that can deal with either literal or indirect variable
names and output shell code appropriate for both use cases. Behavior is
undefined if expansion of an indirect variable does not result in a
-literal variable name. These macros are often followed with @code{dnl},
-to avoid excess newlines in the output.
+literal variable name.
@defmac AS_LITERAL_IF (@var{expression}, @ovar{if-literal}, @ovar{if-not})
@asindex{LITERAL_IF}
@@ -12122,7 +12121,8 @@ Polymorphic Variables
temporary m4 macro @var{m4-name} with @code{AS_VAR_PUSHDEF}, then use
that macro as the argument to subsequent @code{AS_VAR} macros as a
polymorphic variable name, and finally free the temporary macro with
address@hidden
address@hidden These macros are often followed with @code{dnl},
+to avoid excess newlines in the output.
Here is an involved example, that shows the power of writing macros that
can handle composed shell variable names:
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 6e250ee..e62797f 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -477,7 +477,8 @@ break])
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
-AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
+AS_IF([$ac_preproc_ok], [$1], [$2])
+])# _AC_PROG_PREPROC_WORKS_IFELSE
# AC_PROG_CPP
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index b5c720d..eaeff13 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1433,7 +1433,7 @@ m4_define([_m4_divert(HELP_ENABLE)], _m4_divert
(HELP_WITH))
#
m4_define([_AC_ENABLE_IF],
address@hidden:@ Check whether --$1-$2 was given.
-_AC_ENABLE_IF_ACTION([$1], m4_translit([$2], [-.], [__]), [$3], [$4])[]dnl
+_AC_ENABLE_IF_ACTION([$1], m4_translit([$2], [-.], [__]), [$3], [$4])
])
m4_define([_AC_ENABLE_IF_ACTION],
@@ -2446,7 +2446,7 @@ dnl Ultrix and Pyramid sh refuse to redirect output of
eval, so use subshell.
dnl Quote $1 to prevent m4 from eating character classes
$EGREP "[$1]" >/dev/null 2>&1],
[$3],
- [$4])dnl
+ [$4])
rm -f conftest*
])# AC_EGREP_CPP
@@ -2590,7 +2590,7 @@ AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS
(./conftest$ac_exeext)],
_AC_MSG_LOG_CONFTEST
m4_ifvaln([$3],
[( exit $ac_status )
-$3])dnl])[]dnl
+$3])dnl])
rm -rf conftest.dSYM
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext
conftest.$ac_objext m4_ifval([$1],
[conftest.$ac_ext])[]dnl
diff --git a/lib/autoconf/libs.m4 b/lib/autoconf/libs.m4
index 03258f0..59b8dca 100644
--- a/lib/autoconf/libs.m4
+++ b/lib/autoconf/libs.m4
@@ -88,7 +88,7 @@ AS_VAR_COPY([ac_res], [ac_Search])
AS_IF([test "$ac_res" != no],
[test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
$3],
- [$4])dnl
+ [$4])
AS_VAR_POPDEF([ac_Search])dnl
])
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 9ef15f5..db9c718 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -241,8 +241,7 @@ dnl Remove any tests from suggested that are also required
echo shells that I found on your system. Please install a
echo modern shell, or manually run the script under such a
echo shell if you do have one.
- AS_EXIT(1)])
- ])
+ AS_EXIT(1)])])
fi
])# _AS_DETECT_BETTER_SHELL
@@ -519,8 +518,8 @@ m4_define([AS_EXIT],
[{ (exit m4_default([$1], 1)); exit m4_default([$1], 1); }])
-# AS_IF(TEST1, [IF-TRUE1]...[IF-FALSE])
-# -------------------------------------
+# AS_IF(TEST1, [IF-TRUE1 = :]...[IF-FALSE = :])
+# ---------------------------------------------
# Expand into
# | if TEST1; then
# | IF-TRUE1
@@ -541,13 +540,10 @@ m4_define([_AS_IF_ELSE],
[else
$1])])
m4_defun([AS_IF],
-[m4_ifval([$2$3],
[if $1; then
m4_default([$2], [:])
m4_map_args_pair([_$0], [_$0_ELSE], m4_shift2($@))dnl
-fi
-])dnl
-])# AS_IF
+fi])# AS_IF
# _AS_UNSET_PREPARE
@@ -1667,7 +1663,9 @@ m4_define([AS_VAR_IF],
[AS_LITERAL_IF([$1],
[AS_IF([test "x$$1" = x""$2], [$3], [$4])],
[AS_VAR_COPY([as_val], [$1])
- AS_IF([test "x$as_val" = x""$2], [$3], [$4])])])
+ AS_IF([test "x$as_val" = x""$2], [$3], [$4])])
+dnl fixme: remove the newline?
+])
# AS_VAR_PUSHDEF and AS_VAR_POPDEF
@@ -1736,13 +1734,15 @@ m4_define([AS_VAR_SET],
# Implement a shell `if-then-else' depending whether VARIABLE is set
# or not. Polymorphic.
m4_define([AS_VAR_SET_IF],
-[AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
+[AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])
+dnl fixme: remove the newline?
+])
# AS_VAR_TEST_SET(VARIABLE)
# -------------------------
# Expands into the `test' expression which is true if VARIABLE
-# is set. Polymorphic. Should be dnl'ed.
+# is set. Polymorphic.
m4_define([AS_VAR_TEST_SET],
[AS_LITERAL_IF([$1],
[test "${$1+set}" = set],
diff --git a/tests/m4sh.at b/tests/m4sh.at
index b0ddafd..b12cb85 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -799,6 +799,13 @@ AS_CASE([foo],
[foo], [echo ten],
[*], [echo wrong])
+# check for nesting, lists, and side effects
+empty=
+AS_IF([AS_IF([$empty], [echo eleven])]) && echo twelve
+rm -f file
+AS_IF([touch file; false]) && echo thirteen
+test -f file && echo fourteen
+
# check that require works correctly
m4_for([n], 1, 9, [],
[m4_defun([FOO]n, [foo]n[=]n)dnl
@@ -844,6 +851,10 @@ seven
eight
nine
ten
+eleven
+twelve
+thirteen
+fourteen
foo1=1 bar1=1
foo2=2 bar2=
foo3=3 bar3=
--
1.6.0.2
>From 97bb5f56757392ad8f64cfa8c55b532c34386b9f Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 20 Oct 2008 16:43:41 -0600
Subject: [PATCH] Allow AS_CASE in shell lists.
* lib/m4sugar/m4sh.m4 (AS_CASE): Always execute test, in case of
side effects. Allow continuation of script on same line as esac.
* lib/autoconf/c.m4 (AC_PROG_CC_STDC): Adjust client.
* tests/m4sh.at (AS@&address@hidden and AS@&address@hidden): Enhance test.
* NEWS: Document the subtle change.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 7 +++++++
NEWS | 5 +++++
lib/autoconf/c.m4 | 2 +-
lib/m4sugar/m4sh.m4 | 5 +----
tests/m4sh.at | 5 ++++-
5 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3195c7b..0eba950 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-10-21 Eric Blake <address@hidden>
+ Allow AS_CASE in shell lists.
+ * lib/m4sugar/m4sh.m4 (AS_CASE): Always execute test, in case of
+ side effects. Allow continuation of script on same line as esac.
+ * lib/autoconf/c.m4 (AC_PROG_CC_STDC): Adjust client.
+ * tests/m4sh.at (AS@&address@hidden and AS@&address@hidden): Enhance
test.
+ * NEWS: Document the subtle change.
+
Allow AS_IF in shell lists.
* lib/m4sugar/m4sh.m4 (AS_IF): Always execute test, in case of
side effects. Allow continuation of script on same line as fi.
diff --git a/NEWS b/NEWS
index 147639b..2057ff8 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,11 @@ GNU Autoconf NEWS - User visible changes.
AS_VAR_PUSHDEF AS_VAR_SET AS_VAR_SET_IF AS_VAR_TEST_SET
AS_VERSION_COMPARE
+** The m4sh macros AS_IF and AS_CASE can now be used in shell lists.
+ The responsibility for supplying a trailing newline now belongs to
+ the call site, but since most users did not add dnl, this generally
+ results in fewer empty lines in configure.
+
* Major changes in Autoconf 2.63 (2008-09-09) [stable]
Released by Eric Blake, based on git versions 2.62.*.
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index e62797f..f3b3e5f 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -1337,7 +1337,7 @@ AC_DEFUN([AC_PROG_CC_STDC],
[no], [ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no],
[_AC_PROG_CC_C99([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
[_AC_PROG_CC_C89([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
- [ac_cv_prog_cc_stdc=no])])])dnl
+ [ac_cv_prog_cc_stdc=no])])])
AC_MSG_CHECKING([for $CC option to accept ISO Standard C])
AC_CACHE_VAL([ac_cv_prog_cc_stdc], [])
AS_CASE([$ac_cv_prog_cc_stdc],
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index db9c718..0dc9442 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -496,12 +496,9 @@ m4_define([_AS_CASE_DEFAULT],
[ *[)] $1 ;;
])
m4_defun([AS_CASE],
-[m4_ifval([$2$3],
[case $1 in
m4_map_args_pair([_$0], [_$0_DEFAULT], m4_shift($@))dnl
-esac
-])dnl
-])# AS_CASE
+esac])# AS_CASE
# AS_EXIT([EXIT-CODE = 1])
diff --git a/tests/m4sh.at b/tests/m4sh.at
index b12cb85..01253c5 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -801,10 +801,12 @@ AS_CASE([foo],
# check for nesting, lists, and side effects
empty=
-AS_IF([AS_IF([$empty], [echo eleven])]) && echo twelve
+AS_IF([AS_IF([$empty], [echo eleven])]) && AS_CASE([foo]) && echo twelve
rm -f file
AS_IF([touch file; false]) && echo thirteen
test -f file && echo fourteen
+rm -f file
+AS_CASE([`touch file; false`]) && test -f file && echo fifteen
# check that require works correctly
m4_for([n], 1, 9, [],
@@ -855,6 +857,7 @@ eleven
twelve
thirteen
fourteen
+fifteen
foo1=1 bar1=1
foo2=2 bar2=
foo3=3 bar3=
--
1.6.0.2
>From 011cbf8a8e4ce89b852e58c5ebb35b6d58cd5036 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 20 Oct 2008 16:56:12 -0600
Subject: [PATCH] Allow AS_VAR_IF in shell lists.
* lib/m4sugar/m4sh.m4 (AS_VAR_IF): Allow continuation of line.
* lib/autoconf/functions.m4 (AC_CHECK_FUNC): Adjust clients.
* lib/autoconf/general.m4 (AC_CHECK_FILE, AC_CHECK_DECL):
Likewise.
* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL)
(_AC_CHECK_HEADER_NEW, _AC_CHECK_HEADER_OLD)
(_AC_CHECK_HEADER_DIRENT): Likewise.
* lib/autoconf/libs.m4 (AC_CHECK_LIB): Likewise.
* lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW, AC_CHECK_MEMBER):
Likewise.
* tests/m4sh.at (AS@&address@hidden basics): Enhance test.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 13 +++++++++++++
lib/autoconf/functions.m4 | 2 +-
lib/autoconf/general.m4 | 4 ++--
lib/autoconf/libs.m4 | 2 +-
lib/autoconf/types.m4 | 4 ++--
lib/m4sugar/m4sh.m4 | 4 +---
tests/m4sh.at | 6 +++---
7 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0eba950..d086045 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2008-10-21 Eric Blake <address@hidden>
+ Allow AS_VAR_IF in shell lists.
+ * lib/m4sugar/m4sh.m4 (AS_VAR_IF): Allow continuation of line.
+ * lib/autoconf/functions.m4 (AC_CHECK_FUNC): Adjust clients.
+ * lib/autoconf/general.m4 (AC_CHECK_FILE, AC_CHECK_DECL):
+ Likewise.
+ * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL)
+ (_AC_CHECK_HEADER_NEW, _AC_CHECK_HEADER_OLD)
+ (_AC_CHECK_HEADER_DIRENT): Likewise.
+ * lib/autoconf/libs.m4 (AC_CHECK_LIB): Likewise.
+ * lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW, AC_CHECK_MEMBER):
+ Likewise.
+ * tests/m4sh.at (AS@&address@hidden basics): Enhance test.
+
Allow AS_CASE in shell lists.
* lib/m4sugar/m4sh.m4 (AS_CASE): Always execute test, in case of
side effects. Allow continuation of script on same line as esac.
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index c325f30..f5f94d7 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -70,7 +70,7 @@ AC_CACHE_CHECK([for $1], [ac_var],
[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
[AS_VAR_SET([ac_var], [yes])],
[AS_VAR_SET([ac_var], [no])])])
-AS_VAR_IF([ac_var], [yes], [$2], [$3])dnl
+AS_VAR_IF([ac_var], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_var])dnl
])# AC_CHECK_FUNC
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index eaeff13..e1e1367 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2645,7 +2645,7 @@ if test -r "$1"; then
else
AS_VAR_SET([ac_File], [no])
fi])
-AS_VAR_IF([ac_File], [yes], [$2], [$3])[]dnl
+AS_VAR_IF([ac_File], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_File])dnl
])# AC_CHECK_FILE
@@ -2682,7 +2682,7 @@ AC_CACHE_CHECK([whether $1 is declared], [ac_Symbol],
])],
[AS_VAR_SET([ac_Symbol], [yes])],
[AS_VAR_SET([ac_Symbol], [no])])])
-AS_VAR_IF([ac_Symbol], [yes], [$2], [$3])[]dnl
+AS_VAR_IF([ac_Symbol], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_Symbol])dnl
])# AC_CHECK_DECL
diff --git a/lib/autoconf/libs.m4 b/lib/autoconf/libs.m4
index 59b8dca..062063e 100644
--- a/lib/autoconf/libs.m4
+++ b/lib/autoconf/libs.m4
@@ -134,7 +134,7 @@ AS_VAR_IF([ac_Lib], [yes],
[m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
LIBS="-l$1 $LIBS"
])],
- [$4])dnl
+ [$4])
AS_VAR_POPDEF([ac_Lib])dnl
])# AC_CHECK_LIB
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index 0ab85a5..2c89b2f 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -160,7 +160,7 @@ AC_COMPILE_IFELSE(
return 0;])],
[],
[AS_VAR_SET([ac_Type], [yes])])])])
-AS_VAR_IF([ac_Type], [yes], [$2], [$3])[]dnl
+AS_VAR_IF([ac_Type], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_Type])dnl
])# _AC_CHECK_TYPE_NEW
@@ -834,7 +834,7 @@ if (sizeof ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
return 0;])],
[AS_VAR_SET([ac_Member], [yes])],
[AS_VAR_SET([ac_Member], [no])])])])
-AS_VAR_IF([ac_Member], [yes], [$2], [$3])dnl
+AS_VAR_IF([ac_Member], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_Member])dnl
])# AC_CHECK_MEMBER
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 0dc9442..ba84e63 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -1660,9 +1660,7 @@ m4_define([AS_VAR_IF],
[AS_LITERAL_IF([$1],
[AS_IF([test "x$$1" = x""$2], [$3], [$4])],
[AS_VAR_COPY([as_val], [$1])
- AS_IF([test "x$as_val" = x""$2], [$3], [$4])])
-dnl fixme: remove the newline?
-])
+ AS_IF([test "x$as_val" = x""$2], [$3], [$4])])])
# AS_VAR_PUSHDEF and AS_VAR_POPDEF
diff --git a/tests/m4sh.at b/tests/m4sh.at
index 01253c5..8b4d842 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -956,7 +956,7 @@ AS_VAR_COPY([bar], [foo])
AS_ECHO(["$bar-"])
AS_ECHO(["AS_VAR_GET([foo])-"])
AS_VAR_SET_IF([foo], [echo ok], [echo oops])
-AS_VAR_IF([foo], [string], [echo oops], [echo ok])
+AS_VAR_IF([foo], [string], [echo oops]) && echo ok
AS_VAR_PUSHDEF([tmp], [foo])
AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
'], [echo ok], [echo oops]) # 'font-lock
@@ -975,7 +975,7 @@ AS_VAR_COPY([foo$num], [bar])
AS_ECHO(["$foo2-"])
AS_ECHO(["AS_VAR_GET([foo$num])-"])
AS_VAR_SET_IF([foo$num], [echo ok], [echo oops])
-AS_VAR_IF([foo$num], [string], [echo oops], [echo ok])
+AS_VAR_IF([foo$num], [string], [echo oops]) && echo ok
AS_VAR_PUSHDEF([tmp], [foo$num])
AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
'], [echo ok], [echo oops]) # 'font-lock
@@ -993,7 +993,7 @@ AS_VAR_COPY([`echo foo4`], [bar])
AS_ECHO(["$foo4-"])
AS_ECHO(["AS_VAR_GET([`echo foo4`])-"])
AS_VAR_SET_IF([`echo foo4`], [echo ok], [echo oops])
-AS_VAR_IF([`echo foo4`], [string], [echo oops], [echo ok])
+AS_VAR_IF([`echo foo4`], [string], [echo oops]) && echo ok
AS_VAR_PUSHDEF([tmp], [`echo foo4`])
AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
'], [echo ok], [echo oops]) # 'font-lock
--
1.6.0.2
>From 8760c635692e7fa35c86a0ce72658c084726456f Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 20 Oct 2008 17:14:03 -0600
Subject: [PATCH] Allow AS_VAR_SET_IF in shell lists.
* lib/m4sugar/m4sh.m4 (AS_VAR_SET_IF): Allow continuation of
line.
* lib/autoconf/general.m4 (AC_CACHE_VAL): Supply newline no longer
provided by AS_VAR_SET_IF.
* lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL): Adjust
clients.
* lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Likewise.
* tests/m4sh.at (AS@&address@hidden basics): Enhance test.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 10 ++++++++++
lib/autoconf/general.m4 | 3 ++-
lib/autoconf/headers.m4 | 12 ++++++------
lib/autoconf/libs.m4 | 4 ++--
lib/m4sugar/m4sh.m4 | 4 +---
tests/m4sh.at | 6 +++---
6 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d086045..3b538f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2008-10-21 Eric Blake <address@hidden>
+ Allow AS_VAR_SET_IF in shell lists.
+ * lib/m4sugar/m4sh.m4 (AS_VAR_SET_IF): Allow continuation of
+ line.
+ * lib/autoconf/general.m4 (AC_CACHE_VAL): Supply newline no longer
+ provided by AS_VAR_SET_IF.
+ * lib/autoconf/headers.m4 (_AC_CHECK_HEADER_MONGREL): Adjust
+ clients.
+ * lib/autoconf/libs.m4 (AC_SEARCH_LIBS): Likewise.
+ * tests/m4sh.at (AS@&address@hidden basics): Enhance test.
+
Allow AS_VAR_IF in shell lists.
* lib/m4sugar/m4sh.m4 (AS_VAR_IF): Allow continuation of line.
* lib/autoconf/functions.m4 (AC_CHECK_FUNC): Adjust clients.
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index e1e1367..04f2e5a 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2002,7 +2002,8 @@ m4_if(m4_index([$2], [AC_SUBST]), [-1], [],
[where no actions should be taken])])dnl
AS_VAR_SET_IF([$1],
[_AS_ECHO_N([(cached) ])],
- [$2])])
+ [$2])
+])
# AC_CACHE_CHECK(MESSAGE, CACHE-ID, COMMANDS)
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 16b2737..5c41937 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -141,9 +141,9 @@ case $ac_header_compiler:$ac_header_preproc:$ac_[]
_AC_LANG_ABBREV[]_preproc_warn
;;
esac
AC_CACHE_CHECK([for $1], [ac_Header],
- [AS_VAR_SET([ac_Header], [$ac_header_preproc])])
-])dnl ! set ac_HEADER
-AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl
+ [AS_VAR_SET([ac_Header], [$ac_header_preproc])])[]dnl
+])
+AS_VAR_IF([ac_Header], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_Header])dnl
])# _AC_CHECK_HEADER_MONGREL
@@ -160,7 +160,7 @@ AC_CACHE_CHECK([for $1], [ac_Header],
@%:@include <$1>])],
[AS_VAR_SET([ac_Header], [yes])],
[AS_VAR_SET([ac_Header], [no])])])
-AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl
+AS_VAR_IF([ac_Header], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_Header])dnl
])# _AC_CHECK_HEADER_NEW
@@ -175,7 +175,7 @@ AC_CACHE_CHECK([for $1], [ac_Header],
[AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include
<$1>])],
[AS_VAR_SET([ac_Header], [yes])],
[AS_VAR_SET([ac_Header], [no])])])
-AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl
+AS_VAR_IF([ac_Header], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_Header])dnl
])# _AC_CHECK_HEADER_OLD
@@ -403,7 +403,7 @@ AC_CACHE_CHECK([for $1 that defines DIR], [ac_Header],
return 0;])],
[AS_VAR_SET([ac_Header], [yes])],
[AS_VAR_SET([ac_Header], [no])])])
-AS_VAR_IF([ac_Header], [yes], [$2], [$3])[]dnl
+AS_VAR_IF([ac_Header], [yes], [$2], [$3])
AS_VAR_POPDEF([ac_Header])dnl
])# _AC_CHECK_HEADER_DIRENT
diff --git a/lib/autoconf/libs.m4 b/lib/autoconf/libs.m4
index 062063e..cbc4218 100644
--- a/lib/autoconf/libs.m4
+++ b/lib/autoconf/libs.m4
@@ -79,9 +79,9 @@ for ac_lib in '' $2; do
LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
fi
AC_LINK_IFELSE([], [AS_VAR_SET([ac_Search], [$ac_res])])
- AS_VAR_SET_IF([ac_Search], [break])dnl
+ AS_VAR_SET_IF([ac_Search], [break])
done
-AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])dnl
+AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS])
AS_VAR_COPY([ac_res], [ac_Search])
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index ba84e63..1562e6b 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -1729,9 +1729,7 @@ m4_define([AS_VAR_SET],
# Implement a shell `if-then-else' depending whether VARIABLE is set
# or not. Polymorphic.
m4_define([AS_VAR_SET_IF],
-[AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])
-dnl fixme: remove the newline?
-])
+[AS_IF([AS_VAR_TEST_SET([$1])], [$2], [$3])])
# AS_VAR_TEST_SET(VARIABLE)
diff --git a/tests/m4sh.at b/tests/m4sh.at
index 8b4d842..c4b1254 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -949,7 +949,7 @@ AT_DATA_M4SH([script.as], [[dnl
AS_INIT
# Literals.
dnl AS_VAR_SET_IF also covers AS_VAR_TEST_SET
-AS_VAR_SET_IF([foo], [echo oops], [echo ok])
+AS_VAR_SET_IF([foo], [echo oops]) && echo ok
AS_VAR_SET([foo], ['\a "weird" `value` with; $fun '\''characters
']) # 'font-lock
AS_VAR_COPY([bar], [foo])
@@ -966,7 +966,7 @@ m4_ifdef([tmp], [echo oops])
# Indirects via shell vars.
echo '===='
num=1
-AS_VAR_SET_IF([foo$num], [echo oops], [echo ok])
+AS_VAR_SET_IF([foo$num], [echo oops]) && echo ok
AS_VAR_SET([foo$num], ['\a "weird" `value` with; $fun '\''characters
']) # 'font-lock
AS_VAR_COPY([bar], [foo$num])
@@ -984,7 +984,7 @@ m4_ifdef([tmp], [echo oops])
# Indirects via command substitution.
echo '===='
-AS_VAR_SET_IF([`echo foo3`], [echo oops], [echo ok])
+AS_VAR_SET_IF([`echo foo3`], [echo oops]) && echo ok
AS_VAR_SET([`echo foo3`], ['\a "weird" `value` with; $fun '\''characters
']) # 'font-lock
AS_VAR_COPY([bar], [`echo foo3`])
--
1.6.0.2