diff options
-rw-r--r-- | src/luarocks/core/path.lua | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/luarocks/core/path.lua b/src/luarocks/core/path.lua index bf6bdc2d..b354a41a 100644 --- a/src/luarocks/core/path.lua +++ b/src/luarocks/core/path.lua | |||
@@ -44,24 +44,29 @@ end | |||
44 | function path.path_to_module(file) | 44 | function path.path_to_module(file) |
45 | assert(type(file) == "string") | 45 | assert(type(file) == "string") |
46 | 46 | ||
47 | local name = file:match("(.*)%."..cfg.lua_extension.."$") | 47 | local exts = {} |
48 | if name then | 48 | local paths = package.path .. ";" .. package.cpath |
49 | name = name:gsub("/", ".") | 49 | for entry in paths:gmatch("[^;]+") do |
50 | else | 50 | local ext = entry:match("%.([a-z]+)$") |
51 | name = file:match("(.*)%."..cfg.lib_extension.."$") | 51 | if ext then |
52 | exts[ext] = true | ||
53 | end | ||
54 | end | ||
55 | |||
56 | local name | ||
57 | for ext, _ in pairs(exts) do | ||
58 | name = file:match("(.*)%." .. ext .. "$") | ||
52 | if name then | 59 | if name then |
53 | name = name:gsub("/", ".") | 60 | name = name:gsub("[/\\]", ".") |
54 | --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. | 61 | break |
55 | else | ||
56 | name = file:match("(.*)%."..cfg.static_lib_extension.."$") | ||
57 | if name then | ||
58 | name = name:gsub("/", ".") | ||
59 | end | ||
60 | ]] | ||
61 | end | 62 | end |
62 | end | 63 | end |
64 | |||
63 | if not name then name = file end | 65 | if not name then name = file end |
66 | |||
67 | -- remove any beginning and trailing slashes-converted-to-dots | ||
64 | name = name:gsub("^%.+", ""):gsub("%.+$", "") | 68 | name = name:gsub("^%.+", ""):gsub("%.+$", "") |
69 | |||
65 | return name | 70 | return name |
66 | end | 71 | end |
67 | 72 | ||