summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authoraaron <aaron@13f79535-47bb-0310-9956-ffa450edef68>2002-03-08 17:56:14 +0000
committeraaron <aaron@13f79535-47bb-0310-9956-ffa450edef68>2002-03-08 17:56:14 +0000
commitebd287a6bcc24493077934f24be9ef937ef3b854 (patch)
treefcebdb7d526e1355988323cf43ffc07dbc3071f7 /build
parentda2ae02c123cee30251dd05d05c4d342a833d843 (diff)
downloadlibapr-ebd287a6bcc24493077934f24be9ef937ef3b854.tar.gz
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 <thom@planetarytramp.net>, Aaron Bannert git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63097 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'build')
-rw-r--r--build/apr_common.m420
1 files changed, 20 insertions, 0 deletions
diff --git a/build/apr_common.m4 b/build/apr_common.m4
index 5b42ce494..f6e32b7dc 100644
--- a/build/apr_common.m4
+++ b/build/apr_common.m4
@@ -580,3 +580,23 @@ done
$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
+])
+