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: Sun, 28 Oct 2001 15:22:33 -0800 (PST)

> From: Raja R Harinath <address@hidden>
> Date: Sat, 27 Oct 2001 16:59:05 -0500
> 
> Sorry, I'm flogging a dead horse.

Yes; more and more I want to send it to the glue factory.

> awk is not mentioned in the set of "allowed to use" utilities in
> standards.texi

True.  I'd forgotten about that.  Here's a proposed patch to fix this
dead horse one more time.  It uses Sed exclusively, instead of Awk.
It also fixes some of the other bugs we've talked about, but not all
of them.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.555
diff -p -u -r1.555 autoconf.texi
--- doc/autoconf.texi   2001/10/26 19:52:07     1.555
+++ doc/autoconf.texi   2001/10/28 23:18:57
@@ -8190,16 +8190,17 @@ Most modern shells provide the current l
 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.
+with a Sed prepass that replaces the each instance of the string
address@hidden (not followed by an alphanumeric character) 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
+behavior differs in practice.  Also, the possibility of the 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:
+boundaries.  Subshells should be OK, though.  In the following
+example, lines 1, 6, and 9 are portable, but the other instances of
address@hidden are not:
 
 @example
 @group
@@ -8211,10 +8212,9 @@ cat <<EOF
 EOF
 ( echo 6. $LINENO )
 eval 'echo 7. $LINENO'
-echo 8. $LINENO $LINENO
-echo 9. '$LINENO'
-echo 10. $LINENO '
-11.' $LINENO
+echo 8. '$LINENO'
+echo 9. $LINENO '
+10.' $LINENO
 @end group
 @group
 $ @kbd{bash-2.05 lineno}
@@ -8223,10 +8223,9 @@ $ @kbd{bash-2.05 lineno}
 4. 2
 6. 6
 7. 1
-8. 8 8
-9. $LINENO
-10. 10 
-11. 10
+8. $LINENO
+9. 9
+10. 9
 @end group
 @group
 $ @kbd{zsh-3.0.6 lineno}
@@ -8235,10 +8234,9 @@ $ @kbd{zsh-3.0.6 lineno}
 4. 2
 6. 6
 7. 7
-8. 8 8
-9. $LINENO
-10. 10 
-11. 10
+8. $LINENO
+9. 9
+10. 9
 @end group
 @group
 $ @kbd{pdksh-5.2.14 lineno}
@@ -8247,14 +8245,20 @@ $ @kbd{pdksh-5.2.14 lineno}
 4. 2
 6. 6
 7. 0
-8. 8 8
-9. $LINENO
-10. 10 
-11. 10
+8. $LINENO
+9. 9
+10. 9
 @end group
 @group
-$ @kbd{awk '/\$LINENO/@{printf "%d:", address@hidden; @address@hidden' lineno 
|}
-> @kbd{sed '/\$LINENO/s/^\([^:]*\):\(.*\)\$LINENO/\2\1/' |}
+$ @kbd{sed '=; s/^/X/' <lineno |}
+> @kbd{  sed '}
+> @kbd{    /^[0-9]/N}
+> @kbd{    : loop}
+> @kbd{      s/^\([0-9]*\)\(.*\)[$]LINENO\([^a-zA-Z0-9_]\)/\1\2\1\3/}
+> @kbd{      s/^\([0-9]*\)\(.*\)[$]LINENO$/\1\2\1/}
+> @kbd{    t loop}
+> @kbd{    s/.*\nX//}
+> @kbd{  ' |}
 > @kbd{sh}
 1. 1
 3. 3
@@ -8264,7 +8268,6 @@ $ @kbd{awk '/\$LINENO/@{printf "%d:", NR
 8. 8
 9. 9
 10. 10 
-11. 11
 @end group
 @end example
 
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.67
diff -p -u -r1.67 m4sh.m4
--- lib/m4sugar/m4sh.m4 2001/10/26 19:52:43     1.67
+++ lib/m4sugar/m4sh.m4 2001/10/28 23:19:04
@@ -474,15 +474,11 @@ m4_define([_AS_LINENO_WORKS],
 # _AS_LINENO_PREPARE
 # ------------------
 # 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.
+# script where LINENO is hard coded.
 # 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.  Be sure to have a test
-# that does detect non LINENO support...
+# configure.
 m4_define([_AS_LINENO_PREPARE],
 [_AS_LINENO_WORKS || {
   # Find who we are.  Look in the path if we contain no path at all
@@ -515,19 +511,20 @@ m4_define([_AS_LINENO_PREPARE],
         esac
        done]);;
   esac
-  if test ! -f "$as_me.lineno" ||
-     test x`ls -1dt "$as_me.lineno" "$as_myself" 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 <$as_myself '
-           /[[$]]LINENO/ { printf "%d:", NR }
-                         { print }
-         ' |
-       sed ['/[$]LINENO/s/^\([0-9][0-9]*\):\(.*\)[$]LINENO/\2\1/'] \
-         >$as_me.lineno
-    chmod +x $as_me.lineno
-  fi
+
+  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+  # uniformly replaced by the line number.
+  sed '=; s/^/X/' <$as_myself |
+    sed '
+      /^[[0-9]]/N
+      : loop
+       s/^\([[0-9]]*\)\(.*\)[[$]]LINENO\([[^a-zA-Z0-9_]]\)/\1\2\1\3/
+       s/^\([[0-9]]*\)\(.*\)[[$]]LINENO$/\1\2\1/
+      t loop
+      s/.*\nX//
+    ' >$as_me.lineno &&
+  chmod +x $as_me.lineno ||
+    AS_ERROR([cannot create $as_me.lineno; rerun with a POSIX shell])
 
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the



reply via email to

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