diff options
21 files changed, 238 insertions, 104 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 3045b6866..f65c8c0ac 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -2962,6 +2962,11 @@ end file.isreadable = file.is_readable -- depricated file.iswritable = file.is_writable -- depricated +function file.size(name) + local a = attributes(name) + return a and a.size or 0 +end + -- todo: lpeg \\ / .. does not save much local checkedsplit = string.checkedsplit @@ -4877,6 +4882,7 @@ utilities.report = logs and logs.reporter("system") or print local tracestripping = false local forcestupidcompile = true luautilities.stripcode = true +luautilities.alwaysstripcode = false -- saves 1 meg on 7 meg compressed format file (2012.08.12) luautilities.nofstrippedchunks = 0 luautilities.nofstrippedbytes = 0 @@ -4962,7 +4968,7 @@ end -- ... end of borrowed code. local function strippedbytecode(code,forcestrip,name) - if forcestrip and luautilities.stripcode then + if (forcestrip and luautilities.stripcode) or luautilities.alwaysstripcode then return strip_code_pc(code,name) else return code, 0 @@ -4972,8 +4978,16 @@ end luautilities.stripbytecode = strip_code_pc luautilities.strippedbytecode = strippedbytecode +local function fatalerror(name) + utilities.report(format("fatal error in %q",name or "unknown")) +end + +-- quite subtle ... doing this wrong incidentally can give more bytes + + function luautilities.loadedluacode(fullname,forcestrip,name) -- quite subtle ... doing this wrong incidentally can give more bytes + name = name or fullname local code = loadfile(fullname) if code then code() @@ -4983,34 +4997,45 @@ function luautilities.loadedluacode(fullname,forcestrip,name) forcestrip = forcestrip(fullname) end if forcestrip then - local code, n = strip_code_pc(dump(code,name or fullname)) + local code, n = strip_code_pc(dump(code,name)) return loadstring(code), n + elseif luautilities.alwaysstripcode then + return loadstring(strip_code_pc(dump(code),name)) else return code, 0 end + elseif luautilities.alwaysstripcode then + return loadstring(strip_code_pc(dump(code),name)) else return code, 0 end end -function luautilities.strippedloadstring(str,forcestrip,name) -- better inline - if forcestrip and luautilities.stripcode then - local code, n = strip_code_pc(dump(loadstring(str)),name) - return loadstring(code), n - else - return loadstring(str) +function luautilities.strippedloadstring(code,forcestrip,name) -- not executed + local n = 0 + if (forcestrip and luautilities.stripcode) or luautilities.alwaysstripcode then + code = loadstring(code) + if not code then + fatalerror(name) + end + code, n = strip_code_pc(dump(code),name) end + return loadstring(code), n end local function stupidcompile(luafile,lucfile,strip) - local data = io.loaddata(luafile) - if data and data ~= "" then - data = dump(loadstring(data)) + local code = io.loaddata(luafile) + if code and code ~= "" then + code = loadstring(code) + if not code then + fatalerror() + end + code = dump(code) if strip then - data = strippedbytecode(data,true,luafile) -- last one is reported + code = strippedbytecode(code,true,luafile) -- last one is reported end - if data and data ~= "" then - io.savedata(lucfile,data) + if code and code ~= "" then + io.savedata(lucfile,code) end end end diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 3045b6866..f65c8c0ac 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -2962,6 +2962,11 @@ end file.isreadable = file.is_readable -- depricated file.iswritable = file.is_writable -- depricated +function file.size(name) + local a = attributes(name) + return a and a.size or 0 +end + -- todo: lpeg \\ / .. does not save much local checkedsplit = string.checkedsplit @@ -4877,6 +4882,7 @@ utilities.report = logs and logs.reporter("system") or print local tracestripping = false local forcestupidcompile = true luautilities.stripcode = true +luautilities.alwaysstripcode = false -- saves 1 meg on 7 meg compressed format file (2012.08.12) luautilities.nofstrippedchunks = 0 luautilities.nofstrippedbytes = 0 @@ -4962,7 +4968,7 @@ end -- ... end of borrowed code. local function strippedbytecode(code,forcestrip,name) - if forcestrip and luautilities.stripcode then + if (forcestrip and luautilities.stripcode) or luautilities.alwaysstripcode then return strip_code_pc(code,name) else return code, 0 @@ -4972,8 +4978,16 @@ end luautilities.stripbytecode = strip_code_pc luautilities.strippedbytecode = strippedbytecode +local function fatalerror(name) + utilities.report(format("fatal error in %q",name or "unknown")) +end + +-- quite subtle ... doing this wrong incidentally can give more bytes + + function luautilities.loadedluacode(fullname,forcestrip,name) -- quite subtle ... doing this wrong incidentally can give more bytes + name = name or fullname local code = loadfile(fullname) if code then code() @@ -4983,34 +4997,45 @@ function luautilities.loadedluacode(fullname,forcestrip,name) forcestrip = forcestrip(fullname) end if forcestrip then - local code, n = strip_code_pc(dump(code,name or fullname)) + local code, n = strip_code_pc(dump(code,name)) return loadstring(code), n + elseif luautilities.alwaysstripcode then + return loadstring(strip_code_pc(dump(code),name)) else return code, 0 end + elseif luautilities.alwaysstripcode then + return loadstring(strip_code_pc(dump(code),name)) else return code, 0 end end -function luautilities.strippedloadstring(str,forcestrip,name) -- better inline - if forcestrip and luautilities.stripcode then - local code, n = strip_code_pc(dump(loadstring(str)),name) - return loadstring(code), n - else - return loadstring(str) +function luautilities.strippedloadstring(code,forcestrip,name) -- not executed + local n = 0 + if (forcestrip and luautilities.stripcode) or luautilities.alwaysstripcode then + code = loadstring(code) + if not code then + fatalerror(name) + end + code, n = strip_code_pc(dump(code),name) end + return loadstring(code), n end local function stupidcompile(luafile,lucfile,strip) - local data = io.loaddata(luafile) - if data and data ~= "" then - data = dump(loadstring(data)) + local code = io.loaddata(luafile) + if code and code ~= "" then + code = loadstring(code) + if not code then + fatalerror() + end + code = dump(code) if strip then - data = strippedbytecode(data,true,luafile) -- last one is reported + code = strippedbytecode(code,true,luafile) -- last one is reported end - if data and data ~= "" then - io.savedata(lucfile,data) + if code and code ~= "" then + io.savedata(lucfile,code) end end end diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 3045b6866..f65c8c0ac 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -2962,6 +2962,11 @@ end file.isreadable = file.is_readable -- depricated file.iswritable = file.is_writable -- depricated +function file.size(name) + local a = attributes(name) + return a and a.size or 0 +end + -- todo: lpeg \\ / .. does not save much local checkedsplit = string.checkedsplit @@ -4877,6 +4882,7 @@ utilities.report = logs and logs.reporter("system") or print local tracestripping = false local forcestupidcompile = true luautilities.stripcode = true +luautilities.alwaysstripcode = false -- saves 1 meg on 7 meg compressed format file (2012.08.12) luautilities.nofstrippedchunks = 0 luautilities.nofstrippedbytes = 0 @@ -4962,7 +4968,7 @@ end -- ... end of borrowed code. local function strippedbytecode(code,forcestrip,name) - if forcestrip and luautilities.stripcode then + if (forcestrip and luautilities.stripcode) or luautilities.alwaysstripcode then return strip_code_pc(code,name) else return code, 0 @@ -4972,8 +4978,16 @@ end luautilities.stripbytecode = strip_code_pc luautilities.strippedbytecode = strippedbytecode +local function fatalerror(name) + utilities.report(format("fatal error in %q",name or "unknown")) +end + +-- quite subtle ... doing this wrong incidentally can give more bytes + + function luautilities.loadedluacode(fullname,forcestrip,name) -- quite subtle ... doing this wrong incidentally can give more bytes + name = name or fullname local code = loadfile(fullname) if code then code() @@ -4983,34 +4997,45 @@ function luautilities.loadedluacode(fullname,forcestrip,name) forcestrip = forcestrip(fullname) end if forcestrip then - local code, n = strip_code_pc(dump(code,name or fullname)) + local code, n = strip_code_pc(dump(code,name)) return loadstring(code), n + elseif luautilities.alwaysstripcode then + return loadstring(strip_code_pc(dump(code),name)) else return code, 0 end + elseif luautilities.alwaysstripcode then + return loadstring(strip_code_pc(dump(code),name)) else return code, 0 end end -function luautilities.strippedloadstring(str,forcestrip,name) -- better inline - if forcestrip and luautilities.stripcode then - local code, n = strip_code_pc(dump(loadstring(str)),name) - return loadstring(code), n - else - return loadstring(str) +function luautilities.strippedloadstring(code,forcestrip,name) -- not executed + local n = 0 + if (forcestrip and luautilities.stripcode) or luautilities.alwaysstripcode then + code = loadstring(code) + if not code then + fatalerror(name) + end + code, n = strip_code_pc(dump(code),name) end + return loadstring(code), n end local function stupidcompile(luafile,lucfile,strip) - local data = io.loaddata(luafile) - if data and data ~= "" then - data = dump(loadstring(data)) + local code = io.loaddata(luafile) + if code and code ~= "" then + code = loadstring(code) + if not code then + fatalerror() + end + code = dump(code) if strip then - data = strippedbytecode(data,true,luafile) -- last one is reported + code = strippedbytecode(code,true,luafile) -- last one is reported end - if data and data ~= "" then - io.savedata(lucfile,data) + if code and code ~= "" then + io.savedata(lucfile,code) end end end diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index 5b5781531..f537b3936 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -68,16 +68,17 @@ {\ctxcommand{setxmpfile("\backendparameter{xmpfile}")}}% \to \everysetupbackend +% \doifsomething{\backendparameter\c!format} .. at the lua end + \appendtoks - \doifsomething{\backendparameter\c!format} - {\ctxcommand{setformat { + \ctxcommand{setformat { format = "\backendparameter\c!format", level = "\backendparameter\c!level", option = "\backendparameter\c!option", profile = "\backendparameter\c!profile", intent = "\backendparameter\c!intent", file = "\backendparameter\c!file", - }}}% + }}% \to \everysetupbackend %D For the moment we keep these. diff --git a/tex/context/base/char-map.lua b/tex/context/base/char-map.lua index 93a307a97..749da5289 100644 --- a/tex/context/base/char-map.lua +++ b/tex/context/base/char-map.lua @@ -3,7 +3,7 @@ if not modules then modules = { } end modules ['char-map'] = { comment = "companion to char-ini.mkiv", author = "Hans Hagen & Arthur Reutenauer", copyright = "PRAGMA ADE / ConTeXt Development Team", - license = "see context related readme files" + license = "see context related readme files", dataonly = true, } diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index cf0b9bc4f..90476aa22 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.08.10 19:40} +\newcontextversion{2012.08.11 11:43} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index c1eb31960..91f64ab11 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.08.10 19:40} +\newcontextversion{2012.08.11 11:43} %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-version.pdf b/tex/context/base/context-version.pdf Binary files differindex c2b73175e..0622580ce 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 738fa1b3f..c28523396 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index b173fe811..12f009b90 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.08.10 19:40} +\edef\contextversion{2012.08.11 11:43} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 6ee088294..6f5adf2f7 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.08.10 19:40} +\edef\contextversion{2012.08.11 11:43} %D For those who want to use this: diff --git a/tex/context/base/core-sys.lua b/tex/context/base/core-sys.lua index 703bcac0f..ddcb6e938 100644 --- a/tex/context/base/core-sys.lua +++ b/tex/context/base/core-sys.lua @@ -22,5 +22,9 @@ end statistics.register("result saved in file", function() -- suffix will be fetched from backend - return format( "%s.%s", environment.outputfilename, (tex.pdfoutput>0 and "pdf") or "dvi") + if tex.pdfoutput > 0 then + return format( "%s.%s, compresslevel %s, objectcompreslevel %s", environment.outputfilename, "pdf", tex.pdfcompresslevel, tex.pdfobjcompresslevel) + else + return format( "%s.%s", environment.outputfilename, "dvi") -- hard to imagine + end end) diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua index d7b5b7623..bea4ef0aa 100644 --- a/tex/context/base/l-file.lua +++ b/tex/context/base/l-file.lua @@ -198,6 +198,11 @@ end file.isreadable = file.is_readable -- depricated file.iswritable = file.is_writable -- depricated +function file.size(name) + local a = attributes(name) + return a and a.size or 0 +end + -- todo: lpeg \\ / .. does not save much local checkedsplit = string.checkedsplit diff --git a/tex/context/base/lpdf-fmt.lua b/tex/context/base/lpdf-fmt.lua index 3ae41b4f6..626e66d3c 100644 --- a/tex/context/base/lpdf-fmt.lua +++ b/tex/context/base/lpdf-fmt.lua @@ -36,6 +36,8 @@ local pdfstring = lpdf.string local pdfverbose = lpdf.verbose local pdfflushstreamfileobject = lpdf.flushstreamfileobject +local texset = tex.set -- we could make tex.setglobal + local addtoinfo = lpdf.addtoinfo local injectxmpinfo = lpdf.injectxmpinfo local insertxmpinfo = lpdf.insertxmpinfo @@ -625,15 +627,16 @@ end lpdf.registerdocumentfinalizer(flushoutputintents,2,"output intents") function codeinjections.setformat(s) - local format, level, profile, intent, option, filename = - s.format or "", s.level or "", s.profile or "", s.intent or "", s.option or "", s.file or "" - if format == "" then - -- we ignore this as we hook it in \everysetupbackend - else + local format = s.format or "" + local level = tonumber(s.level) + local profile = s.profile or "" + local option = s.option or "" + local filename = s.file or "" + if format ~= "" then local spec = formats[lower(format)] if spec then - formatspecification, formatname = spec, spec.format_name - level = level and tonumber(level) + formatspecification = spec + formatname = spec.format_name report_backend("setting format to '%s'",formatname) local xmp_file = formatspecification.xmp_file or "" if xmp_file == "" then @@ -641,13 +644,20 @@ function codeinjections.setformat(s) else codeinjections.setxmpfile(xmp_file) end - local pdf_version, inject_metadata = spec.pdf_version * 10, spec.inject_metadata - local majorversion, minorversion = math.div(pdf_version,10), math.mod(pdf_version,10) + if not level then + level = 3 -- good compromise, default anyway + end + local pdf_version = spec.pdf_version * 10 + local inject_metadata = spec.inject_metadata + local majorversion = math.div(pdf_version,10) + local minorversion = math.mod(pdf_version,10) local objectcompression = spec.object_compression and pdf_version >= 15 local compresslevel = level or tex.pdfcompresslevel -- keep default local objectcompresslevel = (objectcompression and (level or tex.pdfobjcompresslevel)) or 0 - tex.pdfcompresslevel, tex.pdfobjcompresslevel = compresslevel, objectcompresslevel - tex.pdfmajorversion, tex.pdfminorversion = majorversion, minorversion + texset("global","pdfcompresslevel",compresslevel) + texset("global","pdfobjcompresslevel",objectcompresslevel) + texset("global","pdfmajorversion",majorversion) + texset("global","pdfminorversion",minorversion) if objectcompression then report_backend("forcing pdf version %s.%s, compression level %s, object compression level %s", majorversion,minorversion,compresslevel,objectcompresslevel) @@ -704,6 +714,11 @@ function codeinjections.setformat(s) else report_backend("error, format '%s' is not supported",format) end + elseif level then + texset("global","pdfcompresslevel",level) + texset("global","pdfobjcompresslevel",level) + else + -- we ignore this as we hook it in \everysetupbackend end end diff --git a/tex/context/base/m-spreadsheet.lua b/tex/context/base/m-spreadsheet.lua index 049154f27..4986079d5 100644 --- a/tex/context/base/m-spreadsheet.lua +++ b/tex/context/base/m-spreadsheet.lua @@ -151,11 +151,21 @@ local template = [[ -- to be considered: a weak cache +local function propername(name) + if name ~= "" then + return name + elseif current ~= "" then + return current + else + return defaultname + end +end + local function execute(name,r,c,str) -- if name == "" then name = current if name == "" then name = defaultname end end str = lpegmatch(pattern,str,1,name) str = format(template,name,str) - local result = loadstring(str) + local result = loadstring(str) -- utilities.lua.strippedloadstring(str,true) -- when tracing result = result and result() or 0 data[name].data[c][r] = result if type(result) == "function" then @@ -166,12 +176,12 @@ local function execute(name,r,c,str) end function spreadsheets.set(name,r,c,str) - if name == "" then name = current if name == "" then name = defaultname end end + name = propername(name) execute(name,r,c,str) end function spreadsheets.get(name,r,c,str) - if name == "" then name = current if name == "" then name = defaultname end end + name = propername(name) local dname = data[name] if not str or str == "" then context(dname.data[c][r] or 0) @@ -198,12 +208,12 @@ function spreadsheets.get(name,r,c,str) end function spreadsheets.doifelsecell(name,r,c) - if name == "" then name = current if name == "" then name = defaultname end end + name = propername(name) local d = data[name] commands.doifelse(d and d.data[c][r]) end function spreadsheets.show(name) - if name == "" then name = current if name == "" then name = defaultname end end - table.print(data[name].data,name) + name = propername(name) + inspect(data[name].data,name) end diff --git a/tex/context/base/m-spreadsheet.mkiv b/tex/context/base/m-spreadsheet.mkiv index e065ac7e8..9da9ba9b1 100644 --- a/tex/context/base/m-spreadsheet.mkiv +++ b/tex/context/base/m-spreadsheet.mkiv @@ -37,15 +37,15 @@ \c!split=\v!no] \unexpanded\def\resetspreadsheet - {\dosingleempty\doresetspreadsheet} + {\dosingleempty\module_spreadsheet_reset} -\unexpanded\def\doresetspreadsheet[#1]% +\unexpanded\def\module_spreadsheet_reset[#1]% {\ctxlua{moduledata.spreadsheets.reset("#1")}} \unexpanded\def\startspreadsheet - {\dosingleempty\dostartspreadsheet} + {\dosingleempty\module_spreadsheet_start} -\unexpanded\def\dostartspreadsheet[#1]% +\unexpanded\def\module_spreadsheet_start[#1]% {\pushmacro\currentspreadsheet \edef\currentspreadsheet{#1}% \checkspreadsheetparent @@ -62,27 +62,27 @@ \popmacro\currentspreadsheet} \unexpanded\def\showspreadsheet - {\dosingleempty\doshowspreadsheet} + {\dosingleempty\module_spreadsheet_show} -\unexpanded\def\doshowspreadsheet[#1]% +\unexpanded\def\module_spreadsheet_show[#1]% {\ctxlua{moduledata.spreadsheets.show("#1")}} -\unexpanded\def\getspreadsheet - {\dosingleempty\dogetspreadsheet} +\unexpanded\def\setspreadsheet + {\dosingleempty\module_spreadsheet_set} -\unexpanded\def\dosetspreadsheet[#1]#2#3#4% +\unexpanded\def\module_spreadsheet_set[#1]#2#3#4% {\ctxlua{moduledata.spreadsheets.set("#1",\number#2,\number#3,"#4")}} -\unexpanded\def\setspreadsheet - {\dosingleempty\dosetspreadsheet} +\unexpanded\def\getspreadsheet + {\dosingleempty\module_spreadsheet_get} -\unexpanded\def\dogetspreadsheet[#1]#2#3#4% +\unexpanded\def\module_spreadsheet_get[#1]#2#3#4% {\ctxlua{moduledata.spreadsheets.get("#1",\number#2,\number#3,"#4")}} \unexpanded\def\doifelsespreadsheetcell - {\dosingleempty\dodoifelsespreadsheetcell} + {\dosingleempty\module_spreadsheet_doifelse_cell} -\unexpanded\def\dodoifelsespreadsheetcell[#1]#2#3% +\unexpanded\def\module_spreadsheet_doifelse_cell[#1]#2#3% {\ctxlua{moduledata.spreadsheets.doifelsecell("#1","#2","#3")}} \ifdefined\tblrow @@ -97,7 +97,6 @@ \fi - \appendtoks \resetspreadsheet \let\setspr\TABLEsetspreadsheet @@ -105,11 +104,11 @@ \to \everyTABLEpass \unexpanded\def\startspreadsheettable % quick and dirty - {\dosingleempty\dostartspreadsheettable} + {\dosingleempty\module_spreadsheet_start_table} -\unexpanded\def\dostartspreadsheettable[#1]% +\unexpanded\def\module_spreadsheet_start_table[#1]% {\bgroup - \dostartspreadsheet[#1]%% + \module_spreadsheet_start[#1]%% \unexpanded\def\startrow{\bTR}% \unexpanded\def\stoprow {\eTR}% \unexpanded\def\startcell##1\stopcell{\bTD\getspr{##1}\eTD}% diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 16ade95a6..3ef6fd827 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 17bbb0a67..7ff12a5ba 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/typo-scr.mkiv b/tex/context/base/typo-scr.mkiv index 1a6a80d06..7ec6e6f59 100644 --- a/tex/context/base/typo-scr.mkiv +++ b/tex/context/base/typo-scr.mkiv @@ -140,7 +140,7 @@ \edef\currentlowhigh{#1}% \dosingleempty} % #2 -\unexpanded\def\typo_scripts_lowhigh_indeed[#1]#2#3% +\unexpanded\def\typo_scripts_lowhigh_indeed[#1]#2#3% todo: align .. [#1] is compatible hack {\dostarttagged\t!subsup\currentlowhigh \setbox\plusfour\hbox{\typo_scripts_lowhigh_low_high\lower\c!down\t!sub{#2}}% \setbox\plussix \hbox{\typo_scripts_lowhigh_low_high\raise\c!up \t!sup{#3}}% @@ -233,8 +233,8 @@ \dostarttagged\t!subsup\currentlowmidhigh \uselowmidhighstyleandcolor\c!style\c!color \setstrut - \setbox\plustwo \hbox{\strut\dostarttagged\t!sub\empty#2\dostoptagged}% - \setbox\plusfour\hbox{\strut\dostarttagged\t!mid\empty#3\dostoptagged}% inefficient + \setbox\plustwo \hbox{\strut\dostarttagged\t!sub\empty#3\dostoptagged}% + \setbox\plusfour\hbox{\strut\dostarttagged\t!mid\empty#2\dostoptagged}% inefficient \setbox\plussix \hbox{\strut\dostarttagged\t!sup\empty#4\dostoptagged}% \scratchdimen \wd \ifdim\wd\plustwo>\wd\plusfour diff --git a/tex/context/base/util-lua.lua b/tex/context/base/util-lua.lua index 879ce7f79..9e5328044 100644 --- a/tex/context/base/util-lua.lua +++ b/tex/context/base/util-lua.lua @@ -19,6 +19,7 @@ utilities.report = logs and logs.reporter("system") or print local tracestripping = false local forcestupidcompile = true luautilities.stripcode = true +luautilities.alwaysstripcode = false -- saves 1 meg on 7 meg compressed format file (2012.08.12) luautilities.nofstrippedchunks = 0 luautilities.nofstrippedbytes = 0 @@ -104,7 +105,7 @@ end -- ... end of borrowed code. local function strippedbytecode(code,forcestrip,name) - if forcestrip and luautilities.stripcode then + if (forcestrip and luautilities.stripcode) or luautilities.alwaysstripcode then return strip_code_pc(code,name) else return code, 0 @@ -114,8 +115,16 @@ end luautilities.stripbytecode = strip_code_pc luautilities.strippedbytecode = strippedbytecode +local function fatalerror(name) + utilities.report(format("fatal error in %q",name or "unknown")) +end + +-- quite subtle ... doing this wrong incidentally can give more bytes + + function luautilities.loadedluacode(fullname,forcestrip,name) -- quite subtle ... doing this wrong incidentally can give more bytes + name = name or fullname local code = loadfile(fullname) if code then code() @@ -125,34 +134,45 @@ function luautilities.loadedluacode(fullname,forcestrip,name) forcestrip = forcestrip(fullname) end if forcestrip then - local code, n = strip_code_pc(dump(code,name or fullname)) + local code, n = strip_code_pc(dump(code,name)) return loadstring(code), n + elseif luautilities.alwaysstripcode then + return loadstring(strip_code_pc(dump(code),name)) else return code, 0 end + elseif luautilities.alwaysstripcode then + return loadstring(strip_code_pc(dump(code),name)) else return code, 0 end end -function luautilities.strippedloadstring(str,forcestrip,name) -- better inline - if forcestrip and luautilities.stripcode then - local code, n = strip_code_pc(dump(loadstring(str)),name) - return loadstring(code), n - else - return loadstring(str) +function luautilities.strippedloadstring(code,forcestrip,name) -- not executed + local n = 0 + if (forcestrip and luautilities.stripcode) or luautilities.alwaysstripcode then + code = loadstring(code) + if not code then + fatalerror(name) + end + code, n = strip_code_pc(dump(code),name) end + return loadstring(code), n end local function stupidcompile(luafile,lucfile,strip) - local data = io.loaddata(luafile) - if data and data ~= "" then - data = dump(loadstring(data)) + local code = io.loaddata(luafile) + if code and code ~= "" then + code = loadstring(code) + if not code then + fatalerror() + end + code = dump(code) if strip then - data = strippedbytecode(data,true,luafile) -- last one is reported + code = strippedbytecode(code,true,luafile) -- last one is reported end - if data and data ~= "" then - io.savedata(lucfile,data) + if code and code ~= "" then + io.savedata(lucfile,code) end end end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index fb1bba060..81280b892 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 08/10/12 19:40:14 +-- merge date : 08/11/12 11:43:49 do -- begin closure to overcome local limits and interference @@ -2198,6 +2198,11 @@ end file.isreadable = file.is_readable -- depricated file.iswritable = file.is_writable -- depricated +function file.size(name) + local a = attributes(name) + return a and a.size or 0 +end + -- todo: lpeg \\ / .. does not save much local checkedsplit = string.checkedsplit |