diff options
author | Reuben Thomas <rrt@sc3d.org> | 2014-08-02 23:38:17 +0100 |
---|---|---|
committer | Reuben Thomas <rrt@sc3d.org> | 2014-08-02 23:38:17 +0100 |
commit | 633f56f0bdc0043bdb8047e3e580ee18c593bdc2 (patch) | |
tree | 11e657989ad87f3543dc89dc724c8010adbbdb99 /m4/ax_lua.m4 | |
parent | e499ab4fdcacef1cab6c0f7b67ca36435c774b3d (diff) | |
download | autoconf-archive-633f56f0bdc0043bdb8047e3e580ee18c593bdc2.tar.gz |
ax_lua.m4: rewrite _AX_LUA_FND_PREFX_PTH
Rewrite in Lua for robustness and brevity.
Also make it understand the Lua style of ?-pattern path.
Patch from Gary Vaughan (gary@gnu.org)
Diffstat (limited to 'm4/ax_lua.m4')
-rw-r--r-- | m4/ax_lua.m4 | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/m4/ax_lua.m4 b/m4/ax_lua.m4 index 134bab7..15376af 100644 --- a/m4/ax_lua.m4 +++ b/m4/ax_lua.m4 @@ -180,7 +180,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 27 +#serial 28 dnl ========================================================================= dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION], @@ -375,28 +375,19 @@ AC_DEFUN([_AX_LUA_FND_PRFX_PTH], [ dnl Invokes the Lua interpreter PROG to print the path variable dnl LUA-PATH-VARIABLE, usually package.path or package.cpath. Paths are - dnl then matched against PREFIX. The first path to begin with PREFIX is set - dnl to ax_lua_prefixed_path. - - ax_lua_prefixed_path='' - _ax_package_paths=`$1 -e 'print($3)' 2>/dev/null | sed 's|;|\n|g'` - dnl Try the paths in order, looking for the prefix. - for _ax_package_path in $_ax_package_paths; do - dnl Copy the path, up to the use of a Lua wildcard. - _ax_path_parts=`echo "$_ax_package_path" | sed 's|/|\n|g'` - _ax_reassembled='' - for _ax_path_part in $_ax_path_parts; do - echo "$_ax_path_part" | grep '\?' >/dev/null && break - _ax_reassembled="$_ax_reassembled/$_ax_path_part" - done - dnl Check the path against the prefix. - _ax_package_path=$_ax_reassembled - if echo "$_ax_package_path" | grep "^$2" >/dev/null; then - dnl Found it. - ax_lua_prefixed_path=$_ax_package_path - break - fi - done + dnl then matched against PREFIX. Then ax_lua_prefixed_path is set to the + dnl shortest sub path beginning with PREFIX up to the last directory + dnl that does not contain a '?', if any. + + ax_lua_prefixed_path=`$1 2>/dev/null -e ' + $3:gsub ("(@<:@^;@:>@+)", + function (p) + p = p:gsub ("%?.*$", ""):gsub ("/@<:@^/@:>@*$", "") + if p:match ("^$2") and (not shortest or #shortest > #p) then + shortest = p + end + end) + print (shortest or "")'` ]) |