From 3bb23b8df11b3ae5493e568c0824f2eb029bfdea Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 8 Mar 2016 13:53:58 +0000 Subject: [PATCH] Fix some issues --- ReadMe.md | 12 +++++++----- bsrocks/commands/exec.lua | 1 - bsrocks/downloaders/init.lua | 6 ++++-- bsrocks/env/fixes.lua | 5 ++++- bsrocks/env/io.lua | 9 +++++---- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index ece7289..d30b21e 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -10,15 +10,17 @@ Most functionality of Lua 5.1 is implemented, with the following caveats: - `debug.getinfo` only accepts a numeric value - `.getmetatable`, `.setmetatable`, `.getfenv` and `.setfenv` are just their normal versions - Everything else is not implemented - - `os` library is only partially implemented + - `os.setlocale` library is not implemented - `io.popen` is not implemented. - Several LuaJ bugs: - - `\011` is not considered whitespace + - `\011` is not considered whitespace\* - `string.format` floating point specifiers don't work (e.g. `%5.2f`) - - `string.gmatch` will infinitely loop on the `*` pattern (e.g. `\n*`) - - `getmetatable` returns `nil` for strings. + - `string.gmatch` will infinitely loop on the `*` pattern (e.g. `\n*`)\* + - `getmetatable` returns the string library for strings. - String's metatable and the `string` library are not the same, so you cannot add string methods. - - `%b` errors when no match is found. + - `%b` errors when no match is found.\* + +\* *Fixed in CC 1.79pr2 or CCTweaks 0.3.1* The LuaRocks implementation is very minimal: - Currently only supports downloading GitHub repositories diff --git a/bsrocks/commands/exec.lua b/bsrocks/commands/exec.lua index 659b2cd..58414c6 100644 --- a/bsrocks/commands/exec.lua +++ b/bsrocks/commands/exec.lua @@ -61,7 +61,6 @@ return { return thisEnv.debug.traceback(msg, 2) end ) - loaded(...) for _, v in pairs(env.cleanup) do v() end diff --git a/bsrocks/downloaders/init.lua b/bsrocks/downloaders/init.lua index 8b44fd7..feda29f 100644 --- a/bsrocks/downloaders/init.lua +++ b/bsrocks/downloaders/init.lua @@ -6,9 +6,11 @@ local downloaders = { local url = source.url if not url then return end - local repo = url:match("git://github%.com/(.*)") + local repo = url:match("git://github%.com/(.*)$") local branch = source.branch or source.tag or "master" - if not repo then + if repo then + repo = repo:gsub("%.git$", "") + else -- If we have the archive then we can also fetch from GitHub repo, branch = url:match("https?://github%.com/(.*)/archive/(.*).tar.gz") if not repo then return end diff --git a/bsrocks/env/fixes.lua b/bsrocks/env/fixes.lua index 61fae6a..3c480e6 100644 --- a/bsrocks/env/fixes.lua +++ b/bsrocks/env/fixes.lua @@ -9,8 +9,11 @@ local function copy(tbl) end local function getmeta(obj) - if type(obj) == "table" then + local t = type(obj) + if t == "table" then return getmetatable(obj) + elseif t == "string" then + return string else return nil end diff --git a/bsrocks/env/io.lua b/bsrocks/env/io.lua index 04c1486..7961802 100644 --- a/bsrocks/env/io.lua +++ b/bsrocks/env/io.lua @@ -45,9 +45,10 @@ local fileMeta = { local data = {...} local n = select("#", ...) + if n == 0 then n = 1 end for i = 1, n do - local format = data[i] - format = checkType(format, "string"):gsub("*", "", true) -- "*" is not needed after Lua 5.1 - lets be friendly + local format = data[i] or "l" + format = checkType(format, "string"):gsub("%*", "") -- "*" is not needed after Lua 5.1 - lets be friendly if format == "l" then returns[#returns + 1] = handle.readLine() elseif format == "a" then @@ -59,7 +60,7 @@ local fileMeta = { end end - return unpack(data) + return unpack(returns) end, seek = function(self, ...) @@ -85,7 +86,7 @@ local fileMeta = { end, lines = function(self, ...) - return function() return self.__handle.readLine() end + return self.__handle.readLine end, } }