From 527274eadad499558bb40b794882661970c5cc67 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 26 Nov 2009 16:28:00 +0100 Subject: stable 2009.11.26 16:28 --- scripts/context/lua/mtx-context.lua | 34 ++++++++++-------- scripts/context/lua/mtx-update.lua | 16 +++++---- scripts/context/lua/mtxrun.lua | 63 ++++++++++++++++++++++++++-------- scripts/context/stubs/mswin/mtxrun.lua | 63 ++++++++++++++++++++++++++-------- scripts/context/stubs/unix/mtxrun | 63 ++++++++++++++++++++++++++-------- 5 files changed, 177 insertions(+), 62 deletions(-) (limited to 'scripts') diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 22abf74b1..b146b3c09 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -465,10 +465,11 @@ function scripts.context.multipass.makeoptionfile(jobname,ctxdata,kindofrun,curr -- setalways("%% process info") -- - setalways( "\\setupsystem[\\c!n=%s,\\c!m=%s]", kindofrun or 0, currentrun or 0) - setalways( "\\setupsystem[\\c!type=%s]",os.platform) - setvalue ("inputfile" , "\\setupsystem[inputfile=%s]") + -- setvalue ("inputfile" , "\\setupsystem[inputfile=%s]") + setalways( "\\setupsystem[inputfile=%s]",environment.argument("input") or environment.files[1] or "\\jobname") setvalue ("result" , "\\setupsystem[file=%s]") + setalways( "\\setupsystem[\\c!n=%s,\\c!m=%s]", kindofrun or 0, currentrun or 0) + -- setalways( "\\setupsystem[\\c!type=%s]",os.platform) setvalues("path" , "\\usepath[%s]") setvalue ("setuppath" , "\\setupsystem[\\c!directory={%s}]") setvalue ("randomseed" , "\\setupsystem[\\c!random=%s]") @@ -621,21 +622,26 @@ local function makestub(format,filename,prepname) return filename end -function scripts.context.openpdf(name) - os.spawn(string.format('pdfopen --file "%s" 2>&1', file.replacesuffix(name,"pdf"))) -end -function scripts.context.closepdf(name) - os.spawn(string.format('pdfclose --file "%s" 2>&1', file.replacesuffix(name,"pdf"))) -end - --~ function scripts.context.openpdf(name) ---~ -- somehow two instances start up, one with a funny filename ---~ os.spawn(string.format("\"c:/program files/kde/bin/okular.exe\" --unique %s",file.replacesuffix(name,"pdf"))) +--~ os.spawn(string.format('pdfopen --file "%s" 2>&1', file.replacesuffix(name,"pdf"))) --~ end --~ function scripts.context.closepdf(name) ---~ -- +--~ os.spawn(string.format('pdfclose --file "%s" 2>&1', file.replacesuffix(name,"pdf"))) --~ end +local pdfview -- delayed loading + +function scripts.context.openpdf(name) + pdfview = pdfview or dofile(resolvers.find_file("l-pdfview.lua","tex")) + logs.simple("pdfview methods: %s, current method: %s, MTX_PDFVIEW_METHOD=%s",pdfview.methods(),pdfview.method,os.getenv(pdfview.METHOD) or "") + pdfview.open(file.replacesuffix(name,"pdf")) +end + +function scripts.context.closepdf(name) + pdfview = pdfview or dofile(resolvers.find_file("l-pdfview.lua","tex")) + pdfview.close(file.replacesuffix(name,"pdf")) +end + function scripts.context.run(ctxdata,filename) -- filename overloads environment.files local files = (filename and { filename }) or environment.files @@ -1411,7 +1417,7 @@ messages.help = [[ -- output is currently obsolete for mkiv -- setuppath=list must check -- modefile=name must check --- inputfile=name load the given inputfile (must check) +-- input=name load the given inputfile (must check) messages.expert = [[ expert options: diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua index ed2606576..3dd2f0e47 100644 --- a/scripts/context/lua/mtx-update.lua +++ b/scripts/context/lua/mtx-update.lua @@ -146,9 +146,9 @@ scripts.update.platforms = { scripts.update.modules = { } -function scripts.update.run(str) +function scripts.update.run(str,force) logs.report("run", str) - if environment.argument("force") then + if force or environment.argument("force") then -- important, otherwise formats fly to a weird place -- (texlua sets luatex as the engine, we need to reset that or to fix texexec :) os.setenv("engine",nil) @@ -337,13 +337,17 @@ function scripts.update.synchronize() -- command = format("%s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, url, archives, destination) -- end local normalflags, deleteflags = states.get("rsync.flags.normal"), "" + local dryrunflags = "" + if not environment.argument("force") then + dryrunflags = "--dry-run" + end if (destination:find("texmf$") or destination:find("texmf%-context$")) and (not environment.argument("keep")) then deleteflags = states.get("rsync.flags.delete") end - command = format("%s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, url, archives, destination) - logs.report("mtx update", format("running command: %s",command)) + command = format("%s %s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, dryrunflags, url, archives, destination) + --logs.report("mtx update", format("running command: %s",command)) if not fetched[command] then - scripts.update.run(command) + scripts.update.run(command,true) fetched[command] = command end end @@ -479,7 +483,7 @@ if scripts.savestate then states.set("rsync.program", environment.argument("rsync"), "rsync", true) -- ok states.set("rsync.server", environment.argument("server"), "contextgarden.net::", true) -- ok states.set("rsync.module", environment.argument("module"), "minimals", true) -- ok - states.set("rsync.flags.normal", environment.argument("flags"), "-rpztlv --stats", true) -- ok + states.set("rsync.flags.normal", environment.argument("flags"), "-rpztlv", true) -- ok states.set("rsync.flags.delete", nil, "--delete", true) -- ok states.set("paths.root", environment.argument("texroot"), "tex", true) -- ok diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 6425d7060..a187f0697 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -1890,8 +1890,8 @@ function file.nameonly(name) return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$","")) end -function file.extname(name) - return match(name,"^.+%.([^/\\]-)$") or "" +function file.extname(name,default) + return match(name,"^.+%.([^/\\]-)$") or default or "" end file.suffix = file.extname @@ -6081,7 +6081,7 @@ local xmlfilter = xml.filter -- we could inline this one for speed local xmltostring = xml.tostring local xmlserialize = xml.serialize -local function first(collected) +local function first(collected) -- wrong ? return collected and collected[1] end @@ -6122,8 +6122,10 @@ local function position(collected,n) n = tonumber(n) or 0 if n < 0 then return collected[#collected + n + 1] - else + elseif n > 0 then return collected[n] + else + return collected[1].mi -- match end end end @@ -6489,7 +6491,7 @@ end if arg then - -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later) + -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later) local newarg, instring = { }, false for index, argument in ipairs(arg) do @@ -6809,6 +6811,9 @@ if not modules then modules = { } end modules ['luat-log'] = { -- this is old code that needs an overhaul +--~ io.stdout:setvbuf("no") +--~ io.stderr:setvbuf("no") + local write_nl, write, format = texio.write_nl or print, texio.write or io.write, string.format local texcount = tex and tex.count @@ -6890,27 +6895,49 @@ function logs.tex.line(fmt,...) -- new end end +--~ function logs.tex.start_page_number() +--~ local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno +--~ if real > 0 then +--~ if user > 0 then +--~ if sub > 0 then +--~ write(format("[%s.%s.%s",real,user,sub)) +--~ else +--~ write(format("[%s.%s",real,user)) +--~ end +--~ else +--~ write(format("[%s",real)) +--~ end +--~ else +--~ write("[-") +--~ end +--~ end + +--~ function logs.tex.stop_page_number() +--~ write("]") +--~ end + +local real, user, sub + function logs.tex.start_page_number() - local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno + real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno +end + +function logs.tex.stop_page_number() if real > 0 then if user > 0 then if sub > 0 then - write(format("[%s.%s.%s",real,user,sub)) + logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub) else - write(format("[%s.%s",real,user)) + logs.report("pages", "flushing page, realpage %s, userpage %s",real,user) end else - write(format("[%s",real)) + logs.report("pages", "flushing page, realpage %s",real) end else - write("[-") + logs.report("pages", "flushing page") end end -function logs.tex.stop_page_number() - write("]") -end - logs.tex.report_job_stat = statistics.show_job_stat -- xml logging @@ -9393,6 +9420,14 @@ prefixes.relative = function(str,n) return resolvers.clean_path(str) end +prefixes.auto = function(str) + local fullname = prefixes.relative(str) + if not lfs.isfile(fullname) then + fullname = prefixes.locate(str) + end + return fullname +end + prefixes.locate = function(str) local fullname = resolvers.find_given_file(str) or "" return resolvers.clean_path((fullname ~= "" and fullname) or str) diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 6425d7060..a187f0697 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -1890,8 +1890,8 @@ function file.nameonly(name) return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$","")) end -function file.extname(name) - return match(name,"^.+%.([^/\\]-)$") or "" +function file.extname(name,default) + return match(name,"^.+%.([^/\\]-)$") or default or "" end file.suffix = file.extname @@ -6081,7 +6081,7 @@ local xmlfilter = xml.filter -- we could inline this one for speed local xmltostring = xml.tostring local xmlserialize = xml.serialize -local function first(collected) +local function first(collected) -- wrong ? return collected and collected[1] end @@ -6122,8 +6122,10 @@ local function position(collected,n) n = tonumber(n) or 0 if n < 0 then return collected[#collected + n + 1] - else + elseif n > 0 then return collected[n] + else + return collected[1].mi -- match end end end @@ -6489,7 +6491,7 @@ end if arg then - -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later) + -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later) local newarg, instring = { }, false for index, argument in ipairs(arg) do @@ -6809,6 +6811,9 @@ if not modules then modules = { } end modules ['luat-log'] = { -- this is old code that needs an overhaul +--~ io.stdout:setvbuf("no") +--~ io.stderr:setvbuf("no") + local write_nl, write, format = texio.write_nl or print, texio.write or io.write, string.format local texcount = tex and tex.count @@ -6890,27 +6895,49 @@ function logs.tex.line(fmt,...) -- new end end +--~ function logs.tex.start_page_number() +--~ local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno +--~ if real > 0 then +--~ if user > 0 then +--~ if sub > 0 then +--~ write(format("[%s.%s.%s",real,user,sub)) +--~ else +--~ write(format("[%s.%s",real,user)) +--~ end +--~ else +--~ write(format("[%s",real)) +--~ end +--~ else +--~ write("[-") +--~ end +--~ end + +--~ function logs.tex.stop_page_number() +--~ write("]") +--~ end + +local real, user, sub + function logs.tex.start_page_number() - local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno + real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno +end + +function logs.tex.stop_page_number() if real > 0 then if user > 0 then if sub > 0 then - write(format("[%s.%s.%s",real,user,sub)) + logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub) else - write(format("[%s.%s",real,user)) + logs.report("pages", "flushing page, realpage %s, userpage %s",real,user) end else - write(format("[%s",real)) + logs.report("pages", "flushing page, realpage %s",real) end else - write("[-") + logs.report("pages", "flushing page") end end -function logs.tex.stop_page_number() - write("]") -end - logs.tex.report_job_stat = statistics.show_job_stat -- xml logging @@ -9393,6 +9420,14 @@ prefixes.relative = function(str,n) return resolvers.clean_path(str) end +prefixes.auto = function(str) + local fullname = prefixes.relative(str) + if not lfs.isfile(fullname) then + fullname = prefixes.locate(str) + end + return fullname +end + prefixes.locate = function(str) local fullname = resolvers.find_given_file(str) or "" return resolvers.clean_path((fullname ~= "" and fullname) or str) diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 6425d7060..a187f0697 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -1890,8 +1890,8 @@ function file.nameonly(name) return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$","")) end -function file.extname(name) - return match(name,"^.+%.([^/\\]-)$") or "" +function file.extname(name,default) + return match(name,"^.+%.([^/\\]-)$") or default or "" end file.suffix = file.extname @@ -6081,7 +6081,7 @@ local xmlfilter = xml.filter -- we could inline this one for speed local xmltostring = xml.tostring local xmlserialize = xml.serialize -local function first(collected) +local function first(collected) -- wrong ? return collected and collected[1] end @@ -6122,8 +6122,10 @@ local function position(collected,n) n = tonumber(n) or 0 if n < 0 then return collected[#collected + n + 1] - else + elseif n > 0 then return collected[n] + else + return collected[1].mi -- match end end end @@ -6489,7 +6491,7 @@ end if arg then - -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later) + -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later) local newarg, instring = { }, false for index, argument in ipairs(arg) do @@ -6809,6 +6811,9 @@ if not modules then modules = { } end modules ['luat-log'] = { -- this is old code that needs an overhaul +--~ io.stdout:setvbuf("no") +--~ io.stderr:setvbuf("no") + local write_nl, write, format = texio.write_nl or print, texio.write or io.write, string.format local texcount = tex and tex.count @@ -6890,27 +6895,49 @@ function logs.tex.line(fmt,...) -- new end end +--~ function logs.tex.start_page_number() +--~ local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno +--~ if real > 0 then +--~ if user > 0 then +--~ if sub > 0 then +--~ write(format("[%s.%s.%s",real,user,sub)) +--~ else +--~ write(format("[%s.%s",real,user)) +--~ end +--~ else +--~ write(format("[%s",real)) +--~ end +--~ else +--~ write("[-") +--~ end +--~ end + +--~ function logs.tex.stop_page_number() +--~ write("]") +--~ end + +local real, user, sub + function logs.tex.start_page_number() - local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno + real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno +end + +function logs.tex.stop_page_number() if real > 0 then if user > 0 then if sub > 0 then - write(format("[%s.%s.%s",real,user,sub)) + logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub) else - write(format("[%s.%s",real,user)) + logs.report("pages", "flushing page, realpage %s, userpage %s",real,user) end else - write(format("[%s",real)) + logs.report("pages", "flushing page, realpage %s",real) end else - write("[-") + logs.report("pages", "flushing page") end end -function logs.tex.stop_page_number() - write("]") -end - logs.tex.report_job_stat = statistics.show_job_stat -- xml logging @@ -9393,6 +9420,14 @@ prefixes.relative = function(str,n) return resolvers.clean_path(str) end +prefixes.auto = function(str) + local fullname = prefixes.relative(str) + if not lfs.isfile(fullname) then + fullname = prefixes.locate(str) + end + return fullname +end + prefixes.locate = function(str) local fullname = resolvers.find_given_file(str) or "" return resolvers.clean_path((fullname ~= "" and fullname) or str) -- cgit v1.2.3