From 5b1497034d25e3aaf59c7e9d5d5c0305e493277e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Fri, 10 Jul 2020 20:46:08 +0200 Subject: [PATCH] Drop useless test --- luametalatex-init.lua | 35 +++++++++++++++-------------------- luametalatex.lua | 15 +-------------- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/luametalatex-init.lua b/luametalatex-init.lua index 22d45ef..0f20008 100644 --- a/luametalatex-init.lua +++ b/luametalatex-init.lua @@ -1,31 +1,18 @@ do - local ourpath = lua.startupfile:match('(.*[/\\])[^/\\]*%.lua$') + local ourpath + ourpath, texconfig.formatname = lua.startupfile:match('(.*[/\\])([^/\\]*)%-init%.lua$') kpse = assert(package.loadlib(ourpath .. 'kpse.' .. (os.type == 'windows' and 'dll' or 'so'), 'luaopen_kpse'))() end -local interaction do - local arg0, progname + local arg_pattern = '-' * lpeg.P'-'^-1 * lpeg.C((1-lpeg.P'=')^1) * ('=' * lpeg.C(lpeg.P(1)^0) + lpeg.Cc(true)) for _, a in ipairs(arg) do - if a:sub(1,11) == "--progname=" then - progname = a:sub(12) - elseif a:sub(1,7) == "--arg0=" then - arg0 = a:sub(8) - elseif a:match'^%-%-?interaction=' then - local interaction_name = a:sub(a:find'='+1) - interaction = ({ - batchmode=0, - nonstopmode=1, - scrollmode=2, - errorstopmode=3, - })[interaction_name] - if not interaction then - texio.write('term', string.format('Unknown interaction mode %q ignored.\n', interaction_name)) - end + local name, value = arg_pattern:match(a) + if name then + arg[name] = value end end - os.arg0 = arg0 - kpse.set_program_name(arg0, progname) end +kpse.set_program_name(arg.arg0 or arg[arg[0]], arg.progname) package.searchers[2] = function(modname) local filename = kpse.find_file(modname, "lua", true) if not filename then @@ -59,8 +46,16 @@ end callback_register('find_format_file', function(name) return kpse.find_file(name, 'fmt', true) end) function texconfig.init() + local interaction = ({ [true] = 3, [false] = false, + batchmode=0, + nonstopmode=1, + scrollmode=2, + errorstopmode=3, + })[arg.interaction or false] if interaction then tex.setinteraction(interaction) + elseif interaction == nil then + texio.write('term', string.format('Unknown interaction mode %q ignored.\n', arg.interaction)) end if build_bytecode then -- Effectivly if status.ini_version require'luametalatex-lateinit'(build_bytecode) diff --git a/luametalatex.lua b/luametalatex.lua index 55b8895..2985d5d 100644 --- a/luametalatex.lua +++ b/luametalatex.lua @@ -75,8 +75,6 @@ for i, a in ipairs(os.selfarg) do os.selfarg[i] = a if a:sub(1, 11) == "--progname=" then format = a:sub(12) - elseif a == '--ini' then - is_initex = true end end local dir = absdir(os.selfdir) @@ -106,17 +104,6 @@ for i = #dirseparators, 1, -1 do end error[[CRITICAL: Initialization script not found]] ::FOUND:: --- table.insert(arg, 1, "--lua=" .. dir) --- table.insert(arg, 1, "luametatex") --- arg[0] = nil --- local _, msg = os.exec(arg) --- error(msg) os.setenv("engine", status.luatex_engine) -local ret_value local args = os.selfarg[1] and " \"" .. table.concat(os.selfarg, "\" \"") .. "\"" or "" -if is_initex then - ret_value = os.execute(string.format("luametatex \"--lua=%s\" --arg0=\"%s\"%s", dir, os.selfarg[0], args)) -else - ret_value = os.execute(string.format("luametatex \"--fmt=%s\" \"--lua=%s\" --arg0=\"%s\"%s", format, dir, os.selfarg[0], args)) -end -os.exit(x) +os.exit(os.execute(string.format("luametatex \"--lua=%s\" --arg0=\"%s\"%s", dir, os.selfarg[0], args)))