From: Akim Demaille Date: Tue, 18 Sep 2001 12:26:36 +0000 (+0000) Subject: * tests/m4sh.at: Ensure that AS_DIRNAME handles '/', '//' and '///' X-Git-Tag: AUTOCONF-2.52f~138 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfa90014d7138a700d59af970020242cbef591b8;p=thirdparty%2Fautoconf.git * 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). --- diff --git a/ChangeLog b/ChangeLog index f19cb65b5..35189e788 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2001-09-18 Paul Wagland + + * 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 * lib/autoconf/autotest.m4 (AC_CONFIG_TESTDIR): No INIT-CMDS in diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index bc2728b1c..a3ff10053 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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 diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 550110b66..9e63a9ede 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -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 # --------------- diff --git a/tests/base.at b/tests/base.at index ea80c8f7e..49fc01390 100644 --- a/tests/base.at +++ b/tests/base.at @@ -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 diff --git a/tests/m4sh.at b/tests/m4sh.at index 242acf65f..2dc78f749 100644 --- a/tests/m4sh.at +++ b/tests/m4sh.at @@ -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. ## ## ------------ ##