[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!
From: |
Paul Eggert |
Subject: |
Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test! |
Date: |
Tue, 18 Sep 2001 13:30:40 -0700 (PDT) |
> From: Akim Demaille <address@hidden>
> Date: 18 Sep 2001 13:51:05 +0200
>
> OK, please go ahead then.
OK, I installed the documentation patch.
I looked at the latest AS_BASENAME, and it still doesn't look right.
It uses \? and \+, which is not portable to POSIX 'sed'. On Solaris
8, this causes AS_BASENAME to mishandle many examples. Also, it
mishandles strings that contain ',', '\', or leading '-' (depending on
the host).
How about the following patch? It doesn't address the DOS filename
issues, but it does make AS_BASENAME consistent with AS_DIRNAME and
thus it should be as portable as AS_DIRNAME is.
2001-09-18 Paul Eggert <address@hidden>
Make AS_BASENAME consistent with AS_DIRNAME, to fix some
portability problems with non-GNU sed commands, and to make it
work even with file names containing ',', '\' or leading '-'.
* lib/m4sugar/m4sh.m4 (AS_BASENAME_EXPR): New macro.
(AS_BASENAME_SED): Don't use GNU extensions in sed command.
Instead, stick to the constructs used in AS_DIRNAME_SED.
(AS_BASENAME): Try AS_BASENAME_EXPR first, and then fall
back on AS_BASENAME_SED.
--- autoconf/lib/m4sugar/m4sh.m4 Tue Sep 18 09:18:02 2001
+++ autoconf-fix1/lib/m4sugar/m4sh.m4 Tue Sep 18 13:11:05 2001
@@ -371,12 +371,25 @@ 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])])
+[AS_BASENAME_EXPR([$1]) 2>/dev/null ||
+AS_BASENAME_SED([$1])])
# AS_EXECUTABLE_P
# ---------------
- AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Paul Wagland, 2001/09/17
- AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Paul Wagland, 2001/09/17
- Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Akim Demaille, 2001/09/17
- Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Paul Eggert, 2001/09/17
- Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Akim Demaille, 2001/09/18
- Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!,
Paul Eggert <=
Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Paul Eggert, 2001/09/17
RE: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Paul Wagland, 2001/09/19
Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Paul Eggert, 2001/09/19
Re: AC_PREFIX_PATH, AS_BASENAME fixes and a new test!, Akim Demaille, 2001/09/22