]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* tests/m4sh.at: Ensure that AS_DIRNAME handles '/', '//' and '///'
authorAkim Demaille <akim@epita.fr>
Tue, 18 Sep 2001 12:26:36 +0000 (12:26 +0000)
committerAkim Demaille <akim@epita.fr>
Tue, 18 Sep 2001 12:26:36 +0000 (12:26 +0000)
correctly.
Add test for AS_BASENAME.
* lib/m4sugar/m4sh.m4: Fix AS_BASENAME so that it passes the previous
added test. It now correctly handles /1/2/3/, returning '3' not ''.
Added AS_BASENAME_SED to make the interface the same as AS_DIRNAME.
* tests/base.at: Fixed the expected responses. The old ones were
one line out...
* lib/autoconf/general.m4: Fixed AC_PREFIX_PROGRAM, it now behaves as
the documentation claims it should (and how it behaved in 2.13).

ChangeLog
lib/autoconf/general.m4
lib/m4sugar/m4sh.m4
tests/base.at
tests/m4sh.at

index f19cb65b59a627834f2f610b0282a04eb9934de3..35189e788d5a2cbcbf5a8289e0370d09316bba01 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2001-09-18  Paul Wagland   <paul@wagland.net>
+
+       * tests/m4sh.at: Ensure that AS_DIRNAME handles '/', '//' and '///'
+       correctly.
+       Add test for AS_BASENAME.
+       * lib/m4sugar/m4sh.m4: Fix AS_BASENAME so that it passes the previous
+       added test. It now correctly handles /1/2/3/, returning '3' not ''.
+       Added AS_BASENAME_SED to make the interface the same as AS_DIRNAME.
+       * tests/base.at: Fixed the expected responses. The old ones were
+       one line out...
+       * lib/autoconf/general.m4: Fixed AC_PREFIX_PROGRAM, it now behaves as
+       the documentation claims it should (and how it behaved in 2.13).
+
 2001-09-18  Akim Demaille  <akim@epita.fr>
 
        * lib/autoconf/autotest.m4 (AC_CONFIG_TESTDIR): No INIT-CMDS in
index bc2728b1c502377409b1f989026cf4b42c345550..a3ff10053c1a9049806ad85cbc8f9574c4e99a15 100644 (file)
@@ -522,6 +522,7 @@ dnl We reimplement AC_MSG_CHECKING (mostly) to avoid the ... in the middle.
   AC_PATH_PROG(AC_Prog, [$1])
   if test -n "$ac_cv_path_[]AC_Prog"; then
     prefix=`AS_DIRNAME(["$ac_cv_path_[]AC_Prog"])`
+    prefix=`AS_DIRNAME(["$prefix"])`
   fi
 fi
 m4_popdef([AC_Prog])dnl
index 550110b667ad28a3e4b30418728f8df457977714..9e63a9ede2d4ff1fc18ffa9ece6907ad09839068 100644 (file)
@@ -372,8 +372,11 @@ AS_DIRNAME_SED([$1])])
 # --------------------
 # Simulate running `basename(1)' on PATHNAME, not all systems have it.
 # This macro must be usable from inside ` `.
+m4_defun([AS_BASENAME_SED],
+[echo "$1" |sed 's,\(.*[[\\/]]\+\)\?\([[^\\/]]\+\)[[\\/]]*,\2,'])
+
 m4_defun([AS_BASENAME],
-[echo "$1" |sed 's,.*[[\\/]],,'])
+[AS_BASENAME_SED([$1])])
 
 # AS_EXECUTABLE_P
 # ---------------
index ea80c8f7e663b54f3cecdcb5435c6d8e539757b0..49fc01390b80674b30b4139918ca2d622541fc85 100644 (file)
@@ -98,8 +98,8 @@ esac
 ]])
 
 AT_CHECK_AUTOCONF([], 0, [],
-[configure.ac:18: warning: SINGLE_TEST invoked multiple times
-configure.ac:19: warning: SINGLE_TEST invoked multiple times
+[configure.ac:17: warning: SINGLE_TEST invoked multiple times
+configure.ac:18: warning: SINGLE_TEST invoked multiple times
 ])
 
 AT_CHECK_CONFIGURE
@@ -143,7 +143,7 @@ esac
 ]])
 
 AT_CHECK_AUTOCONF([], 0, [],
-[configure.ac:17: warning: SINGLE_TEST invoked multiple times
+[configure.ac:16: warning: SINGLE_TEST invoked multiple times
 ])
 AT_CHECK_CONFIGURE
 
index 242acf65fbbd18c6116d5f81020dbd15b8283b14..2dc78f749e2ab601480e3288d56b0ddf0095997f 100644 (file)
@@ -44,6 +44,9 @@ dir=`AS_DIRNAME_SED([$1])`
 test "$dir" = "$2" ||
   echo "dirname_sed($1) = $dir instead of $2" >&2])
 
+DIRNAME_TEST([/],              [/])
+DIRNAME_TEST([//],             [//])
+DIRNAME_TEST([///],            [/])
 DIRNAME_TEST([//1],            [//])
 DIRNAME_TEST([/1],             [/])
 DIRNAME_TEST([./1],            [.])
@@ -74,6 +77,66 @@ AT_CLEANUP(configure)
 
 
 
+## ------------------------------- ##
+## AS_BASENAME & AS_BASENAME_SED.  ##
+## ------------------------------- ##
+
+# Build nested dirs.
+m4_pattern_allow([^AS_BASENAME(_SED)?$])
+AT_SETUP([[AS_BASENAME & AS_BASENAME_SED]])
+
+AT_DATA([configure.ac],
+[[AC_PLAIN_SCRIPT()#! /bin/sh
+
+_AS@&t@_EXPR_PREPARE
+
+m4_define([BASENAME_TEST],
+[base=`AS_BASENAME([$1])`
+test "$base" = "$2" ||
+  echo "basename($1) = $base instead of $2" >&2
+
+base=`AS_BASENAME_SED([$1])`
+test "$base" = "$2" ||
+  echo "basename_sed($1) = $base instead of $2" >&2])
+
+BASENAME_TEST([//1],             [1])
+BASENAME_TEST([/1],              [1])
+BASENAME_TEST([./1],             [1])
+BASENAME_TEST([../../2],         [2])
+BASENAME_TEST([//1/],            [1])
+BASENAME_TEST([/1/],             [1])
+BASENAME_TEST([./1/],            [1])
+BASENAME_TEST([../../2],         [2])
+BASENAME_TEST([//1/3],           [3])
+BASENAME_TEST([/1/3],            [3])
+BASENAME_TEST([./1/3],           [3])
+BASENAME_TEST([../../2/3],       [3])
+BASENAME_TEST([//1/3///],        [3])
+BASENAME_TEST([/1/3///],         [3])
+BASENAME_TEST([./1/3///],        [3])
+BASENAME_TEST([../../2/3///],    [3])
+BASENAME_TEST([//1//3/],         [3])
+BASENAME_TEST([/1//3/],          [3])
+BASENAME_TEST([./1//3/],         [3])
+BASENAME_TEST([a.c],             [a.c])
+BASENAME_TEST([a.c/],            [a.c])
+BASENAME_TEST([/a.c/],           [a.c])
+BASENAME_TEST([/1/a.c],          [a.c])
+BASENAME_TEST([/1/a.c/],         [a.c])
+BASENAME_TEST([/1/../a.c],       [a.c])
+BASENAME_TEST([/1/../a.c/],      [a.c])
+BASENAME_TEST([./1/a.c],         [a.c])
+BASENAME_TEST([./1/a.c/],        [a.c])
+AS_EXIT(0)
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP(configure)
+
+
+
 ## ------------ ##
 ## AS_MKDIR_P.  ##
 ## ------------ ##