[latex3-commits] [git/LaTeX3-latex3-l3build] master: Remove local, add local (0d86c7b)
LAURENS Jérôme
jerome.laurens at u-bourgogne.fr
Sun Feb 21 12:28:08 CET 2021
Repository : https://github.com/latex3/l3build
On branch : master
Link : https://github.com/latex3/l3build/commit/0d86c7b8fe21d15f6893b9941e5da4428e46c91b
>---------------------------------------------------------------
commit 0d86c7b8fe21d15f6893b9941e5da4428e46c91b
Author: LAURENS Jérôme <jerome.laurens at u-bourgogne.fr>
Date: Sun Feb 21 12:28:08 2021 +0100
Remove local, add local
Remove local redeclaration of a local variable
Rename locals that hide outer locals (appending '_a' for example).
Simplify the shuffle overhead
Remove unused variable
>---------------------------------------------------------------
0d86c7b8fe21d15f6893b9941e5da4428e46c91b
l3build-check.lua | 41 ++++++++++++++++++-----------------------
l3build-file-functions.lua | 39 +++++++++++++++++++--------------------
l3build-help.lua | 4 ++--
l3build-install.lua | 24 ++++++++++++------------
l3build-manifest-setup.lua | 10 ++++------
l3build-stdmain.lua | 2 ++
l3build-tagging.lua | 2 +-
l3build-typesetting.lua | 20 ++++++++++----------
l3build-unpack.lua | 2 --
l3build-upload.lua | 12 ++++++++++--
10 files changed, 78 insertions(+), 78 deletions(-)
diff --git a/l3build-check.lua b/l3build-check.lua
index fb624e7..f7782af 100644
--- a/l3build-check.lua
+++ b/l3build-check.lua
@@ -134,7 +134,7 @@ local function normalize_log(content,engine,errlevels)
not match(line, "%.%.%.$") then
return "", (lastline or "") .. line
end
- local line = (lastline or "") .. line
+ line = (lastline or "") .. line
lastline = ""
-- Zap ./ at begin of filename
line = gsub(line, "%(%.%/", "(")
@@ -696,17 +696,17 @@ function runtest(name, engine, hide, ext, pdfmode, breakout)
cp(lvtfile, fileexists(testfiledir .. "/" .. lvtfile)
and testfiledir or unpackdir, testdir)
local checkopts = checkopts
- local engine = engine or stdengine
+ engine = engine or stdengine
local binary = engine
- local format = gsub(engine,"tex$",checkformat)
+ format = gsub(engine,"tex$",checkformat)
-- Special binary/format combos
if specialformats[checkformat] and next(specialformats[checkformat]) then
local t = specialformats[checkformat]
- if t[engine] and next(t[engine]) then
- local t = t[engine]
- binary = t.binary or binary
- checkopts = t.options or checkopts
- format = t.format or format
+ local t_ngn = t[engine]
+ if t_ngn and next(t_ngn) then
+ binary = t_ngn.binary or binary
+ checkopts = t_ngn.options or checkopts
+ format = t_ngn.format or format
end
end
-- Finalise format string
@@ -807,11 +807,11 @@ function runtest(name, engine, hide, ext, pdfmode, breakout)
for _,filetype in pairs(auxfiles) do
for _,file in pairs(filelist(testdir, filetype)) do
if match(file,"^" .. name .. ".[^.]+$") then
- local ext = match(file, "%.[^.]+$")
- if ext ~= lvtext and
- ext ~= tlgext and
- ext ~= lveext and
- ext ~= logext then
+ local e7n = match(file, "%.[^.]+$")
+ if e7n ~= lvtext and
+ e7n ~= tlgext and
+ e7n ~= lveext and
+ e7n ~= logext then
local newname = gsub(file,"(%.[^.]+)$","." .. engine .. "%1")
if fileexists(testdir,newname) then
rm(testdir,newname)
@@ -908,17 +908,12 @@ function check(names)
end
end
end
- -- https://stackoverflow.com/a/32167188
- local function shuffle(tbl)
- local len, random = #tbl, rnd
- for i = len, 2, -1 do
- local j = random(1, i)
- tbl[i], tbl[j] = tbl[j], tbl[i]
- end
- return tbl
- end
if options["shuffle"] then
- names = shuffle(names)
+ -- https://stackoverflow.com/a/32167188
+ for i = #names, 2, -1 do
+ local j = rnd(1, i)
+ names[i], names[j] = names[j], names[i]
+ end
end
-- Actually run the tests
print("Running checks on")
diff --git a/l3build-file-functions.lua b/l3build-file-functions.lua
index c80a761..2dfaa79 100644
--- a/l3build-file-functions.lua
+++ b/l3build-file-functions.lua
@@ -36,7 +36,6 @@ local execute = os.execute
local exit = os.exit
local getenv = os.getenv
local remove = os.remove
-local os_time = os.time
local os_type = os.type
local luatex_revision = status.luatex_revision
@@ -183,6 +182,7 @@ function abspath(path)
error(msg)
end
+-- TODO: Fix the cross platform problem
function escapepath(path)
if os_type == "windows" then
local path,count = gsub(path,'"','')
@@ -214,22 +214,21 @@ end
-- Copy files 'quietly'
function cp(glob, source, dest)
local errorlevel
- for i,_ in pairs(tree(source, glob)) do
- local source = source .. "/" .. i
+ for p_rel,p_cwd in pairs(tree(source, glob)) do
if os_type == "windows" then
- if attributes(source)["mode"] == "directory" then
+ if attributes(p_cwd)["mode"] == "directory" then
errorlevel = execute(
- 'xcopy /y /e /i "' .. unix_to_win(source) .. '" "'
- .. unix_to_win(dest .. '/' .. i) .. '" > nul'
+ 'xcopy /y /e /i "' .. unix_to_win(p_cwd) .. '" "'
+ .. unix_to_win(dest .. '/' .. p_rel) .. '" > nul'
)
else
errorlevel = execute(
- 'xcopy /y "' .. unix_to_win(source) .. '" "'
+ 'xcopy /y "' .. unix_to_win(p_cwd) .. '" "'
.. unix_to_win(dest .. '/') .. '" > nul'
)
end
else
- errorlevel = execute("cp -RLf '" .. source .. "' '" .. dest .. "'")
+ errorlevel = execute("cp -RLf '" .. p_cwd .. "' '" .. dest .. "'")
end
if errorlevel ~=0 then
return errorlevel
@@ -302,10 +301,10 @@ function tree(path, glob)
end
local dirs = {["."] = cropdots(path)}
for pattern, criterion in gmatch(cropdots(glob), "([^/]+)(/?)") do
- local criterion = criterion == "/" and is_dir or always_true
- local function fill(path, dir, table)
+ criterion = criterion == "/" and is_dir or always_true
+ local function fill(path_a, dir, table)
for _, file in ipairs(filelist(dir, pattern)) do
- local fullpath = path .. "/" .. file
+ local fullpath = path_a .. "/" .. file
if file ~= "." and file ~= ".." and
fullpath ~= builddir
then
@@ -319,13 +318,13 @@ function tree(path, glob)
local newdirs = {}
if pattern == "**" then
while true do
- local path, dir = next(dirs)
- if not path then
+ local path_a, dir = next(dirs)
+ if not path_a then
break
end
- dirs[path] = nil
- newdirs[path] = dir
- fill(path, dir, dirs)
+ dirs[path_a] = nil
+ newdirs[path_a] = dir
+ fill(path_a, dir, dirs)
end
else
for path, dir in pairs(dirs) do
@@ -357,7 +356,7 @@ function mkdir(dir)
if os_type == "windows" then
-- Windows (with the extensions) will automatically make directory trees
-- but issues a warning if the dir already exists: avoid by including a test
- local dir = unix_to_win(dir)
+ dir = unix_to_win(dir)
return execute(
"if not exist " .. dir .. "\\nul " .. "mkdir " .. dir
)
@@ -368,10 +367,10 @@ end
-- Rename
function ren(dir, source, dest)
- local dir = dir .. "/"
+ dir = dir .. "/"
if os_type == "windows" then
- local source = gsub(source, "^%.+/", "")
- local dest = gsub(dest, "^%.+/", "")
+ source = gsub(source, "^%.+/", "")
+ dest = gsub(dest, "^%.+/", "")
return execute("ren " .. unix_to_win(dir) .. source .. " " .. dest)
else
return execute("mv " .. dir .. source .. " " .. dir .. dest)
diff --git a/l3build-help.lua b/l3build-help.lua
index 8627e14..6431ac5 100644
--- a/l3build-help.lua
+++ b/l3build-help.lua
@@ -39,7 +39,7 @@ end
function help()
local function setup_list(list)
local longest = 0
- for k,v in pairs(list) do
+ for k,_ in pairs(list) do
if k:len() > longest then
longest = k:len()
end
@@ -70,7 +70,7 @@ function help()
end
print("")
print("Valid options are:")
- local longest,t = setup_list(option_list)
+ longest,t = setup_list(option_list)
for _,k in ipairs(t) do
local opt = option_list[k]
local filler = rep(" ", longest - k:len() + 1)
diff --git a/l3build-install.lua b/l3build-install.lua
index 92bfa12..cea9aa1 100644
--- a/l3build-install.lua
+++ b/l3build-install.lua
@@ -97,7 +97,7 @@ function uninstall()
if errorlevel ~= 0 then return errorlevel end
-- Finally, clean up special locations
for _,location in ipairs(tdslocations) do
- local path,glob = splitpath(location)
+ local path = splitpath(location)
errorlevel = zapdir(path)
if errorlevel ~= 0 then return errorlevel end
end
@@ -140,11 +140,11 @@ function install_files(target,full,dry_run)
end
local matched = false
for _,location in ipairs(tdslocations) do
- local path,glob = splitpath(location)
- local pattern = glob_to_pattern(glob)
+ local l_dir,l_glob = splitpath(location)
+ local pattern = glob_to_pattern(l_glob)
if match(filename,pattern) then
- insert(paths,path)
- insert(filenames,path .. sourcepath .. filename)
+ insert(paths,l_dir)
+ insert(filenames,l_dir .. sourcepath .. filename)
matched = true
break
end
@@ -162,12 +162,12 @@ function install_files(target,full,dry_run)
if next(filenames) then
if not dry_run then
for _,path in pairs(paths) do
- local dir = target .. "/" .. path
- if not cleanpaths[dir] then
- errorlevel = cleandir(dir)
+ local dir_a = target .. "/" .. path
+ if not cleanpaths[dir_a] then
+ errorlevel = cleandir(dir_a)
if errorlevel ~= 0 then return errorlevel end
end
- cleanpaths[dir] = true
+ cleanpaths[dir_a] = true
end
end
for _,file in ipairs(filenames) do
@@ -192,17 +192,17 @@ function install_files(target,full,dry_run)
exclude = exclude or { }
dir = dir or currentdir
local includelist = { }
- local excludelist = { }
+ local excludelist_a = { }
for _,glob_table in pairs(exclude) do
for _,glob in pairs(glob_table) do
for file,_ in pairs(tree(dir,glob)) do
- excludelist[file] = true
+ excludelist_a[file] = true
end
end
end
for _,glob in pairs(include) do
for file,_ in pairs(tree(dir,glob)) do
- if not excludelist[file] then
+ if not excludelist_a[file] then
insert(includelist, file)
end
end
diff --git a/l3build-manifest-setup.lua b/l3build-manifest-setup.lua
index e00f48f..e0da78e 100644
--- a/l3build-manifest-setup.lua
+++ b/l3build-manifest-setup.lua
@@ -221,18 +221,16 @@ end
--]]
manifest_sort_within_match = manifest_sort_within_match or function(files)
- local f = files
- table.sort(f)
- return f
+ table.sort(files)
+ return files
end
manifest_sort_within_group = manifest_sort_within_group or function(files)
- local f = files
--[[
-- no-op by default; make your own definition to customise. E.g.:
- table.sort(f)
+ table.sort(files)
--]]
- return f
+ return files
end
--[[
diff --git a/l3build-stdmain.lua b/l3build-stdmain.lua
index b086eb0..48d596f 100644
--- a/l3build-stdmain.lua
+++ b/l3build-stdmain.lua
@@ -22,6 +22,8 @@ for those people who are interested.
--]]
+local lfs = require("lfs")
+
local exit = os.exit
local insert = table.insert
diff --git a/l3build-tagging.lua b/l3build-tagging.lua
index aa84b0d..3dbe4b1 100644
--- a/l3build-tagging.lua
+++ b/l3build-tagging.lua
@@ -51,7 +51,7 @@ local function update_file_tag(file,tagname,tagdate)
else
local path = dirname(file)
ren(path,filename,filename .. ".bak")
- local f = assert(open(file,"w"))
+ f = assert(open(file,"w"))
-- Convert line ends back if required during write
-- Watch for the second return value!
f:write((gsub(updated_content,"\n",os_newline)))
diff --git a/l3build-typesetting.lua b/l3build-typesetting.lua
index 0ae25a9..da57cb8 100644
--- a/l3build-typesetting.lua
+++ b/l3build-typesetting.lua
@@ -49,9 +49,9 @@ end
-- An auxiliary used to set up the environmental variables
function runcmd(cmd,dir,vars)
- local dir = dir or "."
- local dir = abspath(dir)
- local vars = vars or {}
+ dir = dir or "."
+ dir = abspath(dir)
+ vars = vars or {}
-- Allow for local texmf files
local env = os_setenv .. " TEXMFCNF=." .. os_pathsep
local localtexmf = ""
@@ -80,7 +80,7 @@ function biber(name,dir)
end
function bibtex(name,dir)
- local dir = dir or "."
+ dir = dir or "."
if fileexists(dir .. "/" .. name .. ".aux") then
-- LaTeX always generates an .aux file, so there is a need to
-- look inside it for a \citation line
@@ -105,7 +105,7 @@ function bibtex(name,dir)
end
function makeindex(name,dir,inext,outext,logext,style)
- local dir = dir or "."
+ dir = dir or "."
if fileexists(dir .. "/" .. name .. inext) then
if style == "" then style = nil end
return runcmd(makeindexexe .. " " .. makeindexopts
@@ -119,15 +119,15 @@ function makeindex(name,dir,inext,outext,logext,style)
end
function tex(file,dir,cmd)
- local dir = dir or "."
- local cmd = cmd or typesetexe .. typesetopts
+ dir = dir or "."
+ cmd = cmd or typesetexe .. typesetopts
return runcmd(cmd .. " \"" .. typesetcmds
.. "\\input " .. file .. "\"",
dir,{"TEXINPUTS","LUAINPUTS"})
end
local function typesetpdf(file,dir)
- local dir = dir or "."
+ dir = dir or "."
local name = jobname(file)
print("Typesetting " .. name)
local fn = typeset
@@ -141,7 +141,7 @@ local function typesetpdf(file,dir)
print(" ! Compilation failed")
return errorlevel
end
- pdfname = name .. pdfext
+ local pdfname = name .. pdfext
rm(docfiledir,pdfname)
return cp(pdfname,dir,docfiledir)
end
@@ -226,7 +226,7 @@ function doc(files)
end
-- Now know if we should typeset this source
if typeset then
- local errorlevel = typesetpdf(srcname,path)
+ errorlevel = typesetpdf(srcname,path)
if errorlevel ~= 0 then
return errorlevel
else
diff --git a/l3build-unpack.lua b/l3build-unpack.lua
index d5c8e30..83466c0 100644
--- a/l3build-unpack.lua
+++ b/l3build-unpack.lua
@@ -22,8 +22,6 @@ for those people who are interested.
--]]
-local execute = os.execute
-
-- Unpack the package files using an 'isolated' system: this requires
-- a copy of the 'basic' DocStrip program, which is used then removed
function unpack(sources, sourcedirs)
diff --git a/l3build-upload.lua b/l3build-upload.lua
index 7270ebf..a4dcf10 100644
--- a/l3build-upload.lua
+++ b/l3build-upload.lua
@@ -78,6 +78,12 @@ end
-- if upload is anything else, the user will be prompted whether to upload.
-- For now, this is undocumented. I think I would prefer to keep it always set to ask for the time being.
+local ctan_post -- this is private to the module
+
+-- TODO: next is a public global method,
+-- but following functions are semantically local
+-- despite they are declared globally.
+
function upload(tagnames)
local uploadfile = ctanzip..".zip"
@@ -100,7 +106,7 @@ function upload(tagnames)
uploadconfig.note = uploadconfig.note or file_contents(uploadconfig.note_file)
- local tagnames = tagnames or { }
+ tagnames = tagnames or { }
uploadconfig.version = tagnames[1] or uploadconfig.version
local override_update_check = false
@@ -214,7 +220,7 @@ end
function shell(s)
local h = assert(popen(s, 'r'))
- t = assert(h:read('*a'))
+ local t = assert(h:read('*a'))
h:close()
return t
end
@@ -248,11 +254,13 @@ function construct_ctan_post(uploadfile,debug)
ctan_field("uploader", uploadconfig.uploader, 255, "Name of uploader", true, false )
ctan_field("version", uploadconfig.version, 32, "Package version", true, false )
+ --[=[ `qq` is unused because line 258 is commented
-- finish constructing the curl command:
local qq = '"'
if os_type == "windows" then
qq = '\"'
end
+ --]=]
-- commandline ctan_post = ctan_post .. ' --form ' .. qq .. 'file=@' .. tostring(uploadfile) .. ';filename=' .. tostring(uploadfile) .. qq
ctan_post = ctan_post .. '\nform="file=@' .. tostring(uploadfile) . ';filename=' .. tostring(uploadfile) .. '"'
More information about the latex3-commits
mailing list.