autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

proposed autoconf patches for AS_BASENAME, AS_DIRNAME


From: Paul Eggert
Subject: proposed autoconf patches for AS_BASENAME, AS_DIRNAME
Date: Fri, 5 Oct 2001 14:08:57 -0700 (PDT)

Here are some patches to fix some glitches in AS_DIRNAME and
AS_BASENAME.  This should cause those macros to work on DOS hosts,
assuming that the 'basename' and 'dirname' shell commands work on DOS
hosts.  (See, I'm not always an anti-DOS bigot.  :-)

2001-10-05  Paul Eggert  <address@hidden>

        * lib/autoconf/general.m4 (_AC_INIT_SRCDIR):
        Use AS_DIRNAME, since it's now DOS-friendly.

        * lib/m4sugar/m4sh.m4 (AS_DIRNAME): Use 'dirname' if that works.
        (AS_BASENAME_EXPR): New macro.
        (AS_BASENAME_SED): Do not assume GNU sed semantics.
        (AS_BASENAME): Use 'basename' if that works; then try 'expr';
        and fall back on 'sed' only if the other two fail.  This makes
        AS_BASENAME act more like AS_DIRNAME.

diff -rpu autoconf-fiz0/lib/autoconf/general.m4 
autoconf-fiz1/lib/autoconf/general.m4
--- autoconf-fiz0/lib/autoconf/general.m4       Sun Sep 30 08:12:41 2001
+++ autoconf-fiz1/lib/autoconf/general.m4       Fri Oct  5 13:59:47 2001
@@ -548,10 +548,7 @@ m4_define([_AC_INIT_SRCDIR],
 if test -z "$srcdir"; then
   ac_srcdir_defaulted=yes
   # Try the directory containing this script, then its parent.
-  ac_prog=$[0]
-dnl FIXME: should use AS_DIRNAME here once it is made DOS-friendly.
-  ac_confdir=`echo "$ac_prog" | sed 's%[[\\/][^\\/][^\\/]]*$%%'`
-  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  ac_confdir=`AS_DIRNAME(["$[0]"])`
   srcdir=$ac_confdir
   if test ! -r $srcdir/$ac_unique_file; then
     srcdir=..
diff -rpu autoconf-fiz0/lib/m4sugar/m4sh.m4 autoconf-fiz1/lib/m4sugar/m4sh.m4
--- autoconf-fiz0/lib/m4sugar/m4sh.m4   Fri Oct  5 11:29:39 2001
+++ autoconf-fiz1/lib/m4sugar/m4sh.m4   Fri Oct  5 13:59:47 2001
@@ -370,19 +370,34 @@ m4_defun([AS_DIRNAME_SED],
          s/.*/./; q']])
 
 m4_defun([AS_DIRNAME],
-[AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
+[(dirname [$1]) 2>/dev/null ||
+AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
 AS_DIRNAME_SED([$1])])
 
 
 # AS_BASENAME(PATHNAME)
 # --------------------
 # Simulate running `basename(1)' on PATHNAME, not all systems have it.
-# This macro must be usable from inside ` `.
+# Also see the comments for AS_DIRNAME.
+
+m4_defun([AS_BASENAME_EXPR],
+[m4_require([_AS_EXPR_PREPARE])dnl
+$as_expr X/[]$1 : '.*/\([[^/][^/]*]\)/*$' \| \
+        X[]$1 : 'X\(//\)$' \| \
+        X[]$1 : 'X\(/\)$' \| \
+        .     : '\(.\)'])
+
 m4_defun([AS_BASENAME_SED],
-[echo "$1" |sed 's,\(.*[[\\/]]\+\)\?\([[^\\/]]\+\)[[\\/]]*,\2,'])
+[echo X/[]$1 |
+    sed ['/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+         /^X\/\(\/\/\)$/{ s//\1/; q; }
+         /^X\/\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q']])
 
 m4_defun([AS_BASENAME],
-[AS_BASENAME_SED([$1])])
+[(basename [$1]) 2>/dev/null ||
+AS_BASENAME_EXPR([$1]) 2>/dev/null ||
+AS_BASENAME_SED([$1])])
 
 # AS_EXECUTABLE_P
 # ---------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]