]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Support a stack of LINENO values for AS_MESSAGE.
authorPaolo Bonzini <bonzini@gnu.org>
Mon, 13 Oct 2008 16:23:30 +0000 (18:23 +0200)
committerPaolo Bonzini <bonzini@gnu.org>
Wed, 15 Oct 2008 09:06:01 +0000 (11:06 +0200)
* 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.

ChangeLog
lib/m4sugar/m4sh.m4
tests/m4sh.at

index 8a4504c46d2cac0ce8234f557451da9cdefd5694..1f2bb12b88a7768ef5b3a7acc2875e237096a93f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-15  Paolo Bonzini  <bonzini@gnu.org>
+
+       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  <ebb9@byu.net>
 
        Correct previous patch.
index fbc47847f9c60516650bb089a427d72bc9cba284..1051ef5d6e845edf3b4584e6bfbdfb93e58aa0e8 100644 (file)
@@ -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.  ##
 ## -------------------------------------- ##
index 1f8f8368626e30e47f2d82da975c1e1f63b5e3d6..4951fd92a9d55401f98bbea56dad6f8c84227817 100644 (file)
@@ -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.  ##
 ## ------------ ##