aaron 02/03/08 09:56:14
Modified: build apr_common.m4
Log:
Add a new m4 function, APR_PATH_RELATIVE, which takes a path variable and
a prefix path to strip, and will only strip if they are relative. It
also ensures that any additional /'s on the front of the stripped path
are removed.
Submitted by: Thom May <[EMAIL PROTECTED]>, Aaron Bannert
Revision Changes Path
1.25 +20 -0 apr/build/apr_common.m4
Index: apr_common.m4
===================================================================
RCS file: /home/cvs/apr/build/apr_common.m4,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- apr_common.m4 7 Mar 2002 19:10:31 -0000 1.24
+++ apr_common.m4 8 Mar 2002 17:56:14 -0000 1.25
@@ -580,3 +580,23 @@
$1=$cur
])
+dnl
+dnl Removes the value of $3 from the string in $2, strips of any leading
+dnl slashes, and returns the value in $1.
+dnl
+dnl Example:
+dnl orig_path="${prefix}/bar"
+dnl APR_PATH_RELATIVE(final_path, $orig_path, $prefix)
+dnl $final_path now contains "bar"
+AC_DEFUN(APR_PATH_RELATIVE,[
+stripped=`echo $2 | sed -e "s#^$3##"`
+# check if the stripping was successful
+if test "x$2" != "x$stripped"; then
+ # it was, so strip of any leading slashes
+ $1=`echo $stripped | sed -e 's#^/*##'`
+else
+ # it wasn't so return the original
+ $1=$2
+fi
+])
+