diff options
author | Karl Berry <karl@freefriends.org> | 2012-06-01 00:12:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-06-01 00:12:08 +0000 |
commit | fcf2244919c5f0d95df1061c6678448c5cc83bbc (patch) | |
tree | fad2df3dcf0d98501086e1a6c3d1ea5e4e80a052 /Master/bin/universal-darwin | |
parent | 73ae8b5defdefc96fbed12dfdd3591725ef268c1 (diff) |
sync from Master/texmf-dist/scripts/context/lua/mtxrun.lua
git-svn-id: svn://tug.org/texlive/trunk@26754 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/bin/universal-darwin')
-rwxr-xr-x | Master/bin/universal-darwin/mtxrun | 163 |
1 files changed, 131 insertions, 32 deletions
diff --git a/Master/bin/universal-darwin/mtxrun b/Master/bin/universal-darwin/mtxrun index e1783761afa..d2f7e408f0d 100755 --- a/Master/bin/universal-darwin/mtxrun +++ b/Master/bin/universal-darwin/mtxrun @@ -1126,8 +1126,39 @@ local lpeg = require("lpeg") local report = texio and texio.write_nl or print - - +-- local lpmatch = lpeg.match +-- local lpprint = lpeg.print +-- local lpp = lpeg.P +-- local lpr = lpeg.R +-- local lps = lpeg.S +-- local lpc = lpeg.C +-- local lpb = lpeg.B +-- local lpv = lpeg.V +-- local lpcf = lpeg.Cf +-- local lpcb = lpeg.Cb +-- local lpcg = lpeg.Cg +-- local lpct = lpeg.Ct +-- local lpcs = lpeg.Cs +-- local lpcc = lpeg.Cc +-- local lpcmt = lpeg.Cmt +-- local lpcarg = lpeg.Carg + +-- function lpeg.match(l,...) report("LPEG MATCH") lpprint(l) return lpmatch(l,...) end + +-- function lpeg.P (l) local p = lpp (l) report("LPEG P =") lpprint(l) return p end +-- function lpeg.R (l) local p = lpr (l) report("LPEG R =") lpprint(l) return p end +-- function lpeg.S (l) local p = lps (l) report("LPEG S =") lpprint(l) return p end +-- function lpeg.C (l) local p = lpc (l) report("LPEG C =") lpprint(l) return p end +-- function lpeg.B (l) local p = lpb (l) report("LPEG B =") lpprint(l) return p end +-- function lpeg.V (l) local p = lpv (l) report("LPEG V =") lpprint(l) return p end +-- function lpeg.Cf (l) local p = lpcf (l) report("LPEG Cf =") lpprint(l) return p end +-- function lpeg.Cb (l) local p = lpcb (l) report("LPEG Cb =") lpprint(l) return p end +-- function lpeg.Cg (l) local p = lpcg (l) report("LPEG Cg =") lpprint(l) return p end +-- function lpeg.Ct (l) local p = lpct (l) report("LPEG Ct =") lpprint(l) return p end +-- function lpeg.Cs (l) local p = lpcs (l) report("LPEG Cs =") lpprint(l) return p end +-- function lpeg.Cc (l) local p = lpcc (l) report("LPEG Cc =") lpprint(l) return p end +-- function lpeg.Cmt (l) local p = lpcmt (l) report("LPEG Cmt =") lpprint(l) return p end +-- function lpeg.Carg (l) local p = lpcarg(l) report("LPEG Carg =") lpprint(l) return p end local type = type local byte, char, gmatch = string.byte, string.char, string.gmatch @@ -2696,8 +2727,12 @@ local function basename(name) return match(name,"^.+[/\\](.-)$") or name end +-- local function nameonly(name) +-- return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$","")) +-- end + local function nameonly(name) - return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$","")) + return (gsub(match(name,"^.+[/\\](.-)$") or name,"%.[%a%d]+$","")) end local function extname(name,default) @@ -10749,6 +10784,17 @@ local resolvers = resolvers texconfig.kpse_init = false texconfig.shell_escape = 't' +if kpse and kpse.default_texmfcnf then + local default_texmfcnf = kpse.default_texmfcnf() + -- looks more like context: + default_texmfcnf = gsub(default_texmfcnf,"$SELFAUTOLOC","selfautoloc:") + default_texmfcnf = gsub(default_texmfcnf,"$SELFAUTODIR","selfautodir:") + default_texmfcnf = gsub(default_texmfcnf,"$SELFAUTOPARENT","selfautoparent:") + default_texmfcnf = gsub(default_texmfcnf,"$HOME","home:") + -- + environment.default_texmfcnf = default_texmfcnf +end + kpse = { original = kpse } setmetatable(kpse, { @@ -10993,10 +11039,27 @@ local function f_second(a,b) return concat(t,",") end +-- kpsewhich --expand-braces '{a,b}{c,d}' +-- ac:bc:ad:bd + +-- old {a,b}{c,d} => ac ad bc bd +-- +-- local function f_both(a,b) +-- local t, n = { }, 0 +-- for sa in gmatch(a,"[^,]+") do +-- for sb in gmatch(b,"[^,]+") do +-- n = n + 1 ; t[n] = sa .. sb +-- end +-- end +-- return concat(t,",") +-- end +-- +-- new {a,b}{c,d} => ac bc ad bd + local function f_both(a,b) local t, n = { }, 0 - for sa in gmatch(a,"[^,]+") do - for sb in gmatch(b,"[^,]+") do + for sb in gmatch(b,"[^,]+") do -- and not sa + for sa in gmatch(a,"[^,]+") do -- sb n = n + 1 ; t[n] = sa .. sb end end @@ -11024,11 +11087,24 @@ local function splitpathexpr(str, newlist, validate) -- I couldn't resist lpeggi local t, ok, done = newlist or { }, false, false local n = #t str = lpegmatch(replacer_1,str) - repeat local old = str - repeat local old = str ; str = lpegmatch(l_first, str) until old == str - repeat local old = str ; str = lpegmatch(l_second,str) until old == str - repeat local old = str ; str = lpegmatch(l_both, str) until old == str - repeat local old = str ; str = lpegmatch(l_rest, str) until old == str + repeat + local old = str + repeat + local old = str + str = lpegmatch(l_first, str) + until old == str + repeat + local old = str + str = lpegmatch(l_second,str) + until old == str + repeat + local old = str + str = lpegmatch(l_both, str) + until old == str + repeat + local old = str + str = lpegmatch(l_rest, str) + until old == str until old == str -- or not find(str,"{") str = lpegmatch(stripper_1,str) if validate then @@ -11131,7 +11207,7 @@ local stripper = Cs( ) function resolvers.checkedvariable(str) -- assumes str is a string - return lpegmatch(stripper,str) or str + return type(str) == "string" and lpegmatch(stripper,str) or str end -- The path splitter: @@ -12271,7 +12347,7 @@ resolvers.luacnfstate = "unknown" -- resolvers.luacnfspec = 'selfautoparent:{/texmf{-local,}{,/web2c}}' -- -- which does not make texlive happy as there is a texmf-local tree one level up --- (sigh), so we need this. (We can assume web2c as mkiv does not run on older +-- (sigh), so we need this. We can assume web2c as mkiv does not run on older -- texlives anyway. -- -- texlive: @@ -12294,16 +12370,16 @@ resolvers.luacnfstate = "unknown" -- selfautoparent:texmf-context/web2c -- selfautoparent:texmf/web2c -this_is_texlive = true -if this_is_texlive then - -- resolvers.luacnfspec = '{selfautodir:,selfautoparent:}{,{/share,}/texmf{-local,}/web2c}' - -- resolvers.luacnfspec = '{selfautodir:{/share,}/texmf-local/web2c,selfautoparent:{/share,}/texmf{-local,}/web2c}' - -- resolvers.luacnfspec = 'selfautodir:/texmf-local/web2c;selfautoparent:/texmf{-local,}/web2c' - resolvers.luacnfspec = 'selfautodir:;selfautoparent:;{selfautodir:,selfautoparent:}{/share,}/texmf{-local,}/web2c' +if environment.default_texmfcnf then + -- unfortunately we now have quite some overkill in the spec (not so nice on a network) + resolvers.luacnfspec = environment.default_texmfcnf else - resolvers.luacnfspec = 'home:texmf/web2c;selfautoparent:texmf{-local,-context,}/web2c' + -- resolvers.luacnfspec = "selfautoparent:texmf{-local,-context,}/web2c" + resolvers.luacnfspec = "{selfautoloc:,selfautodir:,selfautoparent:}{,/texmf{-local,}/web2c}" end +resolvers.luacnfspec = 'home:texmf/web2c;' .. resolvers.luacnfspec + -- which (as we want users to use the web2c path) be can be simplified to this: -- -- if environment and environment.ownpath and string.find(environment.ownpath,"[\\/]texlive[\\/]") then @@ -12637,7 +12713,7 @@ local function load_configuration_files() instance.loaderror = true end elseif trace_locating then - report_resolving("skipping configuration file '%s' (no file)",filename) + report_resolving("skipping configuration file '%s' (no valid format)",filename) end instance.order[#instance.order+1] = instance.setups[pathname] if instance.loaderror then @@ -13002,7 +13078,10 @@ function resolvers.expandpathfromvariable(str) end function resolvers.expandbraces(str) -- output variable and brace expansion of STRING - local ori = resolvers.variable(str) +-- local ori = resolvers.variable(str) +-- if ori == "" then + local ori = str +-- end local pth = expandedpathfromlist(resolvers.splitpath(ori)) return joinpath(pth) end @@ -13992,13 +14071,21 @@ function resolvers.resetresolve(str) end local function resolve(str) -- use schemes, this one is then for the commandline only - local res = resolved[str] - if not res then - res = gsub(str,"([a-z][a-z]+):([^ \"\';]*)",_resolve_) -- home:xx;selfautoparent:xx; etc - resolved[str] = res - abstract[res] = str + if type(str) == "table" then + local t = { } + for i=1,#str do + t[i] = resolve(str[i]) + end + return t + else + local res = resolved[str] + if not res then + res = gsub(str,"([a-z][a-z]+):([^ \"\';,]*)",_resolve_) -- home:xx;selfautoparent:xx; etc (comma added) + resolved[str] = res + abstract[res] = str + end + return res end - return res end local function unresolve(str) @@ -14687,16 +14774,17 @@ function resolvers.usezipfile(archive) if archive and not registeredfiles[archive] then local z = zip.openarchive(archive) if z then + local instance = resolvers.instance local tree = url.query(specification.query).tree or "" if trace_locating then report_zip("registering, registering archive '%s'",archive) end - statistics.starttiming(resolvers.instance) + statistics.starttiming(instance) resolvers.prependhash('zip',archive) resolvers.extendtexmfvariable(archive) -- resets hashes too registeredfiles[archive] = z instance.files[archive] = resolvers.registerzipfile(z,tree) - statistics.stoptiming(resolvers.instance) + statistics.stoptiming(instance) elseif trace_locating then report_zip("registering, unknown archive '%s'",archive) end @@ -15187,6 +15275,7 @@ function resolvers.load_tree(tree,resolve) -- local AUTOPARENT etc. although these are alwasy set new. if resolve then + -- resolvers.luacnfspec = resolvers.joinpath(resolvers.resolve(resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec)))) resolvers.luacnfspec = resolvers.resolve(resolvers.luacnfspec) end @@ -15262,7 +15351,7 @@ function resolvers.listers.variables(pattern) report_lists(" env: %s",tabstr(rawget(environment,key)) or "unset") report_lists(" var: %s",tabstr(configured[key]) or "unset") report_lists(" exp: %s",tabstr(expansions[key]) or "unset") - report_lists(" res: %s",resolvers.resolve(expansions[key]) or "unset") + report_lists(" res: %s",tabstr(resolvers.resolve(expansions[key])) or "unset") end end instance.environment = fastcopy(env) @@ -15274,7 +15363,17 @@ function resolvers.listers.configurations(report) local configurations = resolvers.instance.specification local report = report or texio.write_nl for i=1,#configurations do - report(resolvers.resolve(configurations[i])) + report(format("file : %s",resolvers.resolve(configurations[i]))) + end + report("") + local list = resolvers.expandedpathfromlist(resolvers.splitpath(resolvers.luacnfspec)) + for i=1,#list do + local li = resolvers.resolve(list[i]) + if lfs.isdir(li) then + report(format("path - %s",li)) + else + report(format("path + %s",li)) + end end end @@ -16616,7 +16715,7 @@ elseif e_argument("find-path") then elseif e_argument("expand-braces") then - -- luatools: runners.execute_ctx_script("mtx-base","--expand-braces",filename) + -- luatools: runners.execute_ctx_script("mtx-base","--expand-braces",filename resolvers.load("nofiles") runners.register_arguments(filename) |