summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/luat-cod.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
committerKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
commit824f7b0903de8ad7f6ee3d7656005e4c59155e06 (patch)
treeabfc8673ef9916f3ab7074e811207384c301492b /Master/texmf-dist/tex/context/base/luat-cod.lua
parent689aefb0727676ed3cddf331337b4be226495e72 (diff)
context import for TL13, from www.pragma-ade.com/context/beta/cont-tmf.zip
git-svn-id: svn://tug.org/texlive/trunk@29731 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/luat-cod.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/luat-cod.lua34
1 files changed, 23 insertions, 11 deletions
diff --git a/Master/texmf-dist/tex/context/base/luat-cod.lua b/Master/texmf-dist/tex/context/base/luat-cod.lua
index b022f31c3e9..8b015477f4e 100644
--- a/Master/texmf-dist/tex/context/base/luat-cod.lua
+++ b/Master/texmf-dist/tex/context/base/luat-cod.lua
@@ -6,6 +6,7 @@ if not modules then modules = { } end modules ['luat-cod'] = {
license = "see context related readme files"
}
+local type, loadfile = type, loadfile
local match, gsub, find, format = string.match, string.gsub, string.find, string.format
local texconfig, lua = texconfig, lua
@@ -19,11 +20,13 @@ texconfig.max_in_open = 127
-- registering bytecode chunks
-lua.bytecode = lua.bytecode or { } -- built in anyway
-lua.bytedata = lua.bytedata or { }
-lua.bytedone = lua.bytedone or { }
+local bytecode = lua.bytecode or { }
+local bytedata = lua.bytedata or { }
+local bytedone = lua.bytedone or { }
-local bytecode, bytedata, bytedone = lua.bytecode, lua.bytedata, lua.bytedone
+lua.bytecode = bytecode -- built in anyway
+lua.bytedata = bytedata
+lua.bytedone = bytedone
lua.firstbytecode = 501
lua.lastbytecode = lua.lastbytecode or (lua.firstbytecode - 1) -- as we load ourselves again ... maybe return earlier
@@ -32,18 +35,19 @@ function lua.registeredcodes()
return lua.lastbytecode - lua.firstbytecode + 1
end
+-- no file.* functions yet
+
function lua.registercode(filename,version)
local barename = gsub(filename,"%.[%a%d]+$","")
if barename == filename then filename = filename .. ".lua" end
local basename = match(barename,"^.+[/\\](.-)$") or barename
- if not bytedone[barename] then
+ if not bytedone[basename] then
local code = environment.luafilechunk(filename)
if code then
- assert(code)()
- bytedone[barename] = true
+ bytedone[basename] = true
if environment.initex then
local n = lua.lastbytecode + 1
- bytedata[n] = { barename, version }
+ bytedata[n] = { barename, version or "0.000" }
bytecode[n] = code
lua.lastbytecode = n
end
@@ -54,10 +58,11 @@ end
local finalizers = { }
function lua.registerfinalizer(f,comment)
+ comment = comment or "unknown"
if type(f) == "function" then
finalizers[#finalizers+1] = { action = f, comment = comment }
else
- print(format("fatal error: invalid finalizer, action: %s",finalizer.comment or "unknown"))
+ print(format("\nfatal error: invalid finalizer, action: %s\n",comment))
os.exit()
end
end
@@ -67,7 +72,7 @@ function lua.finalize(logger)
local finalizer = finalizers[i]
finalizer.action()
if logger then
- logger("finalizing lua", "action: %s",finalizer.comment)
+ logger("finalize action: %s",finalizer.comment)
end
end
end
@@ -98,13 +103,18 @@ if not environment.luafilechunk then
end
local data = loadfile(filename)
texio.write("<",data and "+ " or "- ",filename,">")
+ if data then
+ data()
+ end
return data
end
end
-if not environment.engineflags then
+if not environment.engineflags then -- raw flags
+
local engineflags = { }
+
for i=-10,#arg do
local a = arg[i]
if a then
@@ -114,7 +124,9 @@ if not environment.engineflags then
end
end
end
+
environment.engineflags = engineflags
+
end
-- We need a few premature callbacks in the format generator. We