diff options
-rw-r--r-- | scripts/context/lua/mtx-watch.lua | 67 | ||||
-rw-r--r-- | tex/context/base/colo-ini.mkiv | 6 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context-base.lmx | 4 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/l-io.lua | 2 | ||||
-rw-r--r-- | tex/context/base/l-os.lua | 37 | ||||
-rw-r--r-- | tex/context/base/lpdf-ini.lua | 8 | ||||
-rw-r--r-- | tex/context/base/lpdf-xmp.lua | 19 | ||||
-rw-r--r-- | tex/context/base/lxml-tab.lua | 8 | ||||
-rw-r--r-- | tex/context/base/mlib-run.lua | 2 | ||||
-rw-r--r-- | tex/context/base/node-rul.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/strc-itm.mkiv | 2 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 4 |
14 files changed, 100 insertions, 65 deletions
diff --git a/scripts/context/lua/mtx-watch.lua b/scripts/context/lua/mtx-watch.lua index 9cfe2bbfd..15e0f81e9 100644 --- a/scripts/context/lua/mtx-watch.lua +++ b/scripts/context/lua/mtx-watch.lua @@ -9,27 +9,31 @@ if not modules then modules = { } end modules ['mtx-watch'] = { scripts = scripts or { } scripts.watch = scripts.watch or { } +local format, concat, time, difftime = string.format, table.concat, os.difftime +local pairs, ipairs, next, type = pairs, ipairs, next, type + function scripts.watch.save_exa_modes(joblog,ctmname) - local t= { } if joblog then + local t= { } t[#t+1] = "<?xml version='1.0' standalone='yes'?>\n" t[#t+1] = "<exa:variables xmlns:exa='htpp://www.pragma-ade.com/schemas/exa-variables.rng'>" if joblog.values then for k, v in pairs(joblog.values) do - t[#t+1] = string.format("\t<exa:variable label='%s'>%s</exa:variable>", k, tostring(v)) + t[#t+1] = format("\t<exa:variable label='%s'>%s</exa:variable>", k, tostring(v)) end else t[#t+1] = "<!-- no modes -->" end t[#t+1] = "</exa:variables>" + io.savedata(ctmname,concat(t,"\n")) + else + os.remove(ctmname) end - os.remove(ctmname) - io.savedata(ctmname,table.concat(t,"\n")) end local function toset(t) if type(t) == "table" then - return table.concat(t,",") + return concat(t,",") else return t end @@ -67,10 +71,13 @@ local function glob(files,path) end end +local clock = os.gettimeofday or os.time -- we cannot trust os.clock on linux + function scripts.watch.watch() local delay = environment.argument("delay") or 5 local logpath = environment.argument("logpath") or "" local pipe = environment.argument("pipe") or false + local watcher = "mtxwatch.run" if #environment.files > 0 then for _, path in ipairs(environment.files) do logs.report("watch", "watching path ".. path) @@ -81,13 +88,13 @@ function scripts.watch.watch() lfs.chdir(path) local files = { } glob(files,path) - table.sort(files) -- what gets sorted here + table.sort(files) -- what gets sorted here, todo: by time for name, time in pairs(files) do --~ local ok, joblog = xpcall(function() return dofile(name) end, function() end ) local ok, joblog = pcall(dofile,name) if ok and joblog then if joblog.status == "processing" then - logs.report("watch",string.format("aborted job, %s added to queue",name)) + logs.report("watch",format("aborted job, %s added to queue",name)) joblog.status = "queued" io.savedata(name, table.serialize(joblog,true)) elseif joblog.status == "queued" then @@ -98,12 +105,13 @@ function scripts.watch.watch() outputpath = noset((joblog.paths and joblog.paths.output) or "."), filename = joblog.filename or "", } + -- todo: revision path etc command = command:gsub("%%(.-)%%", replacements) if command ~= "" then joblog.status = "processing" - joblog.runtime = os.clock() + joblog.runtime = clock() io.savedata(name, table.serialize(joblog,true)) - logs.report("watch",string.format("running: %s", command)) + logs.report("watch",format("running: %s", command)) local newpath = file.dirname(name) io.flush() local result = "" @@ -120,10 +128,10 @@ function scripts.watch.watch() scripts.watch.save_exa_modes(joblog,ctmname) if pipe then result = os.resultof(command) else result = os.spawn(command) end end - logs.report("watch",string.format("return value: %s", result)) + logs.report("watch",format("return value: %s", result)) done = true local path, base = replacements.outputpath, file.basename(replacements.filename) - joblog.runtime = os.clock() - joblog.runtime + joblog.runtime = clock() - joblog.runtime if base ~= "" then joblog.result = file.replacesuffix(file.join(path,base),"pdf") joblog.size = lfs.attributes(joblog.result,"size") @@ -138,7 +146,7 @@ function scripts.watch.watch() -- pcall, when error sleep + again io.savedata(name, table.serialize(joblog,true)) if logpath ~= "" then - local name = string.format("%s/%s%04i%09i.lua", logpath, os.time(), math.floor((os.clock()*100)%1000), math.random(99999999)) + local name = os.uuid() .. ".lua" io.savedata(name, table.serialize(joblog,true)) logs.report("watch", "saving joblog ".. name) end @@ -147,18 +155,43 @@ function scripts.watch.watch() end end end - local n, start = 0, os.clock() + local n, start = 0, time() local function wait() io.flush() if not done then n = n + 1 if n >= 10 then - logs.report("watch", string.format("run time: %i seconds, memory usage: %0.3g MB", os.clock() - start, (status.luastate_bytes/1024)/1000)) + logs.report("watch", format("run time: %i seconds, memory usage: %0.3g MB", difftime(time(),start), (status.luastate_bytes/1024)/1000)) n = 0 end os.sleep(delay) end end +local function wait() + io.flush() + local wtime, ttime = 0, 0 + if not done then + n = n + 1 + if n >= 10 then + logs.report("watch", format("run time: %i seconds, memory usage: %0.3g MB", difftime(time(),start), (status.luastate_bytes/1024)/1000)) + n = 0 + end + while true do + local wt = lfs.attributes(watcher,"mtime") + if wt ~= wtime then + -- fast signal that there is a request + wtime = wt + break + else + ttime = ttime + 0.2 + if ttime >= delay then + break + end + end + os.sleep(0.2) + end + end +end while true do if false then process() @@ -197,7 +230,7 @@ function scripts.watch.save_logs(collection,path) -- play safe if collection and not table.is_empty(collection) then path = path or environment.argument("logpath") or "" path = (path == "" and ".") or path - local filename = string.format("%s/collected-%s.lua",path,tostring(os.time())) + local filename = format("%s/collected-%s.lua",path,tostring(time())) io.savedata(filename,table.serialize(collection,true)) local check = dofile(filename) for k,v in pairs(check) do @@ -208,7 +241,7 @@ function scripts.watch.save_logs(collection,path) -- play safe end end for k,v in pairs(check) do - os.remove(string.format("%s.lua",k)) + os.remove(format("%s.lua",k)) end return true else @@ -243,7 +276,7 @@ function scripts.watch.show_logs(path) -- removes duplicates for k,v in ipairs(table.sortedkeys(collection)) do local c = collection[v] local f, s, r, n = c.filename or "?", c.status or "?", c.runtime or 0, c.size or 0 - logs.report("watch", string.format("%s %s %3i %8i %s",string.padd(f,max," "),string.padd(s,10," "),r,n,v)) + logs.report("watch", format("%s %s %3i %8i %s",string.padd(f,max," "),string.padd(s,10," "),r,n,v)) end end diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 68636a23c..3804c6799 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -168,9 +168,9 @@ \unexpanded\def\pushcolor[#1]% {\global\advance\currentcolornesting\plusone \expandafter\edef\csname\??cl:s:\number\currentcolornesting\endcsname - {\attribute\colormodelattribute \the\colormodelattribute - \attribute\colorattribute \the\colorattribute - \attribute\transparencyattribute\the\transparencyattribute + {\attribute\colormodelattribute \the\attribute\colormodelattribute + \attribute\colorattribute \the\attribute\colorattribute + \attribute\transparencyattribute\the\attribute\transparencyattribute \space}% stack \doactivatecolor{#1}} diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 0ffa84f19..40ca60100 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2009.12.13 23:27} +\newcontextversion{2009.12.14 22:32} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context-base.lmx b/tex/context/base/context-base.lmx index e84202cb3..a6781e4f6 100644 --- a/tex/context/base/context-base.lmx +++ b/tex/context/base/context-base.lmx @@ -63,9 +63,7 @@ </div> <div id="main"> <div id='main-settings'> - <div class='title'> - <?lua pv('maintext') ?> - </div> + <?lua pv('maintext') ?> </div> </div> </body> diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index d6a4d6897..55c87b5bb 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2009.12.13 23:27} +\edef\contextversion{2009.12.14 22:32} %D For those who want to use this: diff --git a/tex/context/base/l-io.lua b/tex/context/base/l-io.lua index a77edb107..0d0357039 100644 --- a/tex/context/base/l-io.lua +++ b/tex/context/base/l-io.lua @@ -35,7 +35,7 @@ function io.savedata(filename,data,joiner) elseif type(data) == "function" then data(f) else - f:write(data) + f:write(data or "") end f:close() return true diff --git a/tex/context/base/l-os.lua b/tex/context/base/l-os.lua index dcf8d3e95..81fb1e2be 100644 --- a/tex/context/base/l-os.lua +++ b/tex/context/base/l-os.lua @@ -10,7 +10,13 @@ local find, format = string.find, string.format local random, ceil = math.random, math.ceil function os.resultof(command) - return io.popen(command,"r"):read("*all") + local handle = io.popen(command,"r") + if not handle then + -- print("unknown command '".. command .. "' in os.resultof") + return "" + else + return handle:read("*all") or "" + end end if not os.exec then os.exec = os.execute end @@ -70,26 +76,6 @@ end --~ print(os.date("%H:%M:%S",os.gettimeofday())) --~ print(os.date("%H:%M:%S",os.time())) -if os.arch then - -- okay -elseif os.platform == "windows" then - os.arch = function() - local a = os.getenv("PROCESSOR_ARCHITECTURE") or "x86" - os.arch = function() - return a - end - return a - end -else - os.arch = function() - local a = os.getenv("PROCESSOR_ARCHITECTURE") or os.resultof("uname -m") or "x86" - os.arch = function() - return a - end - return a - end -end - -- no need for function anymore as we have more clever code and helpers now os.platform = os.name @@ -105,7 +91,13 @@ if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" th end os.libsuffix = 'dll' else - local architecture = os.arch() + local architecture = os.getenv("HOSTTYPE") or "" + if architecture == "" then + architecture = os.resultof("uname -m") or "" + end + if architecture == "" then + local architecture = os.resultof("echo $HOSTTYPE") + end if name == "linux" then if find(architecture,"x86_64") then os.platform = "linux-64" @@ -115,7 +107,6 @@ else os.platform = "linux" end elseif name == "macosx" then - local architecture = os.resultof("echo $HOSTTYPE") if find(architecture,"i386") then os.platform = "osx-intel" elseif find(architecture,"x86_64") then diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua index f5cab00c2..526a3a4d2 100644 --- a/tex/context/base/lpdf-ini.lua +++ b/tex/context/base/lpdf-ini.lua @@ -487,9 +487,11 @@ if not pdf.pdfcatalog then end -function lpdf.addtocatalog(k,v) catalog[k] = v end -function lpdf.addtoinfo (k,v) info [k] = v end -function lpdf.addtonames (k,v) names [k] = v end +lpdf.protectresources = true + +function lpdf.addtocatalog(k,v) if not (lpdf.protectresources and catalog[k]) then catalog[k] = v end end +function lpdf.addtoinfo (k,v) if not (lpdf.protectresources and info [k]) then info [k] = v end end +function lpdf.addtonames (k,v) if not (lpdf.protectresources and names [k]) then names [k] = v end end local r_extgstates, d_extgstates = pdfreserveobj(), pdfdictionary() local p_extgstates = pdfreference(r_extgstates) local r_colorspaces, d_colorspaces = pdfreserveobj(), pdfdictionary() local p_colorspaces = pdfreference(r_colorspaces) diff --git a/tex/context/base/lpdf-xmp.lua b/tex/context/base/lpdf-xmp.lua index 03f7c0dd4..03527e823 100644 --- a/tex/context/base/lpdf-xmp.lua +++ b/tex/context/base/lpdf-xmp.lua @@ -125,11 +125,20 @@ local function flushxmpinfo() texio.write_nl("log","") texio.write("log","\n% ",(gsub(blob,"[\r\n]","\n%% ")),"\n") end - if true then - commands.writestatus("system","xmp data not flushed (needs luatex upgrade)") - else - lpdf.addtocatalog("Metadata",lpdf.reference(pdf.immediateobj("stream",format(xpacket,packetid,blob),md()))) - end + -- if true then + -- commands.writestatus("system","xmp data not flushed (needs luatex upgrade)") + -- else + -- lpdf.addtocatalog("Metadata",lpdf.reference(pdf.immediateobj("stream",format(xpacket,packetid,blob),md()))) + local r = pdf.obj { + immediate = true, + compresslevel = 0, + type = "stream", + string = format(xpacket,packetid,blob), + attr = md(), + } + lpdf.addtocatalog("Metadata",lpdf.reference(r)) + -- end + commands.defrostrandomseed() -- hack end diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua index 8bd64890d..f38e5ad89 100644 --- a/tex/context/base/lxml-tab.lua +++ b/tex/context/base/lxml-tab.lua @@ -426,13 +426,15 @@ local text_parsed = Cs(((1-open-ampersand)^1 + entity)^1) local somespace = space^1 local optionalspace = space^0 -local value = (squote * C((1 - squote)^0) * squote) + (dquote * C((1 - dquote)^0) * dquote) -- ampersand and < also invalid in value +----- value = (squote * C((1 - squote)^0) * squote) + (dquote * C((1 - dquote)^0) * dquote) -- ampersand and < also invalid in value +local value = (squote * Cs((entity + (1 - squote))^0) * squote) + (dquote * Cs((entity + (1 - dquote))^0) * dquote) -- ampersand and < also invalid in value local endofattributes = slash * close + close -- recovery of flacky html local whatever = space * name * optionalspace * equal local wrongvalue = C(P(1-whatever-close)^1 + P(1-close)^1) / attribute_value_error ------ local wrongvalue = C(P(1-whatever-endofattributes)^1 + P(1-endofattributes)^1) / attribute_value_error -local wrongvalue = C(P(1-space-endofattributes)^1) / attribute_value_error +----- wrongvalue = C(P(1-whatever-endofattributes)^1 + P(1-endofattributes)^1) / attribute_value_error +----- wrongvalue = C(P(1-space-endofattributes)^1) / attribute_value_error +local wrongvalue = Cs(P(entity + (1-space-endofattributes))^1) / attribute_value_error local attributevalue = value + wrongvalue diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index fb37d9262..a2026e865 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -59,7 +59,7 @@ metapost.finder = finder metapost.parameters = { hash_size = 100000, - main_memory = 2000000, + main_memory = 2500000, max_in_open = 50, param_size = 100000, } diff --git a/tex/context/base/node-rul.mkiv b/tex/context/base/node-rul.mkiv index 0beae198c..f55bd28ec 100644 --- a/tex/context/base/node-rul.mkiv +++ b/tex/context/base/node-rul.mkiv @@ -142,7 +142,7 @@ \unexpanded\def\pushbar[#1]% {\global\advance\currentbarnesting\plusone \expandafter\edef\csname\??on:s:\number\currentbarnesting\endcsname - {\attribute\ruledattribute\the\ruledattribute}% stack + {\attribute\ruledattribute\the\attribute\ruledattribute}% stack \dodoruled{#1}} \unexpanded\def\popbar diff --git a/tex/context/base/strc-itm.mkiv b/tex/context/base/strc-itm.mkiv index 1b7443840..bb3a785ce 100644 --- a/tex/context/base/strc-itm.mkiv +++ b/tex/context/base/strc-itm.mkiv @@ -1060,7 +1060,7 @@ \def\checkforrepeatedlistitem {\ifconditional\repeatlistitem \ifx\currentrepeatstart\empty - \edef\currentrepeatstart{\the\numexpr\currentitemlevel-1}% + \let\currentrepeatstart\currentitemlevel \fi \setbox\itemgroupitembox\hbox to \wd\itemgroupitembox{\hskip-\itemgroupaskedwidth\box\itemgroupitembox}% what a hack ! \fi} diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index c03196d1b..b21e5a2d9 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua --- merge date : 12/13/09 23:30:54 +-- merge date : 12/14/09 22:36:17 do -- begin closure to overcome local limits and interference @@ -1726,7 +1726,7 @@ function io.savedata(filename,data,joiner) elseif type(data) == "function" then data(f) else - f:write(data) + f:write(data or "") end f:close() return true |