autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02-lineno.patch


From: Akim Demaille
Subject: 02-lineno.patch
Date: Sat, 22 Sep 2001 17:22:55 +0200

While discussing with Alexandre Duret-Lutz, it became clear to both of
us that there was really no reason not to implement this now, it
causes to many annoyances to use hard coded linenos.

It behaves properly with bash and zsh.  The only difference one can
find in config.log (which is the best place to observe the difference
between LINENO and oline) is, for instance with GNU M4:

    < configure:2578: ac_nonexistent.h: No such file or directory
    ---
    > configure:2579: ac_nonexistent.h: No such file or directory

due to

    cat >conftest.$ac_ext <<_ACEOF
    #line $LINENO "configure"
    #include "confdefs.h"
    #include <ac_nonexistent.h>
    _ACEOF

with LINENO, it is the lineno of `cat' which is used, not that of the
#line line.  Fine with me.

I have not withdrawn __oline__ support from autom4te, since it is
still meaningful for instance in pure M4sugar.  And it can be useful
anyway.


It should be noted that it is now ``more correct'' than it used to be:
config.status used to log things like:

config.status:22563: creating config.h
config.status:22704: config.h is unchanged
config.status:22885: executing tests/atconfig commands
config.status:22885: executing default-1 commands
config.status:22885: executing default-2 commands
              ^^^^^
         wrt configure, of course...


Index: ChangeLog
from  Akim Demaille  <address@hidden>

        Rely on `$LINENO' when possible instead of `__oline__'.

        * lib/m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Provide some form of
        `$LINENO' support replacement when not supported.
        (_AS_CR_PREPARE, _AS_TR_CPP_PREPARE, _AS_TR_SH_PREPARE): Invoke
        them explicitly to be sure they are not output before this section
        (via m4_require).  Cosmetic only.
        * lib/autoconf/c.m4, lib/autoconf/general.m4,
        * lib/autoconf/programs.m4: Replace all the occurrences of
        `__oline__' with `$LINENO'.
        * doc/autoconf.texi (Special Shell Variables): Document LINENO.

Index: NEWS
--- NEWS Wed, 05 Sep 2001 15:50:08 +0200 akim
+++ NEWS Sat, 22 Sep 2001 15:15:12 +0200 akim
@@ -1,8 +1,8 @@
 * Major changes in Autoconf 2.52e                       -*- outline -*-
-** Licensing
-  The Autoconf manual is now distributed under the terms of the GNU FDL.
+
 ** Requirements
-  Perl 5.005 is now required to run Autoconf.
+  Perl 5.005 is required.
+
 ** Documentation
 - AC_INIT
   Argument requirements, output variables, defined macros.
@@ -10,23 +10,36 @@
   First sketch of its documentation.
 - Double quoting macros
   AC_TRY_CPP, AC_TRY_COMPILE, AC_TRY_LINK and AC_TRY_RUN.
+- Licensing
+  The Autoconf manual is now distributed under the terms of the GNU FDL.
+
+** $LINENO
+  Is now used instead of hard coded line numbers.
+  This eases the comparison of `configure's, and diminishes the
+  pressure over control version archives.
+  Automatic replacement for shells that don't support this feature.
+
 ** autom4te
   New executable, used by the Autoconf suite to cache and speed up
-  some processing.
+  most processing.
+
 ** Standardization of the executables interface
 - --force, -f
   Supported by autom4te, autoconf and autoheader.
 - --include, -I
   Replaces --autoconf-dir and --localdir in autoconf, autoheader and
   autoupdate.
+
 ** Bug fixes
 - The top level $prefix is propagated to the AC_CONFIG_SUBDIRS configures.
+
 ** C Macros
 - AC_C_BIGENDIAN supports the cross-compiling case.
 - AC_C_BIGENDIAN accepts ACTION-IF-TRUE, ACTION-IF-FALSE, and
   ACTION-IF-UNKNOWN arguments.  All are facultative, and the default
   for ACTION-IF-TRUE is to define WORDS_BIGENDIAN like AC_C_BIGENDIAN
   always did.
+
 ** Generic macros
 - AC_CONFIG_COMMANDS, HEADERS, FILES, LINKS.
   Provide the user with srcdir, ac_top_srcdir, ac_top_builddir, ac_srcdir.
Index: doc/autoconf.texi
--- doc/autoconf.texi Tue, 18 Sep 2001 20:53:46 +0200 akim
+++ doc/autoconf.texi Sat, 22 Sep 2001 15:35:18 +0200 akim
@@ -8122,6 +8122,52 @@ dot:
 using @samp{C} as a fall back value. see @ref{Limitations of Builtins},
 builtin @command{unset}, for more details.

address@hidden LINENO
address@hidden LINENO
+Most modern shells provide the current line number in @code{LINENO}.
+Its value is the line number of the beginning of the current command
+(see below the output of the here document).  The behavior wrt
address@hidden differs according to the shell, but, amusingly, not in
+the case of sub shells:
+
address@hidden
address@hidden
+$ cat lineno
+echo 1. $LINENO
+cat <<EOF
+3. $LINENO
+4. $LINENO
+EOF
+( echo 6. $LINENO )
+eval 'echo 7. $LINENO'
address@hidden group
address@hidden
+$ ash lineno
+1.
+3.
+4.
+6.
+7.
address@hidden group
address@hidden
+$ bash-2.03 lineno
+1. 1
+3. 2
+4. 2
+6. 6
+7. 1
address@hidden group
address@hidden
+$ zsh-3.1.9 lineno
+1. 1
+3. 2
+4. 2
+6. 6
+7. 7
address@hidden group
address@hidden example
+
+
 @item NULLCMD
 @evindex NULLCMD
 When executing the command @samp{>foo}, @command{zsh} executes
Index: lib/autoconf/c.m4
--- lib/autoconf/c.m4 Tue, 18 Sep 2001 20:53:46 +0200 akim
+++ lib/autoconf/c.m4 Sat, 22 Sep 2001 13:57:28 +0200 akim
@@ -119,9 +119,9 @@ m4_define([_AC_LANG_ABBREV(C++)], [cxx])
 # AC_LANG_SOURCE(C)(BODY)
 # -----------------------
 # This sometimes fails to find confdefs.h, for some reason.
-# #line __oline__ "$[0]"
+# #line $LINENO "$[0]"
 m4_define([AC_LANG_SOURCE(C)],
-[#line __oline__ "configure"
+[#line $LINENO "configure"
 #include "confdefs.h"
 $1])

@@ -413,7 +413,7 @@ AC_DEFUN([AC_PROG_CC],
 test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])

 # Provide some information about the compiler.
-echo "$as_me:__oline__:" \
+echo "$as_me:$LINENO:" \
      "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
 ac_compiler=`set X $ac_compile; echo $[2]`
 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
@@ -624,7 +624,7 @@ AC_DEFUN([AC_PROG_CXX],
                g++)

 # Provide some information about the compiler.
-echo "$as_me:__oline__:" \
+echo "$as_me:$LINENO:" \
      "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
 ac_compiler=`set X $ac_compile; echo $[2]`
 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
Index: lib/autoconf/general.m4
--- lib/autoconf/general.m4 Tue, 18 Sep 2001 20:53:46 +0200 akim
+++ lib/autoconf/general.m4 Sat, 22 Sep 2001 13:57:52 +0200 akim
@@ -1936,7 +1936,7 @@ m4_define([AC_WARNING],
 # AC_MSG_CHECKING(FEATURE)
 # ------------------------
 m4_define([AC_MSG_CHECKING],
-[_AS_ECHO([$as_me:__oline__: checking $1], AS_MESSAGE_LOG_FD)
+[_AS_ECHO([$as_me:$LINENO: checking $1], AS_MESSAGE_LOG_FD)
 _AS_ECHO_N([checking $1... ])[]dnl
 ])

@@ -1944,7 +1944,7 @@ m4_define([AC_MSG_CHECKING],
 # AC_MSG_RESULT(RESULT)
 # ---------------------
 m4_define([AC_MSG_RESULT],
-[_AS_ECHO([$as_me:__oline__: result: $1], AS_MESSAGE_LOG_FD)
+[_AS_ECHO([$as_me:$LINENO: result: $1], AS_MESSAGE_LOG_FD)
 _AS_ECHO([${ECHO_T}$1])[]dnl
 ])

@@ -1953,7 +1953,7 @@ m4_define([AC_MSG_RESULT],
 # ------------------------------
 # Likewise, but perform $ ` \ shell substitutions.
 m4_define([AC_MSG_RESULT_UNQUOTED],
-[_AS_ECHO_UNQUOTED([$as_me:__oline__: result: $1], AS_MESSAGE_LOG_FD)
+[_AS_ECHO_UNQUOTED([$as_me:$LINENO: result: $1], AS_MESSAGE_LOG_FD)
 _AS_ECHO_UNQUOTED([${ECHO_T}$1])[]dnl
 ])

@@ -1994,7 +1994,7 @@ AC_DEFUN([_AC_RUN_LOG],
 [{ ($2) >&AS_MESSAGE_LOG_FD
   ($1) 2>&AS_MESSAGE_LOG_FD
   ac_status=$?
-  echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+  echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
   (exit $ac_status); }])


@@ -2010,7 +2010,7 @@ AC_DEFUN([_AC_RUN_LOG_STDERR],
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&AS_MESSAGE_LOG_FD
-  echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+  echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
   (exit $ac_status); }])


@@ -2019,7 +2019,7 @@ AC_DEFUN([_AC_RUN_LOG_STDERR],
 # Eval COMMAND, save the exit status in ac_status, and log it.
 AC_DEFUN([_AC_EVAL],
 [_AC_RUN_LOG([eval $1],
-             [eval echo "$as_me:__oline__: \"$1\""])])
+             [eval echo "$as_me:$LINENO: \"$1\""])])


 # _AC_EVAL_STDERR(COMMAND)
@@ -2029,7 +2029,7 @@ AC_DEFUN([_AC_EVAL],
 # Note that when tracing, most shells will leave the traces in stderr
 AC_DEFUN([_AC_EVAL_STDERR],
 [_AC_RUN_LOG_STDERR([eval $1],
-                    [eval echo "$as_me:__oline__: \"$1\""])])
+                    [eval echo "$as_me:$LINENO: \"$1\""])])


 # AC_TRY_EVAL(VARIABLE)
@@ -2051,7 +2051,7 @@ AC_DEFUN([AC_TRY_COMMAND],
 # -------------------
 AC_DEFUN([AC_RUN_LOG],
 [_AC_RUN_LOG([$1],
-             [echo "$as_me:__oline__: AS_ESCAPE([$1])"])])
+             [echo "$as_me:$LINENO: AS_ESCAPE([$1])"])])


 ## ------------------ ##
Index: lib/autoconf/programs.m4
--- lib/autoconf/programs.m4 Wed, 12 Sep 2001 17:50:53 +0200 akim
+++ lib/autoconf/programs.m4 Sat, 22 Sep 2001 13:58:13 +0200 akim
@@ -77,7 +77,7 @@ AC_DEFUN([AC_CHECK_PROG],
   continue
 fi])dnl
 ac_cv_prog_$1="$3"
-echo "$as_me:__oline__: found $as_dir/$ac_word" >&AS_MESSAGE_LOG_FD
+echo "$as_me:$LINENO: found $as_dir/$ac_word" >&AS_MESSAGE_LOG_FD
 break])
 m4_ifvaln([$6],
 [if test $ac_prog_rejected = yes; then
@@ -142,7 +142,7 @@ AC_DEFUN([AC_PATH_PROG],
   _AS_PATH_WALK([$4],
 [if AS_EXECUTABLE_P("$as_dir/$ac_word"); then
    ac_cv_path_$1="$as_dir/$ac_word"
-   echo "$as_me:__oline__: found $as_dir/$ac_word" >&AS_MESSAGE_LOG_FD
+   echo "$as_me:$LINENO: found $as_dir/$ac_word" >&AS_MESSAGE_LOG_FD
    break
 fi])
 dnl If no 3rd arg is given, leave the cache variable unset,
Index: lib/m4sugar/m4sh.m4
--- lib/m4sugar/m4sh.m4 Tue, 18 Sep 2001 20:53:46 +0200 akim
+++ lib/m4sugar/m4sh.m4 Sat, 22 Sep 2001 15:05:57 +0200 akim
@@ -112,12 +112,45 @@ m4_define([_m4_divert(M4SH-INIT)],
 # Name of the executable.
 as_me=`AS_BASENAME($[0])`

+# If LINENO is not supported by the shell, produce a version of this
+# script where LINENO is hard coded.  Rewrite if not up to date only.
+# Comparing LINENO against _oline_ is not a good solution, since in
+# the case of embedded executables (such as config.status within
+# configure) you'd compare LINENO wrt config.status vs. _oline_ vs
+# configure.  Hence a useless rewrite (not to mention the risk of
+# ``infinite'' rewrites.  Merely check that LINENO is incremented
+# between two lines, which is a property guaranteed for _oline_, hence
+# it protects us from repetitive rewrites.
+as_lineno_1=$LINENO
+as_lineno_2=$LINENO
+# Compute as_lineno_1 in two steps: some shells restart LINENO for
+# subshells.
+as_lineno_1=`(expr $as_lineno_1 + 1) 2>/dev/null`
+if test "x$as_lineno_1" != "x$as_lineno_2"; then
+  if test ! -f $as_me.lineno ||
+     test x`ls -1dt $as_me.lineno $as_me 2>/dev/null | sed 1q` \
+                != x$as_me.lineno; then
+     # Be sure to write the pattern so that it doesn't replace itself:
+     # it must not match itself.
+     awk '{
+            if ($[0] ~ /[[$]]LINENO/)
+              while (sub (/[[$]]LINENO/, NR))
+                continue
+            print
+          }' <$as_me >$as_me.lineno
+    chmod +x $as_me.lineno
+  fi
+  exec ${SHELL-/bin/sh} ./$as_me.lineno
+fi
+
+_AS_CR_PREPARE
 _AS_ECHO_N_PREPARE
 _AS_EXPR_PREPARE
 _AS_LN_S_PREPARE
 _AS_PATH_SEPARATOR_PREPARE
 _AS_TEST_PREPARE
-_AS_TR_PREPARE
+_AS_TR_CPP_PREPARE
+_AS_TR_SH_PREPARE
 _AS_UNSET_PREPARE

 # NLS nuisances.
@@ -303,7 +336,7 @@ m4_define([_AS_ECHO_N],
 # ----------------------------------------
 m4_define([AS_MESSAGE],
 [m4_ifset([AS_MESSAGE_LOG_FD],
-          [{ _AS_ECHO([$as_me:__oline__: $1], [AS_MESSAGE_LOG_FD])
+          [{ _AS_ECHO([$as_me:$LINENO: $1], [AS_MESSAGE_LOG_FD])
 _AS_ECHO([$as_me: $1], [$2]);}],
           [_AS_ECHO([$as_me: $1], [$2])])[]dnl
 ])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]