summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/luat-cnf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/luat-cnf.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/luat-cnf.lua167
1 files changed, 114 insertions, 53 deletions
diff --git a/Master/texmf-dist/tex/context/base/luat-cnf.lua b/Master/texmf-dist/tex/context/base/luat-cnf.lua
index e45aceb79f4..609dc412bcf 100644
--- a/Master/texmf-dist/tex/context/base/luat-cnf.lua
+++ b/Master/texmf-dist/tex/context/base/luat-cnf.lua
@@ -6,41 +6,49 @@ if not modules then modules = { } end modules ['luat-cnf'] = {
license = "see context related readme files"
}
+local type, next, tostring, tonumber = type, next, tostring, tonumber
local format, concat, find = string.format, table.concat, string.find
-luatex = luatex or { }
-
-luatex.variablenames = {
- 'main_memory', 'extra_mem_bot', 'extra_mem_top',
- 'buf_size','expand_depth',
- 'font_max', 'font_mem_size',
- 'hash_extra', 'max_strings', 'pool_free', 'pool_size', 'string_vacancies',
- 'obj_tab_size', 'pdf_mem_size', 'dest_names_size',
- 'nest_size', 'param_size', 'save_size', 'stack_size','expand_depth',
- 'trie_size', 'hyph_size', 'max_in_open',
- 'ocp_stack_size', 'ocp_list_size', 'ocp_buf_size',
- 'max_print_line',
-}
+local allocate = utilities.storage.allocate
-function luatex.variables()
- local t, x = { }, nil
- for _,v in next, luatex.variablenames do
- x = resolvers.var_value(v)
- if x and find(x,"^%d+$") then
- t[v] = tonumber(x)
- end
- end
- return t
-end
+texconfig.kpse_init = false
+texconfig.shell_escape = 't'
-if not luatex.variables_set then
- for k, v in next, luatex.variables() do
- texconfig[k] = v
- end
- luatex.variables_set = true
-end
+luatex = luatex or { }
+local luatex = luatex
+
+texconfig.error_line = 79 -- 79 -- obsolete
+texconfig.half_error_line = 50 -- 50 -- obsolete
+
+texconfig.expand_depth = 10000 -- 10000
+texconfig.hash_extra = 100000 -- 0
+texconfig.nest_size = 1000 -- 50
+texconfig.max_in_open = 500 -- 15
+texconfig.max_print_line = 10000 -- 79
+texconfig.max_strings = 500000 -- 15000
+texconfig.param_size = 25000 -- 60
+texconfig.save_size = 50000 -- 4000
+texconfig.stack_size = 10000 -- 300
+
+--~ local function initialize()
+--~ local t, variable = allocate(), resolvers.variable
+--~ for name, default in next, variablenames do
+--~ local name = variablenames[i]
+--~ local value = variable(name)
+--~ value = tonumber(value)
+--~ if not value or value == "" or value == 0 then
+--~ value = default
+--~ end
+--~ texconfig[name], t[name] = value, value
+--~ end
+--~ initialize = nil
+--~ return t
+--~ end
+
+--~ luatex.variables = initialize()
local stub = [[
+
-- checking
storage = storage or { }
@@ -48,7 +56,7 @@ luatex = luatex or { }
-- we provide our own file handling
-texconfig.kpse_init = false
+texconfig.kpse_init = false
texconfig.shell_escape = 't'
-- as soon as possible
@@ -59,14 +67,66 @@ luatex.starttime = os.gettimeofday()
function texconfig.init()
- -- shortcut and helper
+ -- development
+
+ local builtin, globals = { }, { }
+
+ libraries = { -- we set it her as we want libraries also 'indexed'
+ basiclua = {
+ "string", "table", "coroutine", "debug", "file", "io", "lpeg", "math", "os", "package",
+ },
+ basictex = { -- noad
+ "callback", "font", "img", "lang", "lua", "node", "pdf", "status", "tex", "texconfig", "texio", "token",
+ },
+ extralua = {
+ "gzip", "zip", "zlib", "lfs", "ltn12", "mime", "socket", "md5", "profiler", "unicode", "utf",
+ },
+ extratex = {
+ "epdf", "fontloader", "kpse", "mplib",
+ },
+ obsolete = {
+ "fontforge", -- can be filled by luat-log
+ "kpse",
+ },
+ builtin = builtin, -- to be filled
+ globals = globals, -- to be filled
+ }
+
+ for k, v in next, _G do
+ globals[k] = tostring(v)
+ end
- local b = lua.bytecode
+ local function collect(t)
+ local lib = { }
+ for k, v in next, t do
+ local keys = { }
+ local gv = _G[v]
+ if type(gv) == "table" then
+ for k, v in next, gv do
+ keys[k] = tostring(v) -- true -- by tostring we cannot call overloades functions (security)
+ end
+ end
+ lib[v] = keys
+ builtin[v] = keys
+ end
+ return lib
+ end
+
+ libraries.basiclua = collect(libraries.basiclua)
+ libraries.basictex = collect(libraries.basictex)
+ libraries.extralua = collect(libraries.extralua)
+ libraries.extratex = collect(libraries.extratex)
+ libraries.obsolete = collect(libraries.obsolete)
+
+ -- shortcut and helper
local function init(start)
+ local b = lua.bytecode
local i = start
while b[i] do
- b[i]() ; b[i] = nil ; i = i + 1
+ b[i]() ;
+ b[i] = nil ;
+ i = i + 1
-- collectgarbage('step')
end
return i - start
@@ -89,27 +149,28 @@ end)
-- done, from now on input and callbacks are internal
]]
-function luatex.dumpstate(name,firsttable)
- if tex and tex.luatexversion < 38 then
- os.remove(name)
- elseif true then
- local t = {
- "-- this file is generated, don't change it\n",
- "-- configuration (can be overloaded later)\n"
- }
- for _,v in next, luatex.variablenames do
- local tv = texconfig[v]
- if tv then
- t[#t+1] = format("texconfig.%s=%s",v,tv)
- end
+
+local variablenames = {
+ "error_line", "half_error_line",
+ "expand_depth", "hash_extra", "nest_size",
+ "max_in_open", "max_print_line", "max_strings",
+ "param_size", "save_size", "stack_size",
+}
+
+local function makestub()
+ name = name or (environment.jobname .. ".lui")
+ firsttable = firsttable or lua.firstbytecode
+ local t = {
+ "-- this file is generated, don't change it\n",
+ "-- configuration (can be overloaded later)\n"
+ }
+ for _,v in next, variablenames do
+ local tv = texconfig[v]
+ if tv and tv ~= "" then
+ t[#t+1] = format("texconfig.%s=%s",v,tv)
end
- io.savedata(name,format("%s\n\n%s",concat(t,"\n"),format(stub,firsttable or 501)))
- else
- io.savedata(name,format(stub,firsttable or 501))
end
+ io.savedata(name,format("%s\n\n%s",concat(t,"\n"),format(stub,firsttable)))
end
-texconfig.kpse_init = false
-texconfig.max_print_line = 100000
-texconfig.max_in_open = 127
-texconfig.shell_escape = 't'
+lua.registerfinalizer(makestub,"create stub file")