diff options
author | Karl Berry <karl@freefriends.org> | 2013-06-23 23:38:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-06-23 23:38:05 +0000 |
commit | 60f28f85f2707b6a48c3b5aec0ea68b8ee21e466 (patch) | |
tree | ab34d8d573457bea6a804ee3d5de48dd500bf028 /Master/texmf-dist/scripts | |
parent | ac5882d0cb115e11b5cc2e62107ef5822f3507f5 (diff) |
context
git-svn-id: svn://tug.org/texlive/trunk@30865 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-cache.lua | 5 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-context.lua | 30 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-fonts.lua | 42 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-patterns.lua | 127 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-pdf.lua | 46 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-plain.lua | 129 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtxlibs.lua | 1 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/context/lua/mtxrun.lua | 192 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/ruby/base/switch.rb | 2 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/ruby/base/tex.rb | 2 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua | 192 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/context/stubs/unix/mtxrun | 192 |
12 files changed, 837 insertions, 123 deletions
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-cache.lua b/Master/texmf-dist/scripts/context/lua/mtx-cache.lua index cd5512618d5..bff1cb4968f 100644 --- a/Master/texmf-dist/scripts/context/lua/mtx-cache.lua +++ b/Master/texmf-dist/scripts/context/lua/mtx-cache.lua @@ -91,13 +91,14 @@ local function purge(banner,path,list,all) end report("removed tma files : %i",n) report() + return n end function scripts.cache.purge() local writable = caches.getwritablepath() local tmas, tmcs, rest = collect(writable) list("writable path",writable,tmas,tmcs,rest) - local n = purge("writable path",writable,tmas) + purge("writable path",writable,tmas) list("writable path",writable,tmas,tmcs,rest) end @@ -105,7 +106,7 @@ function scripts.cache.erase() local writable = caches.getwritablepath() local tmas, tmcs, rest, all = collect(writable) list("writable path",writable,tmas,tmcs,rest) - local n = purge("writable path",writable,all,true) + purge("writable path",writable,all,true) list("writable path",writable,tmas,tmcs,rest) end diff --git a/Master/texmf-dist/scripts/context/lua/mtx-context.lua b/Master/texmf-dist/scripts/context/lua/mtx-context.lua index ddc9faacf19..87ed3475d0f 100644 --- a/Master/texmf-dist/scripts/context/lua/mtx-context.lua +++ b/Master/texmf-dist/scripts/context/lua/mtx-context.lua @@ -405,6 +405,33 @@ local function luatex_command(l_flags,c_flags,filename,engine) ) end +local plain_formats = { + ["plain"] = "plain", + ["luatex-plain"] = "luatex-plain", +} + +local function plain_format(plainformat) + return plainformat and plain_formats[plainformat] +end + +local function run_plain(plainformat,filename) + local plainformat = plain_formats[plainformat] + if plainformat then + local command = format("mtxrun --script --texformat=%s plain %s",plainformat,filename) + report("running command: %s\n\n",command) + -- todo: load and run + local resultname = file.replacesuffix(filename,"pdf") + local pdfview = getargument("autopdf") or getargument("closepdf") + if pdfview then + pdf_close(resultname,pdfview) + os.execute(command) + pdf_open(resultname,pdfview) + else + os.execute(command) + end + end +end + local function run_texexec(filename,a_purge,a_purgeall) if false then -- we need to write a top etc too and run mp etc so it's not worth the @@ -496,6 +523,7 @@ function scripts.context.run(ctxdata,filename) local a_arrange = getargument("arrange") local a_noarrange = getargument("noarrange") local a_jiton = getargument("jiton") + local a_texformat = getargument("texformat") -- a_batchmode = (a_batchmode and "batchmode") or (a_nonstopmode and "nonstopmode") or nil a_synctex = tonumber(a_synctex) or (toboolean(a_synctex,true) and 1) or (a_synctex == "zipped" and 1) or (a_synctex == "unzipped" and -1) or nil @@ -521,6 +549,8 @@ function scripts.context.run(ctxdata,filename) -- if a_mkii or analysis.engine == 'pdftex' or analysis.engine == 'xetex' then run_texexec(filename,a_purge,a_purgeall) + elseif plain_format(a_texformat or analysis.texformat) then + run_plain(a_texformat or analysis.texformat,filename) else if analysis.interface and analysis.interface ~= interface then formatname = formatofinterface[analysis.interface] or formatname diff --git a/Master/texmf-dist/scripts/context/lua/mtx-fonts.lua b/Master/texmf-dist/scripts/context/lua/mtx-fonts.lua index d427f8b2fc3..b171dd611f4 100644 --- a/Master/texmf-dist/scripts/context/lua/mtx-fonts.lua +++ b/Master/texmf-dist/scripts/context/lua/mtx-fonts.lua @@ -22,7 +22,7 @@ local helpinfo = [[ <category name="basic"> <subcategory> <flag name="save"><short>save open type font in raw table</short></flag> - <flag name="unpack"><short>save a tma file in a more readale format</short></flag> + <flag name="unpack"><short>save a tma file in a more readable format</short></flag> </subcategory> <subcategory> <flag name="reload"><short>generate new font database (use <ref name="force"/> when in doubt)</short></flag> @@ -85,6 +85,7 @@ local report = application.report if not fontloader then fontloader = fontforge end dofile(resolvers.findfile("font-otp.lua","tex")) -- we need to unpack the font for analysis +dofile(resolvers.findfile("font-trt.lua","tex")) dofile(resolvers.findfile("font-syn.lua","tex")) dofile(resolvers.findfile("font-mis.lua","tex")) @@ -135,6 +136,7 @@ function fonts.names.simple() local simpleversion = 1.001 local simplelist = { "ttf", "otf", "ttc", "dfont" } local name = "luatex-fonts-names.lua" + local path = file.collapsepath(caches.getwritablepath("..","..","generic","fonts","data")) fonts.names.filters.list = simplelist fonts.names.version = simpleversion -- this number is the same as in font-dum.lua report("generating font database for 'luatex-fonts' version %s",fonts.names.version) @@ -143,8 +145,9 @@ function fonts.names.simple() if data then local simplemappings = { } local simplified = { - mappings = simplemappings, - version = simpleversion, + mappings = simplemappings, + version = simpleversion, + cache_version = simpleversion, } local specifications = data.specifications for i=1,#simplelist do @@ -154,7 +157,18 @@ function fonts.names.simple() simplemappings[tag] = { s.rawname, s.filename, s.subfont } end end - report("saving names in '%s'",name) + if environment.arguments.nocache then + report("not using cache path %a",path) + else + dir.mkdirs(path) + if lfs.isdir(path) then + report("saving names on cache path %a",path) + name = file.join(path,name) + else + report("invalid cache path %a",path) + end + end + report("saving names in %a",name) io.savedata(name,table.serialize(simplified,true)) local data = io.loaddata(resolvers.findfile("luatex-fonts-syn.lua","tex")) or "" local dummy = string.match(data,"fonts%.names%.version%s*=%s*([%d%.]+)") @@ -365,10 +379,21 @@ function scripts.fonts.list() end +function scripts.fonts.justload() + local fullname = environment.files[1] + if fullname then + local result = fontloader.open(fullname) + if type(result) == "table" then + report("loading %s: %s","succeeded",fullname) + end + end + report("loading %s: %s","failed",fullname) +end + function scripts.fonts.unpack() local name = file.removesuffix(file.basename(givenfiles[1] or "")) if name and name ~= "" then - local cache = containers.define("fonts", "otf", 2.730, true) + local cache = containers.define("fonts", "otf", 2.742, true) local cleanname = containers.cleanname(name) local data = containers.read(cache,cleanname) if data then @@ -377,7 +402,7 @@ function scripts.fonts.unpack() fonts.handlers.otf.enhancers.unpack(data) io.savedata(savename,table.serialize(data,true)) else - report("unknown file '%s'",name) + report("unknown file %a",name) end end end @@ -387,9 +412,8 @@ function scripts.fonts.save() local sub = givenfiles[2] or "" local function save(savename,fontblob) if fontblob then - savename = savename:lower() .. ".lua" + savename = file.addsuffix(string.lower(savename),"lua") report("fontsave, saving data in %s",savename) --- fontloader.apply_featurefile(fontblob, "./ts/test.fea") table.tofile(savename,fontloader.to_table(fontblob),"return") fontloader.close(fontblob) end @@ -435,6 +459,8 @@ elseif getargument("reload") then scripts.fonts.reload() elseif getargument("save") then scripts.fonts.save() +elseif getargument("justload") then + scripts.fonts.justload() elseif getargument("unpack") then scripts.fonts.unpack() elseif getargument("statistics") then diff --git a/Master/texmf-dist/scripts/context/lua/mtx-patterns.lua b/Master/texmf-dist/scripts/context/lua/mtx-patterns.lua index 7144da9b090..dca81568e41 100644 --- a/Master/texmf-dist/scripts/context/lua/mtx-patterns.lua +++ b/Master/texmf-dist/scripts/context/lua/mtx-patterns.lua @@ -27,6 +27,8 @@ local helpinfo = [[ <flag name="path"><short>source path where hyph-foo.tex files are stored</short></flag> <flag name="destination"><short>destination path</short></flag> <flag name="specification"><short>additional patterns: e.g.: =cy,hyph-cy,welsh</short></flag> + <flag name="compress"><short>compress data</short></flag> + <flag name="words"><short>update words in given file</short></flag> </subcategory> </category> </flags> @@ -148,10 +150,11 @@ scripts.patterns.list = { { "sv", "hyph-sv", "swedish" }, -- { "ta", "hyph-ta", "tamil" }, -- { "te", "hyph-te", "telugu" }, + { "th", "hyph-th", "thai" }, { "tk", "hyph-tk", "turkmen" }, { "tr", "hyph-tr", "turkish" }, { "uk", "hyph-uk", "ukrainian" }, - { "zh", "hyph-zh-latn", "zh-latn, chinese pinyin" }, + { "zh", "hyph-zh-latn-pinyin","zh-latn, chinese pinyin" }, } -- stripped down from lpeg example: @@ -166,6 +169,7 @@ end -- *.hyp.txt *.pat.txt *.lic.txt *.chr.txt function scripts.patterns.load(path,name,mnemonic,ignored) + local basename = name local fullname = file.join(path,name) local texfile = addsuffix(fullname,"tex") local hypfile = addsuffix(fullname,"hyp.txt") @@ -190,7 +194,7 @@ function scripts.patterns.load(path,name,mnemonic,ignored) local subfull = file.join(file.dirname(texfile),subname) local subdata = io.loaddata(subfull) or "" if subdata == "" then - report("no subfile %s",subname) + report("%s: no subfile %s",basename,subname) end return previous .. subdata end) @@ -219,7 +223,7 @@ function scripts.patterns.load(path,name,mnemonic,ignored) local line = splitdata[i] if find(line,"%%") then splitdata[i] = gsub(line,"%%.*$","") - report("removing comment: %s",line) + report("%s: removing comment: %s",basename,line) end end end @@ -235,7 +239,7 @@ function scripts.patterns.load(path,name,mnemonic,ignored) local line = splitdata[i] if find(line,"\\") then splitdata[i] = "" - report("removing line with command: %s",line) + report("%s: removing line with command: %s",basename,line) end end end @@ -251,7 +255,7 @@ function scripts.patterns.load(path,name,mnemonic,ignored) local ok = lpegmatch(validutf8,line) if not ok then splitdata[i] = "" - report("removing line with invalid utf: %s",line) + report("%s: removing line with invalid utf: %s",basename,line) end end -- check for commands being used in comments @@ -275,15 +279,15 @@ function scripts.patterns.load(path,name,mnemonic,ignored) else local cdb = cd[b] if not cdb then - report("no entry in chardata for character %s (0x%04X)",char(b),b) + report("%s: no entry in chardata for character %C",basename,b) else local ct = cdb.category - if ct == "lu" or ct == "ll" then + if ct == "lu" or ct == "ll" or ct == "lo" or ct == "mn" then -- hm, really mn ? used[char(b)] = true elseif ct == "nd" then -- number else - report("removing line with suspected utf character %s (0x%04X), category %s: %s",char(b),b,ct,line) + report("%s: removing line with suspected utf character %C, category %s: %s",basename,b,ct,line) splitdata[i] = "" break end @@ -296,7 +300,7 @@ function scripts.patterns.load(path,name,mnemonic,ignored) usedpatterncharactersnew = check(splitpatternsnew,byte(".")) usedhyphenationcharactersnew = check(splithyphenationsnew,byte("-")) for k, v in next, stripped do - report("entries that contain character %s (0x%04X) have been omitted",char(k),k) + report("%s: entries that contain character %C have been omitted",basename,k) end end if okay then @@ -327,11 +331,11 @@ function scripts.patterns.load(path,name,mnemonic,ignored) for i=1,#what do local line = what[i] if p and lpegmatch(p,line) then - report("discarding conflicting pattern: %s",line) + report("%s: discarding conflicting pattern: %s",basename,line) else -- we can speed this up by testing for replacements in the string local l = lpegmatch(r,line) if l ~= line then - report("sanitizing pattern: %s -> %s (for old patterns)",line,l) + report("%s: sanitizing pattern: %s -> %s (for old patterns)",basename,line,l) end result[#result+1] = l end @@ -353,7 +357,7 @@ function scripts.patterns.load(path,name,mnemonic,ignored) -- discard elseif used[line] then -- discard - report("discarding duplicate pattern: %s",line) + report("%s: discarding duplicate pattern: %s",basename,line) else used[line] = true collected[#collected+1] = line @@ -411,6 +415,8 @@ function scripts.patterns.save(destination,mnemonic,name,patternsnew,hyphenation if not comment or comment == "" then comment = "% no comment" end if not type(destination) == "string" then destination = "." end + local compression = environment.arguments.compress and "zlib" or nil + local lines = string.splitlines(comment) for i=1,#lines do if not find(lines[i],"^%%") then @@ -427,9 +433,12 @@ function scripts.patterns.save(destination,mnemonic,name,patternsnew,hyphenation local patterndata, hyphenationdata if nofpatternsnew > 0 then + local data = concat(patternsnew," ") patterndata = { n = nofpatternsnew, - data = concat(patternsnew," ") or nil, + compression = compression, + length = #data, + data = compression and zlib.compress(data,9) or data, characters = concat(table.sortedkeys(pusednew),""), minhyphenmin = 1, -- determined by pattern author minhyphenmax = 1, -- determined by pattern author @@ -440,10 +449,13 @@ function scripts.patterns.save(destination,mnemonic,name,patternsnew,hyphenation } end if nofhyphenationsnew > 0 then + local data = concat(hyphenationsnew," ") hyphenationdata = { - n = nofhyphenationsnew, - data = concat(hyphenationsnew," "), - characters = concat(table.sortedkeys(husednew),""), + n = nofhyphenationsnew, + compression = compression, + length = #data, + data = compression and zlib.compress(data,9) or data, + characters = concat(table.sortedkeys(husednew),""), } else hyphenationdata = { @@ -541,12 +553,83 @@ function scripts.patterns.convert() end end +local function valid(filename) + local specification = table.load(filename) + if not specification then + return false + end + local lists = specification.lists + if not lists then + return false + end + return specification, lists +end + +function scripts.patterns.words() + if environment.arguments.update then + local compress = environment.arguments.compress + for i=1,#environment.files do + local filename = environment.files[i] + local fullname = resolvers.findfile(filename) + if fullname and fullname ~= "" then + report("checking file %a",fullname) + local specification, lists = valid(fullname) + if specification and #lists> 0 then + report("updating %a of language %a",filename,specification.language) + for i=1,#lists do + local entry = lists[i] + local filename = entry.filename + if filename then + local fullname = resolvers.findfile(filename) + if fullname then + report("adding words from %a",fullname) + local data = io.loaddata(fullname) or "" + data = string.strip(data) + data = string.gsub(data,"%s+"," ") + if compress then + entry.data = zlib.compress(data,9) + entry.compression = "zlib" + entry.length = #data + else + entry.data = data + entry.compression = nil + entry.length = #data + end + else + entry.data = "" + entry.compression = nil + entry.length = 0 + end + else + entry.data = "" + entry.compression = nil + entry.length = 0 + end + end + specification.version = "1.00" + specification.timestamp = os.localtime() + report("updated file %a is saved",filename) + table.save(filename,specification) + else + report("no file %a",filename) + end + else + report("nothing done") + end + end + else + report("provide --update") + end +end + if environment.argument("check") then scripts.patterns.prepare() scripts.patterns.check() elseif environment.argument("convert") then scripts.patterns.prepare() scripts.patterns.convert() +elseif environment.argument("words") then + scripts.patterns.words() -- for the moment here elseif environment.argument("exporthelp") then application.export(environment.argument("exporthelp"),environment.files[1]) else @@ -557,3 +640,15 @@ end -- mtxrun --script pattern --check --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns -- mtxrun --script pattern --convert --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns/tex --destination=e:/tmp/patterns -- mtxrun --script pattern --convert --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns/txt --destination=e:/tmp/patterns + +-- copy /Y *.hyp e:\tex-context\tex\texmf-context\tex\context\patterns +-- copy /Y *.pat e:\tex-context\tex\texmf-context\tex\context\patterns +-- copy /Y *.rme e:\tex-context\tex\texmf-context\tex\context\patterns +-- copy /Y *.lua e:\tex-context\tex\texmf-context\tex\context\patterns + +-- move /Y *.hyp e:\tex-context\tex\texmf-mine\tex\context\patterns +-- move /Y *.pat e:\tex-context\tex\texmf-mine\tex\context\patterns +-- move /Y *.rme e:\tex-context\tex\texmf-mine\tex\context\patterns +-- move /Y *.lua e:\tex-context\tex\texmf-mine\tex\context\patterns + +-- mtxrun --script pattern --words --update word-th.lua --compress diff --git a/Master/texmf-dist/scripts/context/lua/mtx-pdf.lua b/Master/texmf-dist/scripts/context/lua/mtx-pdf.lua index 3e4130344ee..551aa5b37ca 100644 --- a/Master/texmf-dist/scripts/context/lua/mtx-pdf.lua +++ b/Master/texmf-dist/scripts/context/lua/mtx-pdf.lua @@ -26,6 +26,7 @@ local helpinfo = [[ <flag name="info"><short>show some info about the given file</short></flag> <flag name="metadata"><short>show metadata xml blob</short></flag> <flag name="fonts"><short>show used fonts (<ref name="detail)"/></short></flag> + <flag name="linearize"><short>linearize given file</short></flag> </subcategory> </category> </flags> @@ -213,9 +214,50 @@ function scripts.pdf.fonts(filename) end end +-- this is a quick hack ... proof of concept .. will change (derived from luigi's example) ... +-- i will make a ctx wrapper + +local qpdf + +function scripts.pdf.linearize(filename) + qpdf = qpdf or swiglib("qpdf.core") + local oldfile = filename or environment.files[1] + if not oldfile then + return + end + file.addsuffix(oldfile,"pdf") + if not lfs.isfile(oldfile) then + return + end + local newfile = environment.files[2] + if not newfile or file.removesuffix(oldfile) == file.removesuffix(newfile)then + newfile = file.addsuffix(file.removesuffix(oldfile) .. "-linearized","pdf") + end + local password = environment.arguments.password + local instance = qpdf.qpdf_init() + if bit32.band(qpdf.qpdf_read(instance,oldfile,password),qpdf.QPDF_ERRORS) ~= 0 then + report("unable to open input file") + elseif bit32.band(qpdf.qpdf_init_write(instance,newfile),qpdf.QPDF_ERRORS) ~= 0 then + report("unable to open output file") + else + report("linearizing %a into %a",oldfile,newfile) + qpdf.qpdf_set_static_ID(instance,qpdf.QPDF_TRUE) + qpdf.qpdf_set_linearization(instance,qpdf.QPDF_TRUE) + qpdf.qpdf_write(instance) + end + while qpdf.qpdf_more_warnings(instance) ~= 0 do + report("warning: %s",qpdf.qpdf_get_error_full_text(instance,qpdf.qpdf_next_warning(qpdf))) + end + if qpdf.qpdf_has_error(instance) ~= 0 then + report("error: %s",qpdf.qpdf_get_error_full_text(instance,qpdf.qpdf_get_error(qpdf))) + end + qpdf.qpdf_cleanup_p(instance) +end + -- scripts.pdf.info("e:/tmp/oeps.pdf") -- scripts.pdf.metadata("e:/tmp/oeps.pdf") -- scripts.pdf.fonts("e:/tmp/oeps.pdf") +-- scripts.pdf.linearize("e:/tmp/oeps.pdf") local filename = environment.files[1] or "" @@ -227,8 +269,10 @@ elseif environment.argument("metadata") then scripts.pdf.metadata(filename) elseif environment.argument("fonts") then scripts.pdf.fonts(filename) +elseif environment.argument("linearize") then + scripts.pdf.linearize(filename) elseif environment.argument("exporthelp") then - application.export(environment.argument("exporthelp"),environment.files[1]) + application.export(environment.argument("exporthelp"),filename) else application.help() end diff --git a/Master/texmf-dist/scripts/context/lua/mtx-plain.lua b/Master/texmf-dist/scripts/context/lua/mtx-plain.lua new file mode 100644 index 00000000000..f43dcdeafcc --- /dev/null +++ b/Master/texmf-dist/scripts/context/lua/mtx-plain.lua @@ -0,0 +1,129 @@ +if not modules then modules = { } end modules ['mtx-plain'] = { + version = 1.002, + comment = "companion to mtxrun.lua", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- future version will use the texmf-cache/generic/formats/<engine> path +-- instead because then we can use some more of the generic context +-- initializers ... in that case we will also use the regular database +-- instead of kpse here, just like with the font database code (as that +-- one also works with kpse runtime) + +local helpinfo = [[ +<?xml version="1.0"?> +<application> + <metadata> + <entry name="name">mtx-plain</entry> + <entry name="detail">Plain TeX Runner</entry> + <entry name="version">1.00</entry> + </metadata> + <flags> + <category name="basic"> + <subcategory> + <flag name="make"><short>create format file</short></flag> + <flag name="run"><short>process file</short></flag> + <flag name="format" value="string"><short>format name (default: luatex-plain)</short></flag> + <flag name="engine" value="string"><short>engine to use (default: luatex)</short></flag> + <flag name="jit"><short>use luajittex</short></flag> + </subcategory> + </category> + </flags> +</application> +]] + +local application = logs.application { + name = "mtx-plain", + banner = "Plain TeX Runner 1.00", + helpinfo = helpinfo, +} + +local report = application.report + +scripts = scripts or { } +scripts.plain = scripts.plain or { } + +local function execute(...) + local command = string.format(...) + report("running command %a\n",command) + os.execute(command) +end + +local function resultof(...) + local command = string.format(...) + report("running command %a",command) + return string.strip(os.resultof(command) or "") +end + +function scripts.plain.make(texengine,texformat) + report("generating kpse file database") + execute("mktexlsr") -- better play safe and use this one + local fmtpathspec = resultof("kpsewhich --var-value=TEXFORMATS --engine=%s",texengine) + if fmtpathspec ~= "" then + report("using path specification %a",fmtpathspec) + fmtpathspec = resultof('kpsewhich -expand-braces="%s"',fmtpathspec) + end + if fmtpathspec ~= "" then + report("using path expansion %a",fmtpathspec) + else + report("no valid path reported, trying alternative") + fmtpathspec = resultof("kpsewhich --show-path=fmt --engine=%s",texengine) + if fmtpathspec ~= "" then + report("using path expansion %a",fmtpathspec) + else + report("no valid path reported, falling back to current path") + fmtpathspec = "." + end + end + fmtpathspec = string.splitlines(fmtpathspec)[1] or fmtpathspec + fmtpathspec = file.splitpath(fmtpathspec) + local fmtpath = nil + for i=1,#fmtpathspec do + local path = fmtpathspec[i] + if path ~= "." then + dir.makedirs(path) + if lfs.isdir(path) and file.is_writable(path) then + fmtpath = path + break + end + end + end + if not fmtpath or fmtpath == "" then + fmtpath = "." + else + lfs.chdir(fmtpath) + end + execute('%s --ini %s \\dump',texengine,file.addsuffix(texformat,"tex")) + report("generating kpse file database") + execute("mktexlsr") + report("format %a saved on path %a",texformat,fmtpath) +end + +function scripts.plain.run(texengine,texformat,filename) + execute('%s --fmt=%s "%s"',texengine,file.removesuffix(texformat),filename) +end + +local texformat = environment.arguments.texformat or environment.arguments.format +local texengine = environment.arguments.texengine or environment.arguments.engine + +if type(texengine) ~= "string" or texengine == "" then + texengine = environment.arguments.jit and "luajittex" or"luatex" +end + +if type(texformat) ~= "string" or texformat == "" then + texformat = "luatex-plain" +end + +local filename = environment.files[1] + +if environment.arguments.exporthelp then + application.export(environment.arguments.exporthelp,filename) +elseif environment.arguments.make then + scripts.plain.make(texengine,texformat) +elseif filename then + scripts.plain.run(texengine,texformat,filename) +else + application.help() +end diff --git a/Master/texmf-dist/scripts/context/lua/mtxlibs.lua b/Master/texmf-dist/scripts/context/lua/mtxlibs.lua index a34ba139a1b..7f52ac8bdfa 100644 --- a/Master/texmf-dist/scripts/context/lua/mtxlibs.lua +++ b/Master/texmf-dist/scripts/context/lua/mtxlibs.lua @@ -78,6 +78,7 @@ local ownlibs = { "l-set.lua", "l-os.lua", "l-file.lua", -- limited functionality when no lfs + -- "l-gzip.lua", "l-md5.lua", -- not loaded when no md5 library "l-url.lua", "l-dir.lua", -- limited functionality when no lfs diff --git a/Master/texmf-dist/scripts/context/lua/mtxrun.lua b/Master/texmf-dist/scripts/context/lua/mtxrun.lua index b06cd695519..d07dfc9a7a1 100755 --- a/Master/texmf-dist/scripts/context/lua/mtxrun.lua +++ b/Master/texmf-dist/scripts/context/lua/mtxrun.lua @@ -144,7 +144,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-package"] = package.loaded["l-package"] or true --- original size: 9341, stripped down to: 6815 +-- original size: 9893, stripped down to: 7253 if not modules then modules={} end modules ['l-package']={ version=1.001, @@ -168,16 +168,17 @@ local pattern=Cs((((1-S("\\/"))^0*(S("\\/")^1/"/"))^0*(P(".")^1/"/"+P(1))^1)*-1) local function lualibfile(name) return lpegmatch(pattern,name) or name end +local offset=luarocks and 1 or 0 local helpers=package.helpers or { cleanpath=cleanpath, lualibfile=lualibfile, trace=false, report=function(...) print(format(...)) end, builtin={ - ["preload table"]=searchers[1], - ["path specification"]=searchers[2], - ["cpath specification"]=searchers[3], - ["all in one fallback"]=searchers[4], + ["preload table"]=searchers[1+offset], + ["path specification"]=searchers[2+offset], + ["cpath specification"]=searchers[3+offset], + ["all in one fallback"]=searchers[4+offset], }, methods={}, sequence={ @@ -358,6 +359,8 @@ methods["not loaded"]=function(name) return nil end local level=0 +local used={} +helpers.traceused=false function helpers.loaded(name) local sequence=helpers.sequence level=level+1 @@ -371,6 +374,9 @@ function helpers.loaded(name) if helpers.trace then helpers.report("%s, level '%s', method '%s', name '%s'","found",level,method,name) end + if helpers.traceused then + used[#used+1]={ level=level,name=name } + end level=level-1 return result,rest end @@ -378,6 +384,18 @@ function helpers.loaded(name) level=level-1 return nil end +function helpers.showused() + local n=#used + if n>0 then + helpers.report("%s libraries loaded:",n) + helpers.report() + for i=1,n do + local u=used[i] + helpers.report("%i %a",u.level,u.name) + end + helpers.report() + end +end function helpers.unload(name) if helpers.trace then if package.loaded[name] then @@ -2825,7 +2843,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 16912, stripped down to: 9198 +-- original size: 17777, stripped down to: 9653 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -2869,7 +2887,7 @@ elseif not lfs.isfile then end end local insert,concat=table.insert,table.concat -local match,find=string.match,string.find +local match,find,gmatch=string.match,string.find,string.gmatch local lpegmatch=lpeg.match local getcurrentdir,attributes=lfs.currentdir,lfs.attributes local checkedsplit=string.checkedsplit @@ -2900,11 +2918,21 @@ local pattern=(noslashes^0*slashes)^0*(noperiod^1*period)^1*C(noperiod^1)*-1 local function suffixonly(name) return name and lpegmatch(pattern,name) or "" end +local pattern=(noslashes^0*slashes)^0*noperiod^1*((period*C(noperiod^1))^1)*-1+Cc("") +local function suffixesonly(name) + if name then + return lpegmatch(pattern,name) + else + return "" + end +end file.pathpart=pathpart file.basename=basename file.nameonly=nameonly file.suffixonly=suffixonly file.suffix=suffixonly +file.suffixesonly=suffixesonly +file.suffixes=suffixesonly file.dirname=pathpart file.extname=suffixonly local drive=C(R("az","AZ"))*colon @@ -2929,7 +2957,11 @@ function file.splitname(str,splitdrive) end end function file.splitbase(str) - return str and lpegmatch(pattern_d,str) + if str then + return lpegmatch(pattern_d,str) + else + return "",str + end end function file.nametotable(str,splitdrive) if str then @@ -3178,6 +3210,67 @@ function file.strip(name,dir) return a~="" and a or name end end +function lfs.mkdirs(path) + local full="" + for sub in gmatch(path,"(/*[^\\/]+)") do + full=full..sub + lfs.mkdir(full) + end +end + + +end -- of closure + +do -- create closure to overcome 200 locals limit + +package.loaded["l-gzip"] = package.loaded["l-gzip"] or true + +-- original size: 1211, stripped down to: 1002 + +if not modules then modules={} end modules ['l-gzip']={ + version=1.001, + author="Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright="PRAGMA ADE / ConTeXt Development Team", + license="see context related readme files" +} +if not gzip then + return +end +local suffix,suffixes=file.suffix,file.suffixes +function gzip.load(filename) + local f=io.open(filename,"rb") + if not f then + elseif suffix(filename)=="gz" then + f:close() + local g=gzip.open(filename,"rb") + if g then + local str=g:read("*all") + g:close() + return str + end + else + local str=f:read("*all") + f:close() + return str + end +end +function gzip.save(filename,data) + if suffix(filename)~="gz" then + filename=filename..".gz" + end + local f=io.open(filename,"wb") + if f then + local s=zlib.compress(data or "",9,nil,15+16) + f:write(s) + f:close() + return #s + end +end +function gzip.suffix(filename) + local suffix,extra=suffixes(filename) + local gzipped=extra=="gz" + return suffix,gzipped +end end -- of closure @@ -4932,7 +5025,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-tab"] = package.loaded["util-tab"] or true --- original size: 14491, stripped down to: 8512 +-- original size: 14510, stripped down to: 8531 if not modules then modules={} end modules ['util-tab']={ version=1.001, @@ -5210,9 +5303,9 @@ function table.deserialize(str) end return code end -function table.load(filename) +function table.load(filename,loader) if filename then - local t=io.loaddata(filename) + local t=(loader or io.loaddata)(filename) if t and t~="" then t=load(t) if type(t)=="function" then @@ -5450,7 +5543,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-prs"] = package.loaded["util-prs"] or true --- original size: 16976, stripped down to: 12143 +-- original size: 17827, stripped down to: 12722 if not modules then modules={} end modules ['util-prs']={ version=1.001, @@ -5520,7 +5613,9 @@ patterns.settings_to_hash_a=pattern_a_s patterns.settings_to_hash_b=pattern_b_s patterns.settings_to_hash_c=pattern_c_s function parsers.make_settings_to_hash_pattern(set,how) - if how=="strict" then + if type(str)=="table" then + return set + elseif how=="strict" then return (pattern_c/set)^1 elseif how=="tolerant" then return (pattern_b/set)^1 @@ -5529,7 +5624,16 @@ function parsers.make_settings_to_hash_pattern(set,how) end end function parsers.settings_to_hash(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_a_s,str) return hash @@ -5538,7 +5642,16 @@ function parsers.settings_to_hash(str,existing) end end function parsers.settings_to_hash_tolerant(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_b_s,str) return hash @@ -5547,7 +5660,16 @@ function parsers.settings_to_hash_tolerant(str,existing) end end function parsers.settings_to_hash_strict(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_c_s,str) return next(hash) and hash @@ -5560,7 +5682,9 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm local pattern=spaces*Ct(value*(separator*value)^0) patterns.settings_to_array=pattern function parsers.settings_to_array(str,strict) - if not str or str=="" then + if type(str)=="table" then + return str + elseif not str or str=="" then return {} elseif strict then if find(str,"{") then @@ -5712,8 +5836,7 @@ local escape=P('\\') local separator=S(' ,') local key=C((1-equal)^1) local value=dquote*C((1-dquote-escape*dquote)^0)*dquote -local pattern=Cf(Ct("")*Cg(key*equal*value)*separator^0,rawset)^0*P(-1) -patterns.keq_to_hash_c=pattern +local pattern=Cf(Ct("")*(Cg(key*equal*value)*separator^0)^1,rawset)^0*P(-1) function parsers.keq_to_hash(str) if str and str~="" then return lpegmatch(pattern,str) @@ -6262,7 +6385,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 21920, stripped down to: 14287 +-- original size: 21914, stripped down to: 14287 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -14557,7 +14680,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-con"] = package.loaded["data-con"] or true --- original size: 4940, stripped down to: 3580 +-- original size: 5010, stripped down to: 3588 if not modules then modules={} end modules ['data-con']={ version=1.100, @@ -14666,7 +14789,7 @@ function containers.content(container,name) return container.storage[name] end function containers.cleanname(name) - return (gsub(lower(name),"[^%w%d]+","-")) + return (gsub(lower(name),"[^%w\128-\255]+","-")) end @@ -15559,7 +15682,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lib"] = package.loaded["util-lib"] or true --- original size: 11094, stripped down to: 5516 +-- original size: 11136, stripped down to: 5549 if not modules then modules={} end modules ['util-lib']={ version=1.001, @@ -15639,10 +15762,10 @@ local function requireswiglib(required,version) end end if trace_swiglib then - report_swiglib("checking clib paths") + report_swiglib("checking lib paths") end - package.extraclibpath(environment.ownpath) - local paths=package.clibpaths() + package.extralibpath(environment.ownpath) + local paths=package.libpaths() for i=1,#paths do local found=check(lfs.isfile) if found and (not checkpattern or find(found,checkpattern)) then @@ -15714,7 +15837,9 @@ function swiglib(name,version) local library=swiglibs[name] if not library then statistics.starttiming(swiglibs) - report_swiglib("loading %a",name) + if trace_swiglib then + report_swiglib("loading %a",name) + end library=requireswiglib("swiglib."..name,version) swiglibs[name]=library statistics.stoptiming(swiglibs) @@ -15969,10 +16094,10 @@ end 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-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 +-- 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 : 666608 --- stripped bytes : 244185 +-- original bytes : 670212 +-- stripped bytes : 245255 -- end library merge @@ -16006,6 +16131,7 @@ local ownlibs = { -- order can be made better 'l-set.lua', 'l-os.lua', 'l-file.lua', + 'l-gzip.lua', 'l-md5.lua', 'l-url.lua', 'l-dir.lua', @@ -17281,6 +17407,8 @@ if os.type ~= "windows" then texio.write("\n") -- is this still valid? end -if ok == false then ok = 1 elseif ok == true then ok = 0 end +if ok == false then ok = 1 elseif ok == true or ok == nil then ok = 0 end + +-- os.exit(ok,true) -- true forces a cleanup in 5.2+ -os.exit(ok,true) -- true forces a cleanup in 5.2+ +os.exit(ok) -- true forces a cleanup in 5.2+ but reports a wrong number then diff --git a/Master/texmf-dist/scripts/context/ruby/base/switch.rb b/Master/texmf-dist/scripts/context/ruby/base/switch.rb index 79613dcd0f9..e3875201861 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/switch.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/switch.rb @@ -1,3 +1,5 @@ +#encoding: ASCII-8BIT + # module : base/switch # copyright : PRAGMA Advanced Document Engineering # version : 2002-2005 diff --git a/Master/texmf-dist/scripts/context/ruby/base/tex.rb b/Master/texmf-dist/scripts/context/ruby/base/tex.rb index 9ba842501ea..77d61b4db94 100644 --- a/Master/texmf-dist/scripts/context/ruby/base/tex.rb +++ b/Master/texmf-dist/scripts/context/ruby/base/tex.rb @@ -1,3 +1,5 @@ +#encoding: ASCII-8BIT + # module : base/tex # copyright : PRAGMA Advanced Document Engineering # version : 2005 diff --git a/Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua b/Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua index b06cd695519..d07dfc9a7a1 100644 --- a/Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua +++ b/Master/texmf-dist/scripts/context/stubs/mswin/mtxrun.lua @@ -144,7 +144,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-package"] = package.loaded["l-package"] or true --- original size: 9341, stripped down to: 6815 +-- original size: 9893, stripped down to: 7253 if not modules then modules={} end modules ['l-package']={ version=1.001, @@ -168,16 +168,17 @@ local pattern=Cs((((1-S("\\/"))^0*(S("\\/")^1/"/"))^0*(P(".")^1/"/"+P(1))^1)*-1) local function lualibfile(name) return lpegmatch(pattern,name) or name end +local offset=luarocks and 1 or 0 local helpers=package.helpers or { cleanpath=cleanpath, lualibfile=lualibfile, trace=false, report=function(...) print(format(...)) end, builtin={ - ["preload table"]=searchers[1], - ["path specification"]=searchers[2], - ["cpath specification"]=searchers[3], - ["all in one fallback"]=searchers[4], + ["preload table"]=searchers[1+offset], + ["path specification"]=searchers[2+offset], + ["cpath specification"]=searchers[3+offset], + ["all in one fallback"]=searchers[4+offset], }, methods={}, sequence={ @@ -358,6 +359,8 @@ methods["not loaded"]=function(name) return nil end local level=0 +local used={} +helpers.traceused=false function helpers.loaded(name) local sequence=helpers.sequence level=level+1 @@ -371,6 +374,9 @@ function helpers.loaded(name) if helpers.trace then helpers.report("%s, level '%s', method '%s', name '%s'","found",level,method,name) end + if helpers.traceused then + used[#used+1]={ level=level,name=name } + end level=level-1 return result,rest end @@ -378,6 +384,18 @@ function helpers.loaded(name) level=level-1 return nil end +function helpers.showused() + local n=#used + if n>0 then + helpers.report("%s libraries loaded:",n) + helpers.report() + for i=1,n do + local u=used[i] + helpers.report("%i %a",u.level,u.name) + end + helpers.report() + end +end function helpers.unload(name) if helpers.trace then if package.loaded[name] then @@ -2825,7 +2843,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 16912, stripped down to: 9198 +-- original size: 17777, stripped down to: 9653 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -2869,7 +2887,7 @@ elseif not lfs.isfile then end end local insert,concat=table.insert,table.concat -local match,find=string.match,string.find +local match,find,gmatch=string.match,string.find,string.gmatch local lpegmatch=lpeg.match local getcurrentdir,attributes=lfs.currentdir,lfs.attributes local checkedsplit=string.checkedsplit @@ -2900,11 +2918,21 @@ local pattern=(noslashes^0*slashes)^0*(noperiod^1*period)^1*C(noperiod^1)*-1 local function suffixonly(name) return name and lpegmatch(pattern,name) or "" end +local pattern=(noslashes^0*slashes)^0*noperiod^1*((period*C(noperiod^1))^1)*-1+Cc("") +local function suffixesonly(name) + if name then + return lpegmatch(pattern,name) + else + return "" + end +end file.pathpart=pathpart file.basename=basename file.nameonly=nameonly file.suffixonly=suffixonly file.suffix=suffixonly +file.suffixesonly=suffixesonly +file.suffixes=suffixesonly file.dirname=pathpart file.extname=suffixonly local drive=C(R("az","AZ"))*colon @@ -2929,7 +2957,11 @@ function file.splitname(str,splitdrive) end end function file.splitbase(str) - return str and lpegmatch(pattern_d,str) + if str then + return lpegmatch(pattern_d,str) + else + return "",str + end end function file.nametotable(str,splitdrive) if str then @@ -3178,6 +3210,67 @@ function file.strip(name,dir) return a~="" and a or name end end +function lfs.mkdirs(path) + local full="" + for sub in gmatch(path,"(/*[^\\/]+)") do + full=full..sub + lfs.mkdir(full) + end +end + + +end -- of closure + +do -- create closure to overcome 200 locals limit + +package.loaded["l-gzip"] = package.loaded["l-gzip"] or true + +-- original size: 1211, stripped down to: 1002 + +if not modules then modules={} end modules ['l-gzip']={ + version=1.001, + author="Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright="PRAGMA ADE / ConTeXt Development Team", + license="see context related readme files" +} +if not gzip then + return +end +local suffix,suffixes=file.suffix,file.suffixes +function gzip.load(filename) + local f=io.open(filename,"rb") + if not f then + elseif suffix(filename)=="gz" then + f:close() + local g=gzip.open(filename,"rb") + if g then + local str=g:read("*all") + g:close() + return str + end + else + local str=f:read("*all") + f:close() + return str + end +end +function gzip.save(filename,data) + if suffix(filename)~="gz" then + filename=filename..".gz" + end + local f=io.open(filename,"wb") + if f then + local s=zlib.compress(data or "",9,nil,15+16) + f:write(s) + f:close() + return #s + end +end +function gzip.suffix(filename) + local suffix,extra=suffixes(filename) + local gzipped=extra=="gz" + return suffix,gzipped +end end -- of closure @@ -4932,7 +5025,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-tab"] = package.loaded["util-tab"] or true --- original size: 14491, stripped down to: 8512 +-- original size: 14510, stripped down to: 8531 if not modules then modules={} end modules ['util-tab']={ version=1.001, @@ -5210,9 +5303,9 @@ function table.deserialize(str) end return code end -function table.load(filename) +function table.load(filename,loader) if filename then - local t=io.loaddata(filename) + local t=(loader or io.loaddata)(filename) if t and t~="" then t=load(t) if type(t)=="function" then @@ -5450,7 +5543,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-prs"] = package.loaded["util-prs"] or true --- original size: 16976, stripped down to: 12143 +-- original size: 17827, stripped down to: 12722 if not modules then modules={} end modules ['util-prs']={ version=1.001, @@ -5520,7 +5613,9 @@ patterns.settings_to_hash_a=pattern_a_s patterns.settings_to_hash_b=pattern_b_s patterns.settings_to_hash_c=pattern_c_s function parsers.make_settings_to_hash_pattern(set,how) - if how=="strict" then + if type(str)=="table" then + return set + elseif how=="strict" then return (pattern_c/set)^1 elseif how=="tolerant" then return (pattern_b/set)^1 @@ -5529,7 +5624,16 @@ function parsers.make_settings_to_hash_pattern(set,how) end end function parsers.settings_to_hash(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_a_s,str) return hash @@ -5538,7 +5642,16 @@ function parsers.settings_to_hash(str,existing) end end function parsers.settings_to_hash_tolerant(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_b_s,str) return hash @@ -5547,7 +5660,16 @@ function parsers.settings_to_hash_tolerant(str,existing) end end function parsers.settings_to_hash_strict(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_c_s,str) return next(hash) and hash @@ -5560,7 +5682,9 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm local pattern=spaces*Ct(value*(separator*value)^0) patterns.settings_to_array=pattern function parsers.settings_to_array(str,strict) - if not str or str=="" then + if type(str)=="table" then + return str + elseif not str or str=="" then return {} elseif strict then if find(str,"{") then @@ -5712,8 +5836,7 @@ local escape=P('\\') local separator=S(' ,') local key=C((1-equal)^1) local value=dquote*C((1-dquote-escape*dquote)^0)*dquote -local pattern=Cf(Ct("")*Cg(key*equal*value)*separator^0,rawset)^0*P(-1) -patterns.keq_to_hash_c=pattern +local pattern=Cf(Ct("")*(Cg(key*equal*value)*separator^0)^1,rawset)^0*P(-1) function parsers.keq_to_hash(str) if str and str~="" then return lpegmatch(pattern,str) @@ -6262,7 +6385,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 21920, stripped down to: 14287 +-- original size: 21914, stripped down to: 14287 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -14557,7 +14680,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-con"] = package.loaded["data-con"] or true --- original size: 4940, stripped down to: 3580 +-- original size: 5010, stripped down to: 3588 if not modules then modules={} end modules ['data-con']={ version=1.100, @@ -14666,7 +14789,7 @@ function containers.content(container,name) return container.storage[name] end function containers.cleanname(name) - return (gsub(lower(name),"[^%w%d]+","-")) + return (gsub(lower(name),"[^%w\128-\255]+","-")) end @@ -15559,7 +15682,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lib"] = package.loaded["util-lib"] or true --- original size: 11094, stripped down to: 5516 +-- original size: 11136, stripped down to: 5549 if not modules then modules={} end modules ['util-lib']={ version=1.001, @@ -15639,10 +15762,10 @@ local function requireswiglib(required,version) end end if trace_swiglib then - report_swiglib("checking clib paths") + report_swiglib("checking lib paths") end - package.extraclibpath(environment.ownpath) - local paths=package.clibpaths() + package.extralibpath(environment.ownpath) + local paths=package.libpaths() for i=1,#paths do local found=check(lfs.isfile) if found and (not checkpattern or find(found,checkpattern)) then @@ -15714,7 +15837,9 @@ function swiglib(name,version) local library=swiglibs[name] if not library then statistics.starttiming(swiglibs) - report_swiglib("loading %a",name) + if trace_swiglib then + report_swiglib("loading %a",name) + end library=requireswiglib("swiglib."..name,version) swiglibs[name]=library statistics.stoptiming(swiglibs) @@ -15969,10 +16094,10 @@ end 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-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 +-- 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 : 666608 --- stripped bytes : 244185 +-- original bytes : 670212 +-- stripped bytes : 245255 -- end library merge @@ -16006,6 +16131,7 @@ local ownlibs = { -- order can be made better 'l-set.lua', 'l-os.lua', 'l-file.lua', + 'l-gzip.lua', 'l-md5.lua', 'l-url.lua', 'l-dir.lua', @@ -17281,6 +17407,8 @@ if os.type ~= "windows" then texio.write("\n") -- is this still valid? end -if ok == false then ok = 1 elseif ok == true then ok = 0 end +if ok == false then ok = 1 elseif ok == true or ok == nil then ok = 0 end + +-- os.exit(ok,true) -- true forces a cleanup in 5.2+ -os.exit(ok,true) -- true forces a cleanup in 5.2+ +os.exit(ok) -- true forces a cleanup in 5.2+ but reports a wrong number then diff --git a/Master/texmf-dist/scripts/context/stubs/unix/mtxrun b/Master/texmf-dist/scripts/context/stubs/unix/mtxrun index b06cd695519..d07dfc9a7a1 100755 --- a/Master/texmf-dist/scripts/context/stubs/unix/mtxrun +++ b/Master/texmf-dist/scripts/context/stubs/unix/mtxrun @@ -144,7 +144,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-package"] = package.loaded["l-package"] or true --- original size: 9341, stripped down to: 6815 +-- original size: 9893, stripped down to: 7253 if not modules then modules={} end modules ['l-package']={ version=1.001, @@ -168,16 +168,17 @@ local pattern=Cs((((1-S("\\/"))^0*(S("\\/")^1/"/"))^0*(P(".")^1/"/"+P(1))^1)*-1) local function lualibfile(name) return lpegmatch(pattern,name) or name end +local offset=luarocks and 1 or 0 local helpers=package.helpers or { cleanpath=cleanpath, lualibfile=lualibfile, trace=false, report=function(...) print(format(...)) end, builtin={ - ["preload table"]=searchers[1], - ["path specification"]=searchers[2], - ["cpath specification"]=searchers[3], - ["all in one fallback"]=searchers[4], + ["preload table"]=searchers[1+offset], + ["path specification"]=searchers[2+offset], + ["cpath specification"]=searchers[3+offset], + ["all in one fallback"]=searchers[4+offset], }, methods={}, sequence={ @@ -358,6 +359,8 @@ methods["not loaded"]=function(name) return nil end local level=0 +local used={} +helpers.traceused=false function helpers.loaded(name) local sequence=helpers.sequence level=level+1 @@ -371,6 +374,9 @@ function helpers.loaded(name) if helpers.trace then helpers.report("%s, level '%s', method '%s', name '%s'","found",level,method,name) end + if helpers.traceused then + used[#used+1]={ level=level,name=name } + end level=level-1 return result,rest end @@ -378,6 +384,18 @@ function helpers.loaded(name) level=level-1 return nil end +function helpers.showused() + local n=#used + if n>0 then + helpers.report("%s libraries loaded:",n) + helpers.report() + for i=1,n do + local u=used[i] + helpers.report("%i %a",u.level,u.name) + end + helpers.report() + end +end function helpers.unload(name) if helpers.trace then if package.loaded[name] then @@ -2825,7 +2843,7 @@ do -- create closure to overcome 200 locals limit package.loaded["l-file"] = package.loaded["l-file"] or true --- original size: 16912, stripped down to: 9198 +-- original size: 17777, stripped down to: 9653 if not modules then modules={} end modules ['l-file']={ version=1.001, @@ -2869,7 +2887,7 @@ elseif not lfs.isfile then end end local insert,concat=table.insert,table.concat -local match,find=string.match,string.find +local match,find,gmatch=string.match,string.find,string.gmatch local lpegmatch=lpeg.match local getcurrentdir,attributes=lfs.currentdir,lfs.attributes local checkedsplit=string.checkedsplit @@ -2900,11 +2918,21 @@ local pattern=(noslashes^0*slashes)^0*(noperiod^1*period)^1*C(noperiod^1)*-1 local function suffixonly(name) return name and lpegmatch(pattern,name) or "" end +local pattern=(noslashes^0*slashes)^0*noperiod^1*((period*C(noperiod^1))^1)*-1+Cc("") +local function suffixesonly(name) + if name then + return lpegmatch(pattern,name) + else + return "" + end +end file.pathpart=pathpart file.basename=basename file.nameonly=nameonly file.suffixonly=suffixonly file.suffix=suffixonly +file.suffixesonly=suffixesonly +file.suffixes=suffixesonly file.dirname=pathpart file.extname=suffixonly local drive=C(R("az","AZ"))*colon @@ -2929,7 +2957,11 @@ function file.splitname(str,splitdrive) end end function file.splitbase(str) - return str and lpegmatch(pattern_d,str) + if str then + return lpegmatch(pattern_d,str) + else + return "",str + end end function file.nametotable(str,splitdrive) if str then @@ -3178,6 +3210,67 @@ function file.strip(name,dir) return a~="" and a or name end end +function lfs.mkdirs(path) + local full="" + for sub in gmatch(path,"(/*[^\\/]+)") do + full=full..sub + lfs.mkdir(full) + end +end + + +end -- of closure + +do -- create closure to overcome 200 locals limit + +package.loaded["l-gzip"] = package.loaded["l-gzip"] or true + +-- original size: 1211, stripped down to: 1002 + +if not modules then modules={} end modules ['l-gzip']={ + version=1.001, + author="Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright="PRAGMA ADE / ConTeXt Development Team", + license="see context related readme files" +} +if not gzip then + return +end +local suffix,suffixes=file.suffix,file.suffixes +function gzip.load(filename) + local f=io.open(filename,"rb") + if not f then + elseif suffix(filename)=="gz" then + f:close() + local g=gzip.open(filename,"rb") + if g then + local str=g:read("*all") + g:close() + return str + end + else + local str=f:read("*all") + f:close() + return str + end +end +function gzip.save(filename,data) + if suffix(filename)~="gz" then + filename=filename..".gz" + end + local f=io.open(filename,"wb") + if f then + local s=zlib.compress(data or "",9,nil,15+16) + f:write(s) + f:close() + return #s + end +end +function gzip.suffix(filename) + local suffix,extra=suffixes(filename) + local gzipped=extra=="gz" + return suffix,gzipped +end end -- of closure @@ -4932,7 +5025,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-tab"] = package.loaded["util-tab"] or true --- original size: 14491, stripped down to: 8512 +-- original size: 14510, stripped down to: 8531 if not modules then modules={} end modules ['util-tab']={ version=1.001, @@ -5210,9 +5303,9 @@ function table.deserialize(str) end return code end -function table.load(filename) +function table.load(filename,loader) if filename then - local t=io.loaddata(filename) + local t=(loader or io.loaddata)(filename) if t and t~="" then t=load(t) if type(t)=="function" then @@ -5450,7 +5543,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-prs"] = package.loaded["util-prs"] or true --- original size: 16976, stripped down to: 12143 +-- original size: 17827, stripped down to: 12722 if not modules then modules={} end modules ['util-prs']={ version=1.001, @@ -5520,7 +5613,9 @@ patterns.settings_to_hash_a=pattern_a_s patterns.settings_to_hash_b=pattern_b_s patterns.settings_to_hash_c=pattern_c_s function parsers.make_settings_to_hash_pattern(set,how) - if how=="strict" then + if type(str)=="table" then + return set + elseif how=="strict" then return (pattern_c/set)^1 elseif how=="tolerant" then return (pattern_b/set)^1 @@ -5529,7 +5624,16 @@ function parsers.make_settings_to_hash_pattern(set,how) end end function parsers.settings_to_hash(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_a_s,str) return hash @@ -5538,7 +5642,16 @@ function parsers.settings_to_hash(str,existing) end end function parsers.settings_to_hash_tolerant(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_b_s,str) return hash @@ -5547,7 +5660,16 @@ function parsers.settings_to_hash_tolerant(str,existing) end end function parsers.settings_to_hash_strict(str,existing) - if str and str~="" then + if type(str)=="table" then + if existing then + for k,v in next,str do + existing[k]=v + end + return exiting + else + return str + end + elseif str and str~="" then hash=existing or {} lpegmatch(pattern_c_s,str) return next(hash) and hash @@ -5560,7 +5682,9 @@ local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C((nestedbraces+(1-comm local pattern=spaces*Ct(value*(separator*value)^0) patterns.settings_to_array=pattern function parsers.settings_to_array(str,strict) - if not str or str=="" then + if type(str)=="table" then + return str + elseif not str or str=="" then return {} elseif strict then if find(str,"{") then @@ -5712,8 +5836,7 @@ local escape=P('\\') local separator=S(' ,') local key=C((1-equal)^1) local value=dquote*C((1-dquote-escape*dquote)^0)*dquote -local pattern=Cf(Ct("")*Cg(key*equal*value)*separator^0,rawset)^0*P(-1) -patterns.keq_to_hash_c=pattern +local pattern=Cf(Ct("")*(Cg(key*equal*value)*separator^0)^1,rawset)^0*P(-1) function parsers.keq_to_hash(str) if str and str~="" then return lpegmatch(pattern,str) @@ -6262,7 +6385,7 @@ do -- create closure to overcome 200 locals limit package.loaded["trac-log"] = package.loaded["trac-log"] or true --- original size: 21920, stripped down to: 14287 +-- original size: 21914, stripped down to: 14287 if not modules then modules={} end modules ['trac-log']={ version=1.001, @@ -14557,7 +14680,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-con"] = package.loaded["data-con"] or true --- original size: 4940, stripped down to: 3580 +-- original size: 5010, stripped down to: 3588 if not modules then modules={} end modules ['data-con']={ version=1.100, @@ -14666,7 +14789,7 @@ function containers.content(container,name) return container.storage[name] end function containers.cleanname(name) - return (gsub(lower(name),"[^%w%d]+","-")) + return (gsub(lower(name),"[^%w\128-\255]+","-")) end @@ -15559,7 +15682,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-lib"] = package.loaded["util-lib"] or true --- original size: 11094, stripped down to: 5516 +-- original size: 11136, stripped down to: 5549 if not modules then modules={} end modules ['util-lib']={ version=1.001, @@ -15639,10 +15762,10 @@ local function requireswiglib(required,version) end end if trace_swiglib then - report_swiglib("checking clib paths") + report_swiglib("checking lib paths") end - package.extraclibpath(environment.ownpath) - local paths=package.clibpaths() + package.extralibpath(environment.ownpath) + local paths=package.libpaths() for i=1,#paths do local found=check(lfs.isfile) if found and (not checkpattern or find(found,checkpattern)) then @@ -15714,7 +15837,9 @@ function swiglib(name,version) local library=swiglibs[name] if not library then statistics.starttiming(swiglibs) - report_swiglib("loading %a",name) + if trace_swiglib then + report_swiglib("loading %a",name) + end library=requireswiglib("swiglib."..name,version) swiglibs[name]=library statistics.stoptiming(swiglibs) @@ -15969,10 +16094,10 @@ end 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-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 +-- 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 : 666608 --- stripped bytes : 244185 +-- original bytes : 670212 +-- stripped bytes : 245255 -- end library merge @@ -16006,6 +16131,7 @@ local ownlibs = { -- order can be made better 'l-set.lua', 'l-os.lua', 'l-file.lua', + 'l-gzip.lua', 'l-md5.lua', 'l-url.lua', 'l-dir.lua', @@ -17281,6 +17407,8 @@ if os.type ~= "windows" then texio.write("\n") -- is this still valid? end -if ok == false then ok = 1 elseif ok == true then ok = 0 end +if ok == false then ok = 1 elseif ok == true or ok == nil then ok = 0 end + +-- os.exit(ok,true) -- true forces a cleanup in 5.2+ -os.exit(ok,true) -- true forces a cleanup in 5.2+ +os.exit(ok) -- true forces a cleanup in 5.2+ but reports a wrong number then |