From 909e04e062287668a9c8d39b4817b089e347ea52 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Fri, 31 Aug 2012 14:57:55 +0200 Subject: [PATCH] Mark global symbols 'local' Signed-off-by: Tobias Ulmer --- global/e2-create-project.lua | 4 ++-- global/e2-fetch-project.lua | 6 +++--- global/e2-install-e2.lua | 2 +- global/e2.lua.in | 11 ++++++----- local/e2-fetch-sources.lua | 4 ++-- local/e2-ls-project.lua | 14 +++++++------- local/e2-new-source.lua | 10 +++++----- local/e2-playground.lua | 2 +- local/policy.lua | 2 +- 9 files changed, 28 insertions(+), 27 deletions(-) diff --git a/global/e2-create-project.lua b/global/e2-create-project.lua index f8b7ad4..115e2b7 100644 --- a/global/e2-create-project.lua +++ b/global/e2-create-project.lua @@ -101,7 +101,7 @@ e2lib.chdir(tmpdir) local version = string.format("%d\n", p.version) local empty = "" -files = { +local files = { { filename = "version", content=version }, { filename = "proj/.keep", content=empty }, { filename = "git/.keep", content=empty }, @@ -178,7 +178,7 @@ local version = string.format("%s\n", p.version) local e2version = string.format("%s\n", p.e2version) local syntax = string.format("%s\n", buildconfig.SYNTAX[1]) local empty = "" -files = { +local files = { { filename = ".e2/.keep", content=empty }, { filename = "in/.keep", content=empty }, { filename = "log/.keep", content=empty }, diff --git a/global/e2-fetch-project.lua b/global/e2-fetch-project.lua index b378813..6cdf25f 100644 --- a/global/e2-fetch-project.lua +++ b/global/e2-fetch-project.lua @@ -115,7 +115,7 @@ if not line then end e2lib.rmtempdir() -v = tonumber(line:match("[0-9]+")) +local v = tonumber(line:match("[0-9]+")) if not v or v < 1 or v > 2 then e2lib.abort(e:append("unhandled project version")) end @@ -179,8 +179,8 @@ local rc, re = e2lib.write_file(e2lib.globals.global_interface_version_file, string.format("%d\n", v)) -- call e2-install-e2 -e2_install_e2 = string.format("%s %s/e2-install-e2", -e2lib.shquote(buildconfig.LUA), e2lib.shquote(buildconfig.TOOLDIR)) +local e2_install_e2 = string.format("%s %s/e2-install-e2", + e2lib.shquote(buildconfig.LUA), e2lib.shquote(buildconfig.TOOLDIR)) rc, re = e2lib.callcmd_log(e2_install_e2) if rc ~= 0 then e2lib.abort(err.new("installing local e2 failed")) diff --git a/global/e2-install-e2.lua b/global/e2-install-e2.lua index 9b4f3ec..ffd1f4a 100644 --- a/global/e2-install-e2.lua +++ b/global/e2-install-e2.lua @@ -89,7 +89,7 @@ if not line then e2lib.abort(e:cat(re)) end -v = tonumber(line:match("[0-9]+")) +local v = tonumber(line:match("[0-9]+")) if not v or v < 1 or v > 2 then e2lib.abort(e:append("unhandled project version")) end diff --git a/global/e2.lua.in b/global/e2.lua.in index ea9dd3d..bcb9870 100644 --- a/global/e2.lua.in +++ b/global/e2.lua.in @@ -28,9 +28,9 @@ package.path = "@LIBDIR@/?.lua" package.cpath = "@LIBDIR@/?.so" -require("buildconfig") local e2lib = require("e2lib") local e2option = require("e2option") +require("buildconfig") require("e2util") e2lib.init() @@ -52,7 +52,7 @@ end) local root = e2lib.locate_project_root() -e2call = {} +local e2call = {} e2call.basename = e2lib.basename(arg[0]) local function quoteargs(argstr) -- probably has to do escaping? @@ -80,12 +80,13 @@ if root then e2call.localtool = root .. "/.e2/bin/" .. e2call.toolname end +local env, cmd if e2util.stat(e2call.globaltool) then e2call.tool = e2call.globaltool env = string.format("LUA_PATH='%s/?.lua' LUA_CPATH='%s/?.so'", buildconfig.LIBDIR, buildconfig.LIBDIR) - lua = buildconfig.LUA - cmd = string.format("%s %s %s %s", env, lua, e2call.tool, e2call.arg_string) + cmd = string.format("%s %s %s %s", env, buildconfig.LUA, e2call.tool, + e2call.arg_string) elseif not root then e2lib.abort(e2call.toolname .. " is not a global tool and we're not in a project environment") @@ -102,7 +103,7 @@ else e2lib.abort(e2call.toolname .. " is neither local nor global tool") end -function table_log(loglevel, t) +local function table_log(loglevel, t) e2lib.log(loglevel, tostring(t)) for k,v in pairs(t) do e2lib.log(loglevel, k .. "\t->\t" .. v) diff --git a/local/e2-fetch-sources.lua b/local/e2-fetch-sources.lua index df5d3d6..962d5ee 100644 --- a/local/e2-fetch-sources.lua +++ b/local/e2-fetch-sources.lua @@ -121,7 +121,7 @@ end -- @param info the info table -- @return bool -- @return nil, an error string on error -function cache_chroot(info) +local function cache_chroot(info) for _,c in ipairs(info.chroot.groups_sorted) do for _,file in ipairs(info.chroot.groups_byname[c].files) do local rc, e = info.cache:cache_file(file.server, file.location, {}) @@ -139,7 +139,7 @@ end -- @param sel table of selected results -- @return bool -- @return nil, an error string on error -function fetch_sources(info, opts, sel) +local function fetch_sources(info, opts, sel) local rc1 = true -- global return code local nfail = 0 -- failure counter local e = err.new() -- no message yet, append the summary later on diff --git a/local/e2-ls-project.lua b/local/e2-ls-project.lua index d890179..69a099e 100644 --- a/local/e2-ls-project.lua +++ b/local/e2-ls-project.lua @@ -251,9 +251,9 @@ for _, s in pairs(sources) do end --------------------- results -s1 = "|" -s2 = " " -s3 = " " +local s1 = "|" +local s2 = " " +local s3 = " " pempty(s1, s2, s3) s2 = " " p1(s1, s2, "res") @@ -277,13 +277,13 @@ for _, r in pairs(results) do end --------------------- licences -s1 = "|" -s2 = " " -s3 = " " +local s1 = "|" +local s2 = " " +local s3 = " " pempty(s1, s2, s3) s2 = "|" p1(s1, s2, "licences") -llen = #info.licences_sorted +local llen = #info.licences_sorted for _,l in pairs(info.licences_sorted) do local lic = info.licences[l] llen = llen - 1 diff --git a/local/e2-new-source.lua b/local/e2-new-source.lua index ea6be5f..22abca3 100644 --- a/local/e2-new-source.lua +++ b/local/e2-new-source.lua @@ -73,7 +73,7 @@ local opts, arguments = e2option.parse(arg) -- @param filename string: the filename -- @return a table with fields checksum and checksum_type ("sha1", "md5") -- @return nil, or an error string on error -function read_checksum(checksum_file, filename) +local function read_checksum(checksum_file, filename) e2lib.log(4, string.format("read_checksum(%s, %s)", checksum_file, filename)) local f, e = io.open(checksum_file, "r") @@ -120,7 +120,7 @@ end -- @param checksum_file: checksum file name -- @return bool -- @return nil, an error string on error -function write_checksum_file_sha1(source_file, checksum_file) +local function write_checksum_file_sha1(source_file, checksum_file) e2lib.log(4, string.format("write_checksum_file_sha1(%s, %s)", source_file, checksum_file)) local cmd = string.format("sha1sum %s > %s", @@ -132,7 +132,7 @@ function write_checksum_file_sha1(source_file, checksum_file) return true, nil end -function download(f) +local function download(f) local name = e2lib.basename(f) local cmd = string.format("curl --silent --fail %s > %s", e2lib.shquote(f), e2lib.shquote(name)) @@ -143,7 +143,7 @@ function download(f) return true, nil end -function mv(s, d) +local function mv(s, d) local cmd = string.format("mv %s %s", e2lib.shquote(s), e2lib.shquote(d)) local rc = e2lib.callcmd_capture(cmd) @@ -160,7 +160,7 @@ end -- @param flags table: flags -- @return bool -- @return nil, an error string on error -function new_files_source(c, server, location, source_file, checksum_file, +local function new_files_source(c, server, location, source_file, checksum_file, checksum_file_format, no_checksum) local source_file_base = e2lib.basename(source_file) local do_checksum = (not no_checksum) diff --git a/local/e2-playground.lua b/local/e2-playground.lua index 644b72d..1ed062e 100644 --- a/local/e2-playground.lua +++ b/local/e2-playground.lua @@ -71,7 +71,7 @@ if #arguments ~= 1 then e2option.usage(1) end -r = arguments[1] +local r = arguments[1] -- apply the standard build mode to all results for _,res in pairs(info.results) do diff --git a/local/policy.lua b/local/policy.lua index 367a7d1..dd4cba3 100644 --- a/local/policy.lua +++ b/local/policy.lua @@ -59,7 +59,7 @@ end -- @return the server to store the result on -- @return the location to store the result in local results_server = "results" -function storage_release(location, release_id) +local function storage_release(location, release_id) return results_server, string.format("%s/release/%s", location, release_id) end -- 2.39.5