[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
17-fyi-fix-lineno.patch
From: |
Akim Demaille |
Subject: |
17-fyi-fix-lineno.patch |
Date: |
Fri, 05 Oct 2001 18:21:37 +0200 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* tests/m4sh.at (LINENO): New.
* lib/m4sugar/m4sh.m4 (AS_SHELL_SANITIZE): Be sure to set
PATH_SEPARATOR before using it.
Fix the absolute path case/esac pattern.
Provide $0 as fallback for as_myself.
Reported by Raja R Harinath.
Index: lib/m4sugar/m4sh.m4
--- lib/m4sugar/m4sh.m4 Fri, 05 Oct 2001 16:26:43 +0200 akim
+++ lib/m4sugar/m4sh.m4 Fri, 05 Oct 2001 18:00:06 +0200 akim
@@ -113,14 +113,14 @@ m4_define([_m4_divert(M4SH-INIT)],
# Name of the executable.
as_me=`AS_BASENAME($[0])`
-# Rewrite early.
+# Rewrite early, but we need PATH_SEPARATOR.
+_AS_PATH_SEPARATOR_PREPARE
_AS_LINENO_PREPARE
_AS_CR_PREPARE
_AS_ECHO_N_PREPARE
_AS_EXPR_PREPARE
_AS_LN_S_PREPARE
-_AS_PATH_SEPARATOR_PREPARE
_AS_TEST_PREPARE
_AS_TR_CPP_PREPARE
_AS_TR_SH_PREPARE
@@ -428,17 +428,22 @@ m4_define([_AS_LINENO_PREPARE],
then
# Find who we are.
case $[0] in
- *[[\\/]]* | ?:[[\\/]]* ) as_myself=$[0] ;;
+ [[\\/]]* | ?:[[\\/]]* ) as_myself=$[0] ;;
*) _AS_PATH_WALK([],
[test -r "$as_dir/$[0]" && as_myself=$as_dir/$[0] && break])
;;
esac
- if test ! -f $as_myself; then
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$[0]
+ fi
+ if test ! -f "$as_myself"; then
AS_ERROR([cannot find myself; rerun with an absolute path])
fi
- 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
+ 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 '
Index: tests/m4sh.at
--- tests/m4sh.at Tue, 18 Sep 2001 20:53:46 +0200 akim
+++ tests/m4sh.at Fri, 05 Oct 2001 18:07:44 +0200 akim
@@ -22,6 +22,73 @@
# Used in many tests.
m4_pattern_allow([^AS_EXIT$])
+## ---------------- ##
+## LINENO support. ##
+## ---------------- ##
+
+AT_SETUP([LINENO])
+
+# AT_DATA_LINENO(FILENAME,
+# UNSET-LINENO = true | false, COUNTER, COUNTER-RE)
+# ----------------------------------------------------------------
+# Produce FILENAME which uses the COUNTER LINENO or _oline_, which
+# we can recognized via COUNTER-RE. Unset LINENO is UNSET-LINENO.
+#
+# Use COUNTER, COUNTER-RE = [$@&address@hidden, [LINENO]
+# or = [__@&address@hidden, [_oline__]
+# to make sure we are not replace in the test suite itself and to avoid
+# seeing the COUNTER-RE being replaced.
+#
+# UNSET-LINENO is a shell condition to make sure the scripts have the
+# same number of lines in the output, so that their outputs be identical.
+m4_define([AT_DATA_LINENO],
+[AT_DATA([$1],
+[[AS@&address@hidden
+m4@&address@hidden([0])d@&address@hidden
+m4@&address@hidden([m4@&address@hidden([0])[]])d@&address@hidden
+#! /bin/sh
+if $2; then
+ AS@&address@hidden([LINENO])
+fi
+AS@&address@hidden
+echo "Line: $3"
+grep 'Line: .*$4' $[0] >/dev/null ||
+ AS@&address@hidden([cannot find original script])
+exit 0
+]])
+])# AT_DATA_LINENO
+
+# `_oline_', once processed and ran, produces our reference.
+# We check that we find ourself by looking at a string which is
+# available only in the original script: `_oline_'.
+AT_DATA_LINENO([reference.as], [false], [__@&address@hidden, [_oline__])
+AT_CHECK([autom4te -l m4sh reference.as -o reference])
+AT_CHECK([./reference], 0, [stdout])
+
+# The reference:
+mv stdout expout
+
+# Now using a maybe-functioning LINENO, with different call conventions.
+# Be sure to be out of the PATH.
+AT_CHECK([mkdir test || exit 77])
+
+AT_DATA_LINENO([test/test-1.as], [false], [$@&address@hidden, [LINENO])
+AT_CHECK([autom4te -l m4sh test/test-1.as -o test/test-1])
+AT_CHECK([test/test-1], 0, [expout])
+AT_CHECK([PATH=test$PATH_SEPARATOR$PATH test-1], 0, [expout])
+AT_CHECK([sh test/test-1], 0, [expout])
+
+# Now using a disabled LINENO, with different call conventions.
+AT_DATA_LINENO([test/test-2.as], [true], [$@&address@hidden, [LINENO])
+AT_CHECK([autom4te -l m4sh test/test-2.as -o test/test-2])
+AT_CHECK([test/test-2], 0, [expout])
+AT_CHECK([PATH=test$PATH_SEPARATOR$PATH test-2], 0, [expout])
+AT_CHECK([sh test/test-2], 0, [expout])
+
+# Beware that *.lineno scripts can be *here* while the masters are in test/.
+AT_CLEANUP(reference test test-1.lineno test-2.lineno)
+
+
## ----------------------------- ##
## AS_DIRNAME & AS_DIRNAME_SED. ##
## ----------------------------- ##
- 17-fyi-fix-lineno.patch,
Akim Demaille <=