diff options
| author | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-10-11 08:19:39 +0000 |
|---|---|---|
| committer | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-10-11 08:19:39 +0000 |
| commit | 2605a681a0e4f668ee360ba83f08e0b02e96f054 (patch) | |
| tree | dae4e95816310c776aee13c0257f6c79f406ff92 | |
| parent | 5cecf67afd4e27e209c592fa3595b32991f0df19 (diff) | |
| download | luarocks-2605a681a0e4f668ee360ba83f08e0b02e96f054.tar.gz luarocks-2605a681a0e4f668ee360ba83f08e0b02e96f054.tar.bz2 luarocks-2605a681a0e4f668ee360ba83f08e0b02e96f054.zip | |
more robust matching
git-svn-id: http://luarocks.org/svn/luarocks/trunk@92 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
| -rw-r--r-- | src/luarocks/manif.lua | 12 |
1 files changed, 8 insertions, 4 deletions
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) | |||
| 301 | return save_table(repo, "manifest", manifest) | 301 | return save_table(repo, "manifest", manifest) |
| 302 | end | 302 | end |
| 303 | 303 | ||
| 304 | local function starts_with(s, prefix) | ||
| 305 | return s:sub(1,#prefix) == prefix | ||
| 306 | end | ||
| 307 | |||
| 304 | local function find_providers(file, root) | 308 | local function find_providers(file, root) |
| 305 | assert(type(file) == "string") | 309 | assert(type(file) == "string") |
| 306 | assert(type(root) == "string" or not root) | 310 | assert(type(root) == "string" or not root) |
| @@ -315,17 +319,17 @@ local function find_providers(file, root) | |||
| 315 | local deploy_lib = path.deploy_lib_dir(root) | 319 | local deploy_lib = path.deploy_lib_dir(root) |
| 316 | local key, manifest_tbl | 320 | local key, manifest_tbl |
| 317 | 321 | ||
| 318 | if file:match("^"..deploy_bin) then | 322 | if starts_with(file, deploy_bin) then |
| 319 | manifest_tbl = manifest.commands | 323 | manifest_tbl = manifest.commands |
| 320 | key = file:sub(#deploy_bin+1) | 324 | key = file:sub(#deploy_bin+1) |
| 321 | elseif file:match("^"..deploy_lua) then | 325 | elseif starts_with(file, deploy_lua) then |
| 322 | manifest_tbl = manifest.modules | 326 | manifest_tbl = manifest.modules |
| 323 | key = path.path_to_module(file:sub(#deploy_lua+1)) | 327 | key = path.path_to_module(file:sub(#deploy_lua+1)) |
| 324 | elseif file:match("^"..deploy_lib) then | 328 | elseif starts_with(file, deploy_lib) then |
| 325 | manifest_tbl = manifest.modules | 329 | manifest_tbl = manifest.modules |
| 326 | key = path.path_to_module(file:sub(#deploy_lib+1)) | 330 | key = path.path_to_module(file:sub(#deploy_lib+1)) |
| 327 | else | 331 | else |
| 328 | assert(false, "Assertion failed: find_current_provider must operate on a deployed file.") | 332 | assert(false, "Assertion failed: '"..file.."' is not a deployed file.") |
| 329 | end | 333 | end |
| 330 | 334 | ||
| 331 | local providers = manifest_tbl[key] | 335 | local providers = manifest_tbl[key] |
