autoconf-patches
[Top][All Lists]
Advanced

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

Re: proposed patch for "Tests failed with LINENO." Autoconf bug


From: Paul Eggert
Subject: Re: proposed patch for "Tests failed with LINENO." Autoconf bug
Date: Fri, 26 Oct 2001 13:56:17 -0700 (PDT)

> From: Akim Demaille <address@hidden>
> Date: 26 Oct 2001 12:30:51 +0200
> 
> configure.ac needs to be adjusted (and in fact lib/Autom4te/General.pm
> should have it too)....

Also NEWS, README, and Struct.pm.

> Thanks a lot Paul.  If you have some spare time to add information to
> the documentation...

OK, I installed the following change, which I hope addresses the above issues.

Could you please look over the autoconf.texi change in particular?
(If we got rid of the Awk+Sed hack, the LINENO documentation could get
a lot shorter.  :-)

2001-10-26  Paul Eggert  <address@hidden>

        * NEWS, README, configure.ac, lib/Autom4te/General.pm,
          lib/Autom4te/Struct.pm:
        Require Perl 5.005_03 instead of just 5.005, as some tests fail
        with 5.005_02.

        * doc/autoconf.texi (Special Shell Variables): Document some
        more LINENO gotchas, particularly with respect to the Awk+Sed hack.

        * lib/m4sugar/m4sh.m4 (_AS_LINENO_WORKS): New macro.
        (_AS_LINENO_PREPARE): Use it instead of shell eval, since
        eval $LINENO is not portable in practice.

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.202
diff -p -u -r1.202 NEWS
--- NEWS        2001/10/22 17:51:16     1.202
+++ NEWS        2001/10/26 19:35:17
@@ -1,8 +1,9 @@
 * Major changes in Autoconf 2.52e                       -*- outline -*-
 
 ** Requirements
-  Perl 5.005 is required: autom4te is written in Perl and is needed by
-  autoconf.  autoheader, autoreconf, ifnames, and autoscan are
+
+  Perl 5.005_03 or later is required: autom4te is written in Perl and is
+  needed by autoconf.  autoheader, autoreconf, ifnames, and autoscan are
   rewritten in Perl.
 
 ** Documentation
Index: README
===================================================================
RCS file: /cvsroot/autoconf/autoconf/README,v
retrieving revision 1.15
diff -p -u -r1.15 README
--- README      2001/08/20 15:16:54     1.15
+++ README      2001/10/26 19:35:17
@@ -11,7 +11,7 @@ operating system features that the packa
 macro calls.
 
 Producing configuration scripts using Autoconf requires GNU M4 and
-Perl.  You must install GNU M4 (version 1.4 or later) and Perl (5.005
+Perl.  You must install GNU M4 (version 1.4 or later) and Perl (5.005_03
 or later) before configuring Autoconf, so that Autoconf's configure
 script can find them.  The configuration scripts produced by Autoconf
 are self-contained, so their users do not need to have Autoconf (or
Index: configure.ac
===================================================================
RCS file: /cvsroot/autoconf/autoconf/configure.ac,v
retrieving revision 1.25
diff -p -u -r1.25 configure.ac
--- configure.ac        2001/10/24 13:30:57     1.25
+++ configure.ac        2001/10/26 19:35:30
@@ -72,8 +72,8 @@ AC_SUBST(PERL)dnl
 if test "$PERL" = no; then
   AC_MSG_ERROR([perl is not found])
 fi
-$PERL -e 'require 5.005;' || {
-   AC_MSG_ERROR([Perl 5.005 or better is required])
+$PERL -e 'require 5.005_03;' || {
+   AC_MSG_ERROR([Perl 5.005_03 or better is required])
 }
 
 # Emacs modes.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.554
diff -p -u -r1.554 autoconf.texi
--- doc/autoconf.texi   2001/10/23 17:18:44     1.554
+++ doc/autoconf.texi   2001/10/26 19:36:33
@@ -8187,11 +8187,20 @@ builtin @command{unset}, for more detail
 @item LINENO
 @evindex 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:
+Its value is the line number of the beginning of the current command.
+Autoconf attempts to execute @command{configure} with a modern shell.
+If no such shell is available, it attempts to implement @code{LINENO}
+with a simple Awk+Sed prepass that replaces the first instance of the
+string @code{$LINENO} in each line with the line's number.
 
+You should not rely on @code{LINENO} within @command{eval}, as the
+behavior differs in practice.  Also, the possibility of the Awk+Sed
+prepass means that you should not rely on @code{$LINENO} when quoted,
+when in here-documents, or when in long commands that cross line
+boundaries or that have multiple instances of $LINENO.  Subshells
+should be OK, though.  In the following example, lines 1, 6, and 10
+are portable, but the other instances of @code{LINENO} are not:
+
 @example
 @group
 $ @kbd{cat lineno}
@@ -8202,30 +8211,34 @@ cat <<EOF
 EOF
 ( echo 6. $LINENO )
 eval 'echo 7. $LINENO'
address@hidden group
address@hidden
-$ @kbd{ash lineno}
-1.
-3.
-4.
-6.
-7.
+echo 8. $LINENO $LINENO
+echo 9. '$LINENO'
+echo 10. $LINENO '
+11.' $LINENO
 @end group
 @group
-$ @kbd{bash-2.03 lineno}
+$ @kbd{bash-2.05 lineno}
 1. 1
 3. 2
 4. 2
 6. 6
 7. 1
+8. 8 8
+9. $LINENO
+10. 10 
+11. 10
 @end group
 @group
-$ @kbd{zsh-3.1.9 lineno}
+$ @kbd{zsh-3.0.6 lineno}
 1. 1
 3. 2
 4. 2
 6. 6
 7. 7
+8. 8 8
+9. $LINENO
+10. 10 
+11. 10
 @end group
 @group
 $ @kbd{pdksh-5.2.14 lineno}
@@ -8234,6 +8247,24 @@ $ @kbd{pdksh-5.2.14 lineno}
 4. 2
 6. 6
 7. 0
+8. 8 8
+9. $LINENO
+10. 10 
+11. 10
address@hidden group
address@hidden
+$ @kbd{awk '/\$LINENO/@{printf "%d:", address@hidden; @address@hidden' lineno 
|}
+> @kbd{sed '/\$LINENO/s/^\([^:]*\):\(.*\)\$LINENO/\2\1/' |}
+> @kbd{sh}
+1. 1
+3. 3
+4. 4
+6. 6
+7. 7
+8. 8
+9. 9
+10. 10 
+11. 11
 @end group
 @end example
 
Index: lib/Autom4te/General.pm
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/Autom4te/General.pm,v
retrieving revision 1.15
diff -p -u -r1.15 General.pm
--- lib/Autom4te/General.pm     2001/10/24 14:29:16     1.15
+++ lib/Autom4te/General.pm     2001/10/26 19:36:40
@@ -18,7 +18,7 @@
 
 package Autom4te::General;
 
-use 5.005;
+use 5.005_03;
 use Exporter;
 use File::Basename;
 use File::stat;
Index: lib/Autom4te/Struct.pm
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/Autom4te/Struct.pm,v
retrieving revision 1.2
diff -p -u -r1.2 Struct.pm
--- lib/Autom4te/Struct.pm      2001/08/04 13:14:39     1.2
+++ lib/Autom4te/Struct.pm      2001/10/26 19:36:48
@@ -26,7 +26,7 @@ package Autom4te::Struct;
 
 ## See POD after __END__
 
-use 5.005;
+use 5.005_03;
 
 use strict;
 use vars qw(@ISA @EXPORT $VERSION);
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.66
diff -p -u -r1.66 m4sh.m4
--- lib/m4sugar/m4sh.m4 2001/10/19 00:20:03     1.66
+++ lib/m4sugar/m4sh.m4 2001/10/26 19:36:51
@@ -459,6 +459,17 @@ else
 fi
 ])# _AS_EXPR_PREPARE
 
+# _AS_LINENO_WORKS
+# ---------------
+# Succeed if the currently executing shell supports LINENO.
+m4_define([_AS_LINENO_WORKS],
+[{
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x$as_lineno_3"  = "x$as_lineno_2"
+}])
 
 # _AS_LINENO_PREPARE
 # ------------------
@@ -473,16 +484,7 @@ fi
 # it protects us from repetitive rewrites.  Be sure to have a test
 # that does detect non LINENO support...
 m4_define([_AS_LINENO_PREPARE],
-[as_command='
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2"
-'
-if eval "$as_command"; then
-  :
-else
+[_AS_LINENO_WORKS || {
   # Find who we are.  Look in the path if we contain no path at all
   # relative or not.
   case $[0] in
@@ -505,7 +507,7 @@ else
       [for as_base in sh bash ksh sh5; do
         case $as_dir in
         /*)
-          if ("$as_dir/$as_base" -c "$as_command") 2>/dev/null; then
+          if ("$as_dir/$as_base" -c '_AS_LINENO_WORKS') 2>/dev/null; then
             CONFIG_SHELL=$as_dir/$as_base
             export CONFIG_SHELL
             exec "$CONFIG_SHELL" "$[0]" ${1+"address@hidden"}
@@ -533,7 +535,7 @@ else
   . ./$as_me.lineno
   # Exit status is that of the last command.
   exit
-fi
+}
 ])# _AS_LINENO_PREPARE
 
 



reply via email to

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