diff options
| author | Philipp Gesang <phg42.2a@gmail.com> | 2013-04-30 13:22:32 -0700 | 
|---|---|---|
| committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-04-30 13:22:32 -0700 | 
| commit | 5199cbc39231d796d802ad9966e45718d5edd18d (patch) | |
| tree | 9cea5bb1e950d96a8aa3b86ba5db9d8c3e85072b | |
| parent | 6165f2cda31a0ad5330360d2edd7cb480ef52179 (diff) | |
| parent | 89e6b7e01691688713a5e7c02e5d642b28abfefc (diff) | |
| download | lualibs-5199cbc39231d796d802ad9966e45718d5edd18d.tar.gz | |
Merge pull request #4 from phi-gamma/master
eliminate module()
| -rw-r--r-- | lualibs-basic.lua | 22 | ||||
| -rw-r--r-- | lualibs-compat.lua | 2 | ||||
| -rw-r--r-- | lualibs-extended.lua | 38 | ||||
| -rw-r--r-- | lualibs.lua | 55 | 
4 files changed, 57 insertions, 60 deletions
| diff --git a/lualibs-basic.lua b/lualibs-basic.lua index 8bdaf70..cd28e75 100644 --- a/lualibs-basic.lua +++ b/lualibs-basic.lua @@ -1,21 +1,19 @@ ---  This is file `lualibs-basic.lua', -module('lualibs-basic', package.seeall) +lualibs = lualibs or { }  local lualibs_basic_module = {    name          = "lualibs-basic", -  version       = 1.01, -  date          = "2013/04/10", -  description   = "Basic Lua extensions, meta package.", -  author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux", +  version       = 2.00, +  date          = "2013/04/30", +  description   = "ConTeXt Lua libraries -- basic collection.", +  author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",    copyright     = "PRAGMA ADE / ConTeXt Development Team",    license       = "See ConTeXt's mreadme.pdf for the license",  } -local lualibs = _G.config.lualibs  local error, warn, info = lualibs.error, lualibs.warn, lualibs.info -local loadmodule   = lualibs.loadmodule -local stringformat = string.format +local loadmodule      = lualibs.loadmodule +local stringformat    = string.format  local loaded = false  if lualibs.prefer_merged then @@ -46,9 +44,5 @@ if loaded == false then    loadmodule("lualibs-set.lua")  end --- these don’t look much basic to me: ---l-pdfview.lua ---l-xml.lua - +lualibs.basic_loaded = true  -- vim:tw=71:sw=2:ts=2:expandtab ---  End of File `lualibs.lua'. diff --git a/lualibs-compat.lua b/lualibs-compat.lua index cb9d8f0..707f26b 100644 --- a/lualibs-compat.lua +++ b/lualibs-compat.lua @@ -1,5 +1,7 @@  #!/usr/bin/env texlua +lualibs = lualibs or { } +  local stringgsub  = string.gsub  local stringlower = string.lower  local next        = next diff --git a/lualibs-extended.lua b/lualibs-extended.lua index b0aea31..293df39 100644 --- a/lualibs-extended.lua +++ b/lualibs-extended.lua @@ -1,23 +1,21 @@ ---  This is file `lualibs-extended.lua', -module('lualibs-extended', package.seeall) +lualibs = lualibs or { }  local lualibs_extended_module = {    name          = "lualibs-extended", -  version       = 1.01, -  date          = "2013/04/10", -  description   = "Basic Lua extensions, meta package.", -  author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux", +  version       = 2.00, +  date          = "2013/04/30", +  description   = "ConTeXt Lua libraries -- extended collection.", +  author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",    copyright     = "PRAGMA ADE / ConTeXt Development Team",    license       = "See ConTeXt's mreadme.pdf for the license",  } -local lualibs = _G.config.lualibs  local error, warn, info = lualibs.error, lualibs.warn, lualibs.info -local stringformat  = string.format -local loadmodule    = lualibs.loadmodule -local texiowrite    = texio.write -local texiowrite_nl = texio.write_nl +local stringformat     = string.format +local loadmodule       = lualibs.loadmodule +local texiowrite       = texio.write +local texiowrite_nl    = texio.write_nl  --[[doc--  Here we define some functions that fake the elaborate logging/tracking @@ -92,12 +90,12 @@ restore it after we are done loading.  local backup_store = { }  local fake_context = function ( ) -  if _G.logs     then backup_store.logs     = _G.logs     end -  if _G.trackers then backup_store.trackers = _G.trackers end -  _G.logs     = fake_logs"logs" -  _G.trackers = fake_trackers"trackers" +  if logs     then backup_store.logs     = logs     end +  if trackers then backup_store.trackers = trackers end +  logs     = fake_logs"logs" +  trackers = fake_trackers"trackers" -  backup_store.argv = table.fastcopy(_G.arg) +  backup_store.argv = table.fastcopy(arg)  end @@ -108,9 +106,9 @@ local unfake_context = function ( )    if backup_store then      local bl, bt = backup_store.logs, backup_store.trackers      local argv   = backup_store.argv -    if bl   then _G.logs     = bl   end -    if bt   then _G.trackers = bt   end -    if argv then _G.arg      = argv end +    if bl   then logs     = bl   end +    if bt   then trackers = bt   end +    if argv then arg      = argv end    end  end @@ -155,5 +153,5 @@ loadmodule"lualibs-util-jsn.lua"--- cannot be merged because of return statement  unfake_context() --- TODO check if this works at runtime +lualibs.extended_loaded = true  -- vim:tw=71:sw=2:ts=2:expandtab ---  End of File `lualibs-extended.lua'. diff --git a/lualibs.lua b/lualibs.lua index f126fb7..aa6a736 100644 --- a/lualibs.lua +++ b/lualibs.lua @@ -1,29 +1,30 @@ ---  This is file `lualibs.lua', -module('lualibs', package.seeall) +lualibs = lualibs or { } -local lualibs_module = { +lualibs.module_info = {    name          = "lualibs", -  version       = 1.01, -  date          = "2013/04/10", -  description   = "Lua additional functions.", -  author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux", +  version       = 2.00, +  date          = "2013/04/30", +  description   = "ConTeXt Lua standard libraries.", +  author        = "Hans Hagen, PRAGMA-ADE, Hasselt NL & Elie Roux & Philipp Gesang",    copyright     = "PRAGMA ADE / ConTeXt Development Team",    license       = "See ConTeXt's mreadme.pdf for the license",  } -_G.config              = _G.config or { } -_G.config.lualibs      = _G.config.lualibs or { } -local lualibs          = _G.config.lualibs +config           = config or { } +config.lualibs   = config.lualibs or { } -if lualibs.prefer_merged == nil then lualibs.prefer_merged = true end -if lualibs.load_extended == nil then lualibs.load_extended = true end -lualibs.verbose = lualibs.verbose == true or false - -local lpeg, kpse = lpeg, kpse +if config.lualibs.prefer_merged == nil then +  lualibs.prefer_merged = true +end +if config.lualibs.load_extended == nil then +  lualibs.load_extended = true +end +config.lualibs.verbose = config.lualibs.verbose == true -local dofile       = dofile -local lpegmatch    = lpeg.match -local stringformat = string.format +local dofile        = dofile +local kpsefind_file = kpse.find_file +local stringformat  = string.format +local texiowrit_nl  = texio.write_nl  local find_file, error, warn, info  do @@ -31,10 +32,9 @@ do    if luatexbase and luatexbase.provides_module then      _error, _warn, _info = luatexbase.provides_module(lualibs_module)    else -    _error, _warn, _info = texio.write_nl, texio.write_nl, texio.write_nl -- stub +    _error, _warn, _info = texiowrite_nl, texiowrite_nl, texiowrite_nl    end -  -- if lualibs.verbose then     if lualibs.verbose then      error, warn, info = _error, _warn, _info    else @@ -48,12 +48,12 @@ if luatexbase and luatexbase.find_file then    find_file = luatexbase.find_file  else    kpse.set_program_name"luatex" -  find_file = kpse.find_file +  find_file = kpsefind_file  end -loadmodule = _G.loadmodule or function (name, t) +loadmodule = loadmodule or function (name, t)    if not t then t = "library" end -  local filepath  = kpse.find_file(name, "lua") +  local filepath  = kpsefind_file(name, "lua")    if not filepath or filepath == "" then      warn(stringformat("Could not locate %s “%s”.", t, name))      return false @@ -67,10 +67,13 @@ lualibs.loadmodule = loadmodule  The separation of the “basic” from the “extended” sets coincides with  the split into luat-bas.mkiv and luat-lib.mkiv.  --doc]]-- -loadmodule"lualibs-basic.lua" -loadmodule"lualibs-compat.lua" --- restore stuff gone since v1.* +if lualibs.basic_loaded ~= true then +  loadmodule"lualibs-basic.lua" +  loadmodule"lualibs-compat.lua" --- restore stuff gone since v1.* +end -if load_extended == true then +if  lualibs.load_extended   == true +and lualibs.extended_loaded ~= true then    loadmodule"lualibs-extended.lua"  end | 
