[latex3-commits] [git/LaTeX3-latex3-l3build] master, standalone: Local copies of various globals (821f938)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Mar 6 09:53:17 CET 2018


Repository : https://github.com/latex3/l3build
On branches: master,standalone
Link       : https://github.com/latex3/l3build/commit/821f9381643c6d562ac1f2106fdd11486e57011c

>---------------------------------------------------------------

commit 821f9381643c6d562ac1f2106fdd11486e57011c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Mar 6 08:51:25 2018 +0000

    Local copies of various globals
    
    Std Lua practice.


>---------------------------------------------------------------

821f9381643c6d562ac1f2106fdd11486e57011c
 l3build-arguments.lua |   33 ++++++++++++++++++++-------------
 l3build-aux.lua       |    3 +++
 l3build.lua           |    5 +++--
 3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/l3build-arguments.lua b/l3build-arguments.lua
index 78eb542..b367039 100644
--- a/l3build-arguments.lua
+++ b/l3build-arguments.lua
@@ -25,6 +25,13 @@ for those people who are interested.
 local exit             = os.exit
 local stderr           = io.stderr
 
+local find             = string.find
+local gmatch           = string.gmatch
+local match            = string.match
+local sub              = string.sub
+
+local insert           = table.insert
+
 -- Parse command line options
 
 option_list =
@@ -140,7 +147,7 @@ local function argparse()
   result["target"] = "help"
   if a then
     -- No options are allowed in position 1, so filter those out
-    if not string.match(a, "^%-") then
+    if not match(a, "^%-") then
       result["target"] = a
     end
   end
@@ -152,7 +159,7 @@ local function argparse()
   local function remainder(num)
     local names = { }
     for i = num, #arg do
-      table.insert(names, arg[i])
+      insert(names, arg[i])
     end
     return names
   end
@@ -172,22 +179,22 @@ local function argparse()
     local optarg
     local opts
     -- Look for and option and get it into a variable
-    if string.match(a, "^%-") then
-      if string.match(a, "^%-%-") then
+    if match(a, "^%-") then
+      if match(a, "^%-%-") then
         opts = long_options
-        local pos = string.find(a, "=", 1, true)
+        local pos = find(a, "=", 1, true)
         if pos then
-          opt    = string.sub(a, 3, pos - 1)
-          optarg = string.sub(a, pos + 1)
+          opt    = sub(a, 3, pos - 1)
+          optarg = sub(a, pos + 1)
         else
-          opt = string.sub(a, 3)
+          opt = sub(a, 3)
         end
       else
         opts = short_options
-        opt  = string.sub(a, 2, 2)
+        opt  = sub(a, 2, 2)
         -- Only set optarg if it is there
         if #a > 2 then
-          optarg = string.sub(a, 3)
+          optarg = sub(a, 3)
         end
       end
       -- Now check that the option is valid and sort out the argument
@@ -197,7 +204,7 @@ local function argparse()
         -- Tidy up arguments
         if option_list[optname]["type"] == "boolean" then
           if optarg then
-            local opt = "-" .. (string.match(a, "^%-%-") and "-" or "") . opt
+            local opt = "-" .. (match(a, "^%-%-") and "-" or "") .. opt
             stderr:write("Value not allowed for option " .. opt .."\n")
             return {"help"}
           end
@@ -221,8 +228,8 @@ local function argparse()
           result[optname] = optarg
         else
           local opts = result[optname] or { }
-          for hit in string.gmatch(optarg, "([^,%s]+)") do
-            table.insert(opts, hit)
+          for hit in gmatch(optarg, "([^,%s]+)") do
+            insert(opts, hit)
           end
           result[optname] = opts
         end
diff --git a/l3build-aux.lua b/l3build-aux.lua
index 102f9ba..db74664 100644
--- a/l3build-aux.lua
+++ b/l3build-aux.lua
@@ -22,6 +22,9 @@ for those people who are interested.
 
 --]]
 
+local match = string.match
+local pairs = pairs
+local print = print
 --
 -- Auxiliary functions which are used by more than one main function
 --
diff --git a/l3build.lua b/l3build.lua
index 6d18918..b81d405 100644
--- a/l3build.lua
+++ b/l3build.lua
@@ -32,6 +32,7 @@ local lfs = require("lfs")
 
 local assert           = assert
 local ipairs           = ipairs
+local lookup           = kpse.lookup
 local next             = next
 local print            = print
 local select           = select
@@ -41,9 +42,9 @@ local exit             = os.exit
 -- l3build setup and functions
 
 kpse.set_program_name("kpsewhich")
-build_kpse_path = string.match(kpse.lookup("l3build.lua"),"(.*[/])")
+build_kpse_path = string.match(lookup("l3build.lua"),"(.*[/])")
 local function build_require(s)
-  require( kpse.lookup("l3build-"..s..".lua", { path = build_kpse_path } ) )
+  require(lookup("l3build-"..s..".lua", { path = build_kpse_path } ) )
 end
 
 build_require("variables")





More information about the latex3-commits mailing list