From 2605a681a0e4f668ee360ba83f08e0b02e96f054 Mon Sep 17 00:00:00 2001 From: hisham Date: Sun, 11 Oct 2009 08:19:39 +0000 Subject: more robust matching git-svn-id: http://luarocks.org/svn/luarocks/trunk@92 9ca3f7c1-7366-0410-b1a3-b5c78f85698c --- src/luarocks/manif.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 6a0d637a..f1810d67 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua @@ -301,6 +301,10 @@ function update_manifest(name, version, repo) return save_table(repo, "manifest", manifest) end +local function starts_with(s, prefix) + return s:sub(1,#prefix) == prefix +end + local function find_providers(file, root) assert(type(file) == "string") assert(type(root) == "string" or not root) @@ -315,17 +319,17 @@ local function find_providers(file, root) local deploy_lib = path.deploy_lib_dir(root) local key, manifest_tbl - if file:match("^"..deploy_bin) then + if starts_with(file, deploy_bin) then manifest_tbl = manifest.commands key = file:sub(#deploy_bin+1) - elseif file:match("^"..deploy_lua) then + elseif starts_with(file, deploy_lua) then manifest_tbl = manifest.modules key = path.path_to_module(file:sub(#deploy_lua+1)) - elseif file:match("^"..deploy_lib) then + elseif starts_with(file, deploy_lib) then manifest_tbl = manifest.modules key = path.path_to_module(file:sub(#deploy_lib+1)) else - assert(false, "Assertion failed: find_current_provider must operate on a deployed file.") + assert(false, "Assertion failed: '"..file.."' is not a deployed file.") end local providers = manifest_tbl[key] -- cgit v1.2.3-55-g6feb