summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-context.lua62
-rw-r--r--scripts/context/lua/mtxrun.lua14
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua14
-rwxr-xr-xscripts/context/stubs/unix/mtxrun14
4 files changed, 65 insertions, 39 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index 49d7135b0..2ca3253d0 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -287,32 +287,38 @@ end
local pattern = lpegpatterns.utfbom^-1 * (P("%% ") + P("% ")) * Cs((1-lpegpatterns.newline)^1)
+local prefile = nil
+local predata = nil
+
local function preamble_analyze(filename) -- only files on current path
- local t = { }
- local line = io.loadlines(fileaddsuffix(filename,"tex"))
+ filename = fileaddsuffix(filename,"tex") -- to be sure
+ if predata and prefile == filename then
+ return predata
+ end
+ prefile = filename
+ predata = { }
+ local line = io.loadlines(prefile)
if line then
local preamble = lpegmatch(pattern,line)
if preamble then
- for key, value in gmatch(preamble,"(%S+)%s*=%s*(%S+)") do
- t[key] = value
- end
- t.type = "tex"
+ utilities.parsers.options_to_hash(preamble,predata)
+ predata.type = "tex"
elseif find(line,"^<?xml ") then
- t.type = "xml"
+ predata.type = "xml"
end
- if t.nofruns then
- multipass_nofruns = t.nofruns
+ if predata.nofruns then
+ multipass_nofruns = predata.nofruns
end
- if not t.engine then
- t.engine = environment.basicengines[engine_old] --'luatex'
+ if not predata.engine then
+ predata.engine = environment.basicengines[engine_old] --'luatex'
end
- if t.engine ~= engine_old then -- hack
- if environment.validengines[t.engine] and t.engine ~= environment.basicengines[engine_old] then
- restart(engine_old,t.engine)
+ if predata.engine ~= engine_old then -- hack
+ if environment.validengines[predata.engine] and predata.engine ~= environment.basicengines[engine_old] then
+ restart(engine_old,predata.engine)
end
end
end
- return t
+ return predata
end
-- automatically opening and closing pdf files
@@ -890,24 +896,26 @@ function scripts.context.ctx()
end
function scripts.context.autoctx()
- local ctxdata = nil
- local files = environment.files
+ local ctxdata = nil
+ local files = environment.files
local firstfile = #files > 0 and files[1]
if firstfile then
- local suffix = filesuffix(firstfile)
+ local suffix = filesuffix(firstfile)
+ local ctxname = nil
if suffix == "xml" then
local chunk = io.loadchunk(firstfile) -- 1024
if chunk then
- local ctxname = match(chunk,"<%?context%-directive%s+job%s+ctxfile%s+([^ ]-)%s*?>")
- if ctxname then
- ctxdata = ctxrunner.new()
- ctxdata.jobname = firstfile
- ctxrunner.checkfile(ctxdata,ctxname)
- ctxrunner.checkflags(ctxdata)
- end
+ ctxname = match(chunk,"<%?context%-directive%s+job%s+ctxfile%s+([^ ]-)%s*?>")
end
- elseif suffix == "tex" then
- -- maybe but we scan the preamble later too
+ elseif suffix == "tex" or suffix == "mkiv" then
+ local analysis = preamble_analyze(firstfile)
+ ctxname = analysis.ctxfile or analysis.ctx
+ end
+ if ctxname then
+ ctxdata = ctxrunner.new()
+ ctxdata.jobname = firstfile
+ ctxrunner.checkfile(ctxdata,ctxname)
+ ctxrunner.checkflags(ctxdata)
end
end
scripts.context.run(ctxdata)
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index c5614aed3..791f25d09 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -5884,7 +5884,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 18179, stripped down to: 13032
+-- original size: 18558, stripped down to: 13323
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -6102,6 +6102,12 @@ function parsers.simple_hash_to_string(h,separator)
end
return concat(t,separator or ",")
end
+local str=C((1-whitespace-equal)^1)
+local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset)
+local splitter=setting^1
+function utilities.parsers.options_to_hash(str,target)
+ return str and lpegmatch(splitter,str,1,target or {}) or {}
+end
local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C(digit^1*lparent*(noparent+nestedparents)^1*rparent)+C((nestedbraces+(1-comma))^1)
local pattern_a=spaces*Ct(value*(separator*value)^0)
local function repeater(n,str)
@@ -6314,7 +6320,7 @@ end
local function fetch(t,name)
return t[name] or {}
end
-function process(result,more)
+local function process(result,more)
for k,v in next,more do
result[k]=v
end
@@ -16376,8 +16382,8 @@ end -- of closure
-- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 668980
--- stripped bytes : 235300
+-- original bytes : 669359
+-- stripped bytes : 235388
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index c5614aed3..791f25d09 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -5884,7 +5884,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 18179, stripped down to: 13032
+-- original size: 18558, stripped down to: 13323
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -6102,6 +6102,12 @@ function parsers.simple_hash_to_string(h,separator)
end
return concat(t,separator or ",")
end
+local str=C((1-whitespace-equal)^1)
+local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset)
+local splitter=setting^1
+function utilities.parsers.options_to_hash(str,target)
+ return str and lpegmatch(splitter,str,1,target or {}) or {}
+end
local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C(digit^1*lparent*(noparent+nestedparents)^1*rparent)+C((nestedbraces+(1-comma))^1)
local pattern_a=spaces*Ct(value*(separator*value)^0)
local function repeater(n,str)
@@ -6314,7 +6320,7 @@ end
local function fetch(t,name)
return t[name] or {}
end
-function process(result,more)
+local function process(result,more)
for k,v in next,more do
result[k]=v
end
@@ -16376,8 +16382,8 @@ end -- of closure
-- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 668980
--- stripped bytes : 235300
+-- original bytes : 669359
+-- stripped bytes : 235388
-- end library merge
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index c5614aed3..791f25d09 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -5884,7 +5884,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 18179, stripped down to: 13032
+-- original size: 18558, stripped down to: 13323
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -6102,6 +6102,12 @@ function parsers.simple_hash_to_string(h,separator)
end
return concat(t,separator or ",")
end
+local str=C((1-whitespace-equal)^1)
+local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset)
+local splitter=setting^1
+function utilities.parsers.options_to_hash(str,target)
+ return str and lpegmatch(splitter,str,1,target or {}) or {}
+end
local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C(digit^1*lparent*(noparent+nestedparents)^1*rparent)+C((nestedbraces+(1-comma))^1)
local pattern_a=spaces*Ct(value*(separator*value)^0)
local function repeater(n,str)
@@ -6314,7 +6320,7 @@ end
local function fetch(t,name)
return t[name] or {}
end
-function process(result,more)
+local function process(result,more)
for k,v in next,more do
result[k]=v
end
@@ -16376,8 +16382,8 @@ end -- of closure
-- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 668980
--- stripped bytes : 235300
+-- original bytes : 669359
+-- stripped bytes : 235388
-- end library merge