]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Allow AS_IF in shell lists.
authorEric Blake <ebb9@byu.net>
Mon, 20 Oct 2008 22:18:05 +0000 (16:18 -0600)
committerEric Blake <ebb9@byu.net>
Wed, 22 Oct 2008 03:03:57 +0000 (21:03 -0600)
* 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 <ebb9@byu.net>
ChangeLog
doc/autoconf.texi
lib/autoconf/c.m4
lib/autoconf/general.m4
lib/autoconf/libs.m4
lib/m4sugar/m4sh.m4
tests/m4sh.at

index 25ba3c0c431ee956a796fd4ebdd1361ee3f85f6f..93f29c059a5b9042db442ae081ba8180e76bc3ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2008-10-21  Eric Blake  <ebb9@byu.net>
+
+       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  <bonzini@gnu.org>
        and Eric Blake  <ebb9@byu.net>
 
index 25a733788b72962424fc4198b3bb6b51e11bc3ec..145302f747ba657fdbd8078b23df03e0965644ab 100644 (file)
@@ -11952,7 +11952,7 @@ Redirections can be placed outside the macro invocation.
 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 @@ M4sh supports the notion of polymorphic shell variables, making it easy
 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}
@@ -12147,7 +12146,8 @@ composed variable name based on @var{value}, it is easier to declare a
 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
-@code{AS_VAR_POPDEF}.
+@code{AS_VAR_POPDEF}.  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:
index 6e250eedc38801ecf6d30afb1feef70713a2a96e..e62797fe5ea888375b612e06ccae2a4c5121825f 100644 (file)
@@ -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
index 22111a1b78999f9364fa6d3375d33616302f8deb..b0032bf55efd7d266fd823c9f0c01fbdc7dceb76 100644 (file)
@@ -1433,7 +1433,7 @@ m4_define([_m4_divert(HELP_ENABLE)],    _m4_divert(HELP_WITH))
 #
 m4_define([_AC_ENABLE_IF],
 [@%:@ 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
 
@@ -2605,7 +2605,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
index 03258f0e113fa7ff36ba293c4d7aadb5f736e753..59b8dca09ef440e83f2768c156111ce6f6241e50 100644 (file)
@@ -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
 ])
 
index 10537eb0c12a4a72510abccd4729e99eeffa9804..94572e0defd5f4899e2b99096939d326e20c78f5 100644 (file)
@@ -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
 
@@ -521,8 +520,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
@@ -543,13 +542,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
@@ -1715,7 +1711,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
@@ -1785,13 +1783,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],
index 6ea6358594a619d72a79871c7ac8809a2e065180..8e3e6d2d55cd02758cc60f1459a2114101ce3bb2 100644 (file)
@@ -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=