From: Paolo Bonzini Date: Mon, 13 Oct 2008 16:23:30 +0000 (+0200) Subject: Support a stack of LINENO values for AS_MESSAGE. X-Git-Tag: v2.63b~255 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=270c996180a4bb09db725732ce5e1977edce9613;p=thirdparty%2Fautoconf.git Support a stack of LINENO values for AS_MESSAGE. * lib/m4sugar/m4sh.m4 (_AS_ECHO_LOG): If defined, use $as_lineno as the line number emitted to the log file. (AS_LINENO_PUSH, AS_LINENO_POP): New. * tests/m4sh.at (LINENO Stack): New test. --- diff --git a/ChangeLog b/ChangeLog index 8a4504c4..1f2bb12b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-10-15 Paolo Bonzini + + Support a stack of LINENO values for AS_MESSAGE. + * lib/m4sugar/m4sh.m4 (_AS_ECHO_LOG): If defined, use $as_lineno as + the line number emitted to the log file. + (AS_LINENO_PUSH, AS_LINENO_POP): New. + * tests/m4sh.at (LINENO Stack): New test. + 2008-10-14 Eric Blake Correct previous patch. diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index fbc47847..1051ef5d 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -624,7 +624,7 @@ m4_define([_AS_ECHO], # Log the string to AS_MESSAGE_LOG_FD. m4_define([_AS_ECHO_LOG], [AS_REQUIRE([_AS_LINENO_PREPARE])dnl -_AS_ECHO([$as_me:$LINENO: $1], [AS_MESSAGE_LOG_FD])]) +_AS_ECHO([$as_me:${as_lineno-$LINENO}: $1], [AS_MESSAGE_LOG_FD])]) # _AS_ECHO_N_PREPARE @@ -683,6 +683,23 @@ m4_define([AS_ERROR], +# AS_LINENO_PUSH([LINENO]) +# ------------------------ +# If this is the outermost call to AS_LINENO_PUSH, make sure that +# AS_MESSAGE will print LINENO as the line number. +m4_defun([AS_LINENO_PUSH], +[as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack]) + + +# AS_LINENO_POP([LINENO]) +# ------------------------ +# If this is call balances the outermost call to AS_LINENO_PUSH, +# AS_MESSAGE will restart printing $LINENO as the line number. +m4_defun([AS_LINENO_POP], +[eval $as_lineno_stack; test "x$as_lineno_stack" = x && AS_UNSET([as_lineno])]) + + + ## -------------------------------------- ## ## 4. Portable versions of common tools. ## ## -------------------------------------- ## diff --git a/tests/m4sh.at b/tests/m4sh.at index 1f8f8368..4951fd92 100644 --- a/tests/m4sh.at +++ b/tests/m4sh.at @@ -96,6 +96,34 @@ AT_CLEANUP +## ---------------------- ## +## LINENO stack support. ## +## ---------------------- ## + +AT_SETUP([LINENO stack]) +AT_KEYWORDS([m4sh]) + +AT_DATA_M4SH([script.as], +[[AS_INIT + +AS_LINENO_PUSH([9999]) +test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1]) +AS_LINENO_PUSH([8888]) +test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 2]) +AS_LINENO_POP +test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1]) +AS_LINENO_POP +test x${as_lineno+set} = xset && AS_ERROR([as_lineno set at depth 0]) + +AS_EXIT([0]) +]]) + +AT_CHECK_M4SH +AT_CHECK([./script]) + +AT_CLEANUP + + ## ------------ ## ## AS_DIRNAME. ## ## ------------ ##