2006-04-01 Stepan Kasal * lib/m4sugar/m4sh.m4 (AS_DIRNAME): Reimplement using AS_CASE. (AS_BASENAME): Likewise. (AS_DIRNAME_EXPR, AS_DIRNAME_SED, AS_BASENAME_EXPR, AS_BASENAME_SED): Nuke. * tests/m4sh.at (AS_DIRNAME, AS_BASENAME): Do not test the removed macros. Index: lib/m4sugar/m4sh.m4 =================================================================== RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v retrieving revision 1.169 diff -u -r1.169 m4sh.m4 --- lib/m4sugar/m4sh.m4 1 Apr 2006 18:32:10 -0000 1.169 +++ lib/m4sugar/m4sh.m4 1 Apr 2006 18:38:01 -0000 @@ -659,36 +659,28 @@ # AS_BASENAME(FILE-NAME) # ---------------------- # Simulate the command 'basename FILE-NAME'. Not all systems have basename. -# Also see the comments for AS_DIRNAME. - -m4_defun([AS_BASENAME_EXPR], -[AS_REQUIRE([_AS_EXPR_PREPARE])dnl -$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \ - X[]$1 : 'X\(//\)$' \| \ - X[]$1 : 'X\(/\)' \| \ - . : '\(.\)']) - -m4_defun([AS_BASENAME_SED], -[echo X/[]$1 | - sed ['/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q']]) - +# Try to respect the platform specific behavior for // and the empty string. +# +# This macro must be usable from inside ` `. +# +# Prefer expr to echo|sed, since expr is usually faster and it handles +# backslashes and newlines correctly. However, older expr +# implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have +# a silly length limit that causes expr to fail if the matched +# substring is longer than 120 bytes. So fall back on echo|sed if +# expr fails. +# m4_defun([AS_BASENAME], [AS_REQUIRE([_$0_PREPARE])dnl -$as_basename $1 || -AS_BASENAME_EXPR([$1]) 2>/dev/null || -AS_BASENAME_SED([$1])]) +AS_REQUIRE([_AS_EXPR_PREPARE])dnl +AS_CASE([$1], + [[*[!/]*]], + [$as_basename $1 || + $as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' 2>/dev/null || + echo X/[]$1 | sed ['s|^.*/\([^/][^/]*\)/*$|\1|']], + [//], [$as_basename $1 || echo //], + [''], [$as_basename $1 || echo .], + [echo /])]) # _AS_BASENAME_PREPARE @@ -706,46 +698,21 @@ # AS_DIRNAME(FILE-NAME) # --------------------- # Simulate the command 'dirname FILE-NAME'. Not all systems have dirname. -# This macro must be usable from inside ` `. +# Try to respect the platform specific behavior for //*. +# +# Also see the comments for AS_DIRNAME. # -# Prefer expr to echo|sed, since expr is usually faster and it handles -# backslashes and newlines correctly. However, older expr -# implementations (e.g. SunOS 4 expr and Solaris 8 /usr/ucb/expr) have -# a silly length limit that causes expr to fail if the matched -# substring is longer than 120 bytes. So fall back on echo|sed if -# expr fails. -m4_defun([AS_DIRNAME_EXPR], -[AS_REQUIRE([_AS_EXPR_PREPARE])dnl -$as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \ - X[]$1 : 'X\(//\)[[^/]]' \| \ - X[]$1 : 'X\(//\)$' \| \ - X[]$1 : 'X\(/\)' \| \ - . : '\(.\)']) - -m4_defun([AS_DIRNAME_SED], -[echo X[]$1 | - sed ['/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q']]) - m4_defun([AS_DIRNAME], -[(dirname $1) 2>/dev/null || -AS_DIRNAME_EXPR([$1]) 2>/dev/null || -AS_DIRNAME_SED([$1])]) +[AS_REQUIRE([_AS_EXPR_PREPARE])dnl +AS_CASE([$1], + [[*[!/]/*[!/]*]], + [(dirname $1) 2>/dev/null || + $as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' 2>/dev/null || + echo X[]$1 | sed ['s|^X\(.*[^/]\)//*[^/][^/]*/*$|\1|p']], + [[//|//[!/]*]], + [(dirname $1) 2>/dev/null || echo //], + [/*], [echo /], + [echo .])]) # AS_EXECUTABLE_P Index: tests/m4sh.at =================================================================== RCS file: /cvsroot/autoconf/autoconf/tests/m4sh.at,v retrieving revision 1.45 diff -u -r1.45 m4sh.at --- tests/m4sh.at 21 Feb 2006 09:30:01 -0000 1.45 +++ tests/m4sh.at 1 Apr 2006 18:38:02 -0000 @@ -111,17 +111,7 @@ [dir=`AS_DIRNAME([$1])` test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") || echo "dirname($1) = $dir instead of $2" >&2 - -if test "$as_expr" != false; then - dir=`AS_DIRNAME_EXPR([$1])` - test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") || - echo "dirname_expr($1) = $dir instead of $2" >&2 -fi - -dir=`AS_DIRNAME_SED([$1])` -test "$dir" = "$2" || -test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") || - echo "dirname_sed($1) = $dir instead of $2" >&2]) +]) DIRNAME_TEST([/], [/]) DIRNAME_TEST([//], [//], [/]) @@ -170,10 +160,7 @@ [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])