diff options
Diffstat (limited to 'tex/context/base/luat-cod.lua')
-rw-r--r-- | tex/context/base/luat-cod.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tex/context/base/luat-cod.lua b/tex/context/base/luat-cod.lua index 815d7f92c..87b2c0059 100644 --- a/tex/context/base/luat-cod.lua +++ b/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,14 +35,16 @@ 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 - bytedone[barename] = true + bytedone[basename] = true if environment.initex then local n = lua.lastbytecode + 1 bytedata[n] = { barename, version or "0.000" } @@ -53,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")) + texio.write_nl(format("fatal error: invalid finalizer, action: %s",comment)) os.exit() end end |