]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* tests/m4sh.at (LINENO): New.
authorAkim Demaille <akim@epita.fr>
Fri, 5 Oct 2001 16:12:22 +0000 (16:12 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 5 Oct 2001 16:12:22 +0000 (16:12 +0000)
* 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.

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

index 740c6139aedb15e2272b5abbbdd62de4f1108152..ad29cc08f8526f75fbfb27fe0296a826b89f95d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2001-10-05  Akim Demaille  <akim@epita.fr>
+
+       * 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.
+
 2001-10-05  Akim Demaille  <akim@epita.fr>
 
        * Makefile.am, config/Makefile.am, lib/emacs/Makefile.am,
index 6a0c7349cf6d31d39e606a89e397774edd85eadd..c5c2e1f2205a479c26c851bca397aebe68b71858 100644 (file)
@@ -113,14 +113,14 @@ fi
 # 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 @@ if test "x$as_lineno_1"  = "x$as_lineno_2" ||
   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 2dc78f749e2ab601480e3288d56b0ddf0095997f..39bf90d243def39dcb8ea9f54c460a58d6caa912 100644 (file)
@@ -22,6 +22,73 @@ AT_BANNER([M4sh.])
 # 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 = [$@&t@LINENO],   [LINENO]
+#  or                     = [__@&t@oline__], [_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@&t@_INIT
+m4@&t@_divert_push([0])d@&t@nl
+m4@&t@_wrap([m4@&t@_divert_pop([0])[]])d@&t@nl
+#! /bin/sh
+if $2; then
+  AS@&t@_UNSET([LINENO])
+fi
+AS@&t@_SHELL_SANITIZE
+echo "Line: $3"
+grep 'Line: .*$4' $[0] >/dev/null ||
+  AS@&t@_ERROR([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], [__@&t@oline__], [_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], [$@&t@LINENO], [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], [$@&t@LINENO], [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.  ##
 ## ----------------------------- ##