From a8d9843c3e9396f7c737c5c98529b4fe8667a1a8 Mon Sep 17 00:00:00 2001 From: hisham Date: Sun, 11 Oct 2009 05:47:04 +0000 Subject: remove global references git-svn-id: http://luarocks.org/svn/luarocks/trunk@84 9ca3f7c1-7366-0410-b1a3-b5c78f85698c --- src/luarocks/build.lua | 1 + src/luarocks/fetch.lua | 2 +- src/luarocks/make_manifest.lua | 2 +- src/luarocks/pack.lua | 1 + src/luarocks/path.lua | 2 +- src/luarocks/search.lua | 2 +- src/luarocks/util.lua | 10 +++++----- 7 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 997929a8..98d5dd61 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -170,6 +170,7 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode) build.type = "builtin" end + local build_type ok, build_type = pcall(require, "luarocks.build." .. build.type) if not ok or not type(build_type) == "table" then return nil, "Failed initializing build back-end for build type '"..build.type.."'" diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 407d72c5..5e1f870d 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -285,7 +285,7 @@ function fetch_sources(rockspec, extract, dest_dir) assert(type(dest_dir) == "string" or not dest_dir) local protocol = rockspec.source.protocol - local proto + local ok, proto if protocol == "http" or protocol == "https" or protocol == "ftp" or protocol == "file" then proto = require("luarocks.fetch") else diff --git a/src/luarocks/make_manifest.lua b/src/luarocks/make_manifest.lua index bec1b704..4701a45a 100644 --- a/src/luarocks/make_manifest.lua +++ b/src/luarocks/make_manifest.lua @@ -24,7 +24,7 @@ function run(repo) print("Making manifest for "..repo) - ok, err = manif.make_manifest(repo) + local ok, err = manif.make_manifest(repo) if ok then print("Generating index.html for "..repo) index.make_index(repo) diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 2fa12d9b..800a855e 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua @@ -113,6 +113,7 @@ local function pack_binary_rock(name, version) local temp_dir = fs.make_temp_dir("pack") fs.copy_contents(prefix, temp_dir) + local is_binary = false if rock_manifest.lib then copy_back_files(name, version, rock_manifest.lib, cfg.deploy_lib_dir, dir.path(temp_dir, "lib")) is_binary = true diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index 8c5aa0da..4718378e 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua @@ -269,6 +269,6 @@ function versioned_name(file, prefix, name, version) assert(type(version) == "string") local rest = file:gsub("^"..prefix.."/*", "") - name_version = (name.."_"..version):gsub("%-", "_"):gsub("%.", "_") + local name_version = (name.."_"..version):gsub("%-", "_"):gsub("%.", "_") return dir.path(prefix, name_version.."-"..rest) end diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 0ba9ff43..da69eaff 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua @@ -37,7 +37,7 @@ local function query_arch_as_table(query) query.arch = accept elseif format == "string" then local accept = {} - for a in string.gmatch(query.arch, "[%w_-]+") do + for a in query.arch:gmatch("[%w_-]+") do accept[a] = true end query.arch = accept diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index f48bfe1f..ab6ad34f 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -273,15 +273,15 @@ function show_table(t, name, indent) local info = debug.getinfo(o, "S") -- info.name is nil because o is not a calling level if info.what == "C" then - return string.format("%q", so .. ", C function") + return ("%q"):format(so .. ", C function") else -- the information is defined through lines - return string.format("%q", so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) + return ("%q"):format(so .. ", defined in (" .. info.linedefined .. "-" .. info.lastlinedefined .. ")" .. info.source) end elseif type(o) == "number" then return so else - return string.format("%q", so) + return ("%q"):format(so) end end @@ -307,8 +307,8 @@ function show_table(t, name, indent) cart = cart .. " = {\n" for k, v in pairs(value) do k = basicSerialize(k) - local fname = string.format("%s[%s]", name, k) - field = string.format("[%s]", k) + local fname = ("%s[%s]"):format(name, k) + field = ("[%s]"):format(k) -- three spaces between levels addtocart(v, fname, indent .. " ", saved, field) end -- cgit v1.2.3-55-g6feb