diff options
Diffstat (limited to 'src/lpm.lua')
-rw-r--r-- | src/lpm.lua | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lpm.lua b/src/lpm.lua index e4c47e0..ba81ce0 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -370,6 +370,7 @@ function common.join(j, l) local s = "" for i, v in ipairs(l) do if i > 1 then s function common.sort(t, f) table.sort(t, f) return t end function common.write(path, contents) local f, err = io.open(path, "wb") if not f then error("can't write to " .. path .. ": " .. err) end f:write(contents) f:flush() end function common.read(path) local f, err = io.open(path, "rb") if not f then error("can't read from " .. path .. ": " .. err) end return f:read("*all") end +function common.uniq(l) local t = {} local k = {} for i,v in ipairs(l) do if not k[v] then table.insert(t, v) k[v] = true end end return t end function common.split(splitter, str) local o = 1 local res = {} @@ -1143,7 +1144,7 @@ function Bottle:get_plugin(id, version, filter) end end end - return table.unpack(common.sort(candidates, function (a,b) return a.version < b.version end)) + return table.unpack(common.sort(common.uniq(candidates), function (a,b) return a.version < b.version end)) end |