mirror of
git://git.sv.gnu.org/autoconf
synced 2025-01-18 10:45:15 +08:00
* lib/m4sugar/m4sh.m4 (AS_CASE): New macro.
(_AS_CASE): Private helper macro. * tests/m4sh.at: Basic tests for AS_IF and AS_CASE. * doc/autoconf.texi (Programming in M4sh): Document AS_CASE. Fix syntax of AS_IF description (Prerequisite Macros): Mention AS_IF and AS_CASE as workarounds for the AC_REQUIRE mess. * NEWS: Mention AS_CASE, AS_BOURNE_COMPATIBLE, and AS_SHELL_SANITIZE.
This commit is contained in:
parent
cbb28abf85
commit
6fab15fe41
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2006-02-15 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
||||
|
||||
* lib/m4sugar/m4sh.m4 (AS_CASE): New macro.
|
||||
(_AS_CASE): Private helper macro.
|
||||
* tests/m4sh.at: Basic tests for AS_IF and AS_CASE.
|
||||
* doc/autoconf.texi (Programming in M4sh): Document AS_CASE.
|
||||
Fix syntax of AS_IF description
|
||||
(Prerequisite Macros): Mention AS_IF and AS_CASE as workarounds
|
||||
for the AC_REQUIRE mess.
|
||||
* NEWS: Mention AS_CASE, AS_BOURNE_COMPATIBLE, and
|
||||
AS_SHELL_SANITIZE.
|
||||
|
||||
2006-02-14 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* doc/autoconf.texi: Minor style cleanup.
|
||||
|
3
NEWS
3
NEWS
@ -64,6 +64,9 @@
|
||||
** AS_HELP_STRING
|
||||
The macro correctly handles quadrigraphs now.
|
||||
|
||||
** AS_BOURNE_COMPATIBLE, AS_SHELL_SANITIZE, AS_CASE
|
||||
These macros are new or published now.
|
||||
|
||||
** AT_COPYRIGHT
|
||||
New macro for copyright notices in testsuite files.
|
||||
|
||||
|
@ -9009,6 +9009,13 @@ environment variables, or setting options, or similar
|
||||
implementation-specific actions.
|
||||
@end defmac
|
||||
|
||||
@defmac AS_CASE (@var{word}, @ovar{pattern1}, @ovar{if-matched1}, @dots{}, @ovar{default})
|
||||
@asindex{CASE}
|
||||
Expand into a shell @samp{case} statement, where @var{word} is matched
|
||||
against one or more patterns. @var{if-matched} is run if the
|
||||
corresponding pattern matched @var{word}, else @var{default} is run.
|
||||
@end defmac
|
||||
|
||||
@defmac AS_DIRNAME (@var{file-name})
|
||||
@asindex{DIRNAME}
|
||||
Return the directory portion of @var{file-name}, using the algorithm
|
||||
@ -9017,11 +9024,12 @@ details about what this returns and why it is more portable than the
|
||||
@command{dirname} command.
|
||||
@end defmac
|
||||
|
||||
@defmac AS_IF (@var{test}, @ovar{RUN-IF-TRUE}, @ovar{RUN-IF-FALSE})
|
||||
@defmac AS_IF (@var{test}, @ovar{run-if-true}, @ovar{run-if-false})
|
||||
@asindex{IF}
|
||||
Run shell code TEST@. If TEST exits with a zero status then run shell code
|
||||
RUN-IF-TRUE, else run shell code RUN-IF-FALSE, with simplifications if either
|
||||
RUN-IF-TRUE or RUN-IF-FALSE is empty.
|
||||
Run shell code @var{test}. If @var{test} exits with a zero status then
|
||||
run shell code @var{run-if-true}, else run shell code @var{run-if-false},
|
||||
with simplifications if either @var{run-if-true} or @var{run-if-false}
|
||||
is empty.
|
||||
@end defmac
|
||||
|
||||
@defmac AS_MKDIR_P (@var{file-name})
|
||||
@ -9430,9 +9438,11 @@ SOME_CHECK
|
||||
@end group
|
||||
@end example
|
||||
|
||||
|
||||
You are encouraged to put all @code{AC_REQUIRE}s at the beginning of a
|
||||
macro. You can use @code{dnl} to avoid the empty lines they leave.
|
||||
The helper macros @code{AS_IF} and @code{AS_CASE} may be used to
|
||||
enforce expansion of required macros outside of shell conditional
|
||||
constructs. You are furthermore encouraged to put all @code{AC_REQUIRE}s
|
||||
at the beginning of a macro. You can use @code{dnl} to avoid the empty
|
||||
lines they leave.
|
||||
|
||||
@node Suggested Ordering
|
||||
@subsection Suggested Ordering
|
||||
|
@ -460,6 +460,30 @@ fi
|
||||
])# AS_IF
|
||||
|
||||
|
||||
# AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT])
|
||||
# ----------------------------------------------------
|
||||
# Expand into
|
||||
# | case WORD in
|
||||
# | PATTERN1) IF-MATCHED1 ;;
|
||||
# | ...
|
||||
# | *) DEFAULT ;;
|
||||
# | esac
|
||||
m4_define([_AS_CASE],
|
||||
[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
|
||||
[$#], 1, [ *) $1 ;;],
|
||||
[$#], 2, [ $1) m4_default([$2], [:]) ;;],
|
||||
[ $1) m4_default([$2], [:]) ;;
|
||||
$0(m4_shiftn(2, $@))])dnl
|
||||
])
|
||||
m4_defun([AS_CASE],
|
||||
[m4_ifval([$2$3],
|
||||
[case $1 in
|
||||
_AS_CASE(m4_shift($@))
|
||||
esac
|
||||
])dnl
|
||||
])# AS_CASE
|
||||
|
||||
|
||||
# _AS_UNSET_PREPARE
|
||||
# -----------------
|
||||
# AS_UNSET depends upon $as_unset: compute it.
|
||||
|
@ -533,3 +533,36 @@ AT_CHECK([./script], [0],
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
## ------------------- ##
|
||||
## AS_IF and AS_CASE. ##
|
||||
## ------------------- ##
|
||||
|
||||
AT_SETUP([AS@&t@_IF and AS@&t@_CASE])
|
||||
|
||||
AT_DATA_M4SH([script.as], [[dnl
|
||||
AS_INIT
|
||||
# Syntax checks: cope with empty arguments.
|
||||
AS_IF([:], [], [echo wrong])
|
||||
AS_IF([:], [:], [echo wrong])
|
||||
AS_IF([false], [echo wrong], [:])
|
||||
AS_IF([false], [echo wrong])
|
||||
AS_CASE([foo])
|
||||
AS_CASE([foo], [:])
|
||||
AS_CASE([foo],
|
||||
[foo], [:],
|
||||
[echo wrong])
|
||||
AS_CASE([foo],
|
||||
[foo], [:],
|
||||
[*], [echo wrong])
|
||||
AS_CASE([foo],
|
||||
[bar], [echo wrong],
|
||||
[foo], [:],
|
||||
[*], [echo wrong])
|
||||
]])
|
||||
|
||||
AT_CHECK_M4SH
|
||||
AT_CHECK([./script])
|
||||
|
||||
AT_CLEANUP
|
||||
|
Loading…
Reference in New Issue
Block a user