diff options
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 37 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 37 | ||||
-rw-r--r-- | scripts/context/stubs/unix/mtxrun | 37 | ||||
-rw-r--r-- | tex/context/base/cldf-ver.lua | 2 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4088 -> 4087 bytes | |||
-rw-r--r-- | tex/context/base/context-version.png | bin | 106517 -> 105941 bytes | |||
-rw-r--r-- | tex/context/base/context.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/m-spreadsheet.lua | 57 | ||||
-rw-r--r-- | tex/context/base/m-spreadsheet.mkiv | 10 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24422 -> 24408 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 190438 -> 190434 bytes | |||
-rw-r--r-- | tex/context/base/status-mkiv.lua | 2 | ||||
-rw-r--r-- | tex/context/base/typo-scr.mkiv | 7 | ||||
-rw-r--r-- | tex/context/base/util-lua.lua | 37 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
18 files changed, 163 insertions, 73 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index f65c8c0ac..4af1453a1 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -4870,18 +4870,18 @@ if not modules then modules = { } end modules ['util-lua'] = { license = "see context related readme files" } -local rep, sub, byte, dump = string.rep, string.sub, string.byte, string.dump -local loadstring, loadfile = loadstring, loadfile +local rep, sub, byte, dump, format = string.rep, string.sub, string.byte, string.dump, string.format +local loadstring, loadfile, type = loadstring, loadfile, type utilities = utilities or {} utilities.lua = utilities.lua or { } local luautilities = utilities.lua -utilities.report = logs and logs.reporter("system") or print +utilities.report = logs and logs.reporter("system") or print -- can be overloaded later local tracestripping = false -local forcestupidcompile = true -luautilities.stripcode = true +local forcestupidcompile = true -- use internal bytecode compiler +luautilities.stripcode = true -- support stripping when asked for luautilities.alwaysstripcode = false -- saves 1 meg on 7 meg compressed format file (2012.08.12) luautilities.nofstrippedchunks = 0 luautilities.nofstrippedbytes = 0 @@ -5025,6 +5025,7 @@ end local function stupidcompile(luafile,lucfile,strip) local code = io.loaddata(luafile) + local n = 0 if code and code ~= "" then code = loadstring(code) if not code then @@ -5032,30 +5033,39 @@ local function stupidcompile(luafile,lucfile,strip) end code = dump(code) if strip then - code = strippedbytecode(code,true,luafile) -- last one is reported + code, n = strippedbytecode(code,true,luafile) -- last one is reported end if code and code ~= "" then io.savedata(lucfile,code) end end + return n end +local luac_normal = "texluac -o %q %q" +local luac_strip = "texluac -s -o %q %q" + function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) -- defaults: cleanup=false strip=true utilities.report("lua: compiling %s into %s",luafile,lucfile) os.remove(lucfile) local done = false + if strip ~= false then + strip = true + end if forcestupidcompile then fallback = true + elseif strip then + done = os.spawn(format(luac_strip, lucfile,luafile)) == 0 else - local command = "-o " .. string.quoted(lucfile) .. " " .. string.quoted(luafile) - if strip ~= false then - command = "-s " .. command - end - done = os.spawn("texluac " .. command) == 0 -- or os.spawn("luac " .. command) == 0 + done = os.spawn(format(luac_normal,lucfile,luafile)) == 0 end if not done and fallback then - utilities.report("lua: dumping %s into %s (unstripped)",luafile,lucfile) - stupidcompile(luafile,lucfile,strip) + local n = stupidcompile(luafile,lucfile,strip) + if n > 0 then + utilities.report("lua: %s dumped into %s (%i bytes stripped)",luafile,lucfile,n) + else + utilities.report("lua: %s dumped into %s (unstripped)",luafile,lucfile) + end cleanup = false -- better see how bad it is end if done and cleanup == true and lfs.isfile(lucfile) and lfs.isfile(luafile) then @@ -5071,7 +5081,6 @@ end - end -- of closure do -- create closure to overcome 200 locals limit diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index f65c8c0ac..4af1453a1 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -4870,18 +4870,18 @@ if not modules then modules = { } end modules ['util-lua'] = { license = "see context related readme files" } -local rep, sub, byte, dump = string.rep, string.sub, string.byte, string.dump -local loadstring, loadfile = loadstring, loadfile +local rep, sub, byte, dump, format = string.rep, string.sub, string.byte, string.dump, string.format +local loadstring, loadfile, type = loadstring, loadfile, type utilities = utilities or {} utilities.lua = utilities.lua or { } local luautilities = utilities.lua -utilities.report = logs and logs.reporter("system") or print +utilities.report = logs and logs.reporter("system") or print -- can be overloaded later local tracestripping = false -local forcestupidcompile = true -luautilities.stripcode = true +local forcestupidcompile = true -- use internal bytecode compiler +luautilities.stripcode = true -- support stripping when asked for luautilities.alwaysstripcode = false -- saves 1 meg on 7 meg compressed format file (2012.08.12) luautilities.nofstrippedchunks = 0 luautilities.nofstrippedbytes = 0 @@ -5025,6 +5025,7 @@ end local function stupidcompile(luafile,lucfile,strip) local code = io.loaddata(luafile) + local n = 0 if code and code ~= "" then code = loadstring(code) if not code then @@ -5032,30 +5033,39 @@ local function stupidcompile(luafile,lucfile,strip) end code = dump(code) if strip then - code = strippedbytecode(code,true,luafile) -- last one is reported + code, n = strippedbytecode(code,true,luafile) -- last one is reported end if code and code ~= "" then io.savedata(lucfile,code) end end + return n end +local luac_normal = "texluac -o %q %q" +local luac_strip = "texluac -s -o %q %q" + function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) -- defaults: cleanup=false strip=true utilities.report("lua: compiling %s into %s",luafile,lucfile) os.remove(lucfile) local done = false + if strip ~= false then + strip = true + end if forcestupidcompile then fallback = true + elseif strip then + done = os.spawn(format(luac_strip, lucfile,luafile)) == 0 else - local command = "-o " .. string.quoted(lucfile) .. " " .. string.quoted(luafile) - if strip ~= false then - command = "-s " .. command - end - done = os.spawn("texluac " .. command) == 0 -- or os.spawn("luac " .. command) == 0 + done = os.spawn(format(luac_normal,lucfile,luafile)) == 0 end if not done and fallback then - utilities.report("lua: dumping %s into %s (unstripped)",luafile,lucfile) - stupidcompile(luafile,lucfile,strip) + local n = stupidcompile(luafile,lucfile,strip) + if n > 0 then + utilities.report("lua: %s dumped into %s (%i bytes stripped)",luafile,lucfile,n) + else + utilities.report("lua: %s dumped into %s (unstripped)",luafile,lucfile) + end cleanup = false -- better see how bad it is end if done and cleanup == true and lfs.isfile(lucfile) and lfs.isfile(luafile) then @@ -5071,7 +5081,6 @@ end - end -- of closure do -- create closure to overcome 200 locals limit diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index f65c8c0ac..4af1453a1 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -4870,18 +4870,18 @@ if not modules then modules = { } end modules ['util-lua'] = { license = "see context related readme files" } -local rep, sub, byte, dump = string.rep, string.sub, string.byte, string.dump -local loadstring, loadfile = loadstring, loadfile +local rep, sub, byte, dump, format = string.rep, string.sub, string.byte, string.dump, string.format +local loadstring, loadfile, type = loadstring, loadfile, type utilities = utilities or {} utilities.lua = utilities.lua or { } local luautilities = utilities.lua -utilities.report = logs and logs.reporter("system") or print +utilities.report = logs and logs.reporter("system") or print -- can be overloaded later local tracestripping = false -local forcestupidcompile = true -luautilities.stripcode = true +local forcestupidcompile = true -- use internal bytecode compiler +luautilities.stripcode = true -- support stripping when asked for luautilities.alwaysstripcode = false -- saves 1 meg on 7 meg compressed format file (2012.08.12) luautilities.nofstrippedchunks = 0 luautilities.nofstrippedbytes = 0 @@ -5025,6 +5025,7 @@ end local function stupidcompile(luafile,lucfile,strip) local code = io.loaddata(luafile) + local n = 0 if code and code ~= "" then code = loadstring(code) if not code then @@ -5032,30 +5033,39 @@ local function stupidcompile(luafile,lucfile,strip) end code = dump(code) if strip then - code = strippedbytecode(code,true,luafile) -- last one is reported + code, n = strippedbytecode(code,true,luafile) -- last one is reported end if code and code ~= "" then io.savedata(lucfile,code) end end + return n end +local luac_normal = "texluac -o %q %q" +local luac_strip = "texluac -s -o %q %q" + function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) -- defaults: cleanup=false strip=true utilities.report("lua: compiling %s into %s",luafile,lucfile) os.remove(lucfile) local done = false + if strip ~= false then + strip = true + end if forcestupidcompile then fallback = true + elseif strip then + done = os.spawn(format(luac_strip, lucfile,luafile)) == 0 else - local command = "-o " .. string.quoted(lucfile) .. " " .. string.quoted(luafile) - if strip ~= false then - command = "-s " .. command - end - done = os.spawn("texluac " .. command) == 0 -- or os.spawn("luac " .. command) == 0 + done = os.spawn(format(luac_normal,lucfile,luafile)) == 0 end if not done and fallback then - utilities.report("lua: dumping %s into %s (unstripped)",luafile,lucfile) - stupidcompile(luafile,lucfile,strip) + local n = stupidcompile(luafile,lucfile,strip) + if n > 0 then + utilities.report("lua: %s dumped into %s (%i bytes stripped)",luafile,lucfile,n) + else + utilities.report("lua: %s dumped into %s (unstripped)",luafile,lucfile) + end cleanup = false -- better see how bad it is end if done and cleanup == true and lfs.isfile(lucfile) and lfs.isfile(luafile) then @@ -5071,7 +5081,6 @@ end - end -- of closure do -- create closure to overcome 200 locals limit diff --git a/tex/context/base/cldf-ver.lua b/tex/context/base/cldf-ver.lua index 9b1b82806..b48fd253a 100644 --- a/tex/context/base/cldf-ver.lua +++ b/tex/context/base/cldf-ver.lua @@ -45,7 +45,7 @@ table .tocontext = t_tocontext string .tocontext = s_tocontext boolean.tocontext = b_tocontext -function tocontext(first,...) +function context.tocontext(first,...) local t = type(first) if t == "string" then s_tocontext(first,...) diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 90476aa22..0d7722073 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.11 11:43} +\newcontextversion{2012.08.11 14:11} %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 91f64ab11..7c64b1d24 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.11 11:43} +\newcontextversion{2012.08.11 14:11} %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 0622580ce..1372d89dd 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 c28523396..67cdddeaa 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 12f009b90..2b6855cbc 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.11 11:43} +\edef\contextversion{2012.08.11 14:11} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 6f5adf2f7..6c12acb10 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.11 11:43} +\edef\contextversion{2012.08.11 14:11} %D For those who want to use this: diff --git a/tex/context/base/m-spreadsheet.lua b/tex/context/base/m-spreadsheet.lua index 4986079d5..7d8fe9e07 100644 --- a/tex/context/base/m-spreadsheet.lua +++ b/tex/context/base/m-spreadsheet.lua @@ -8,6 +8,7 @@ if not modules then modules = { } end modules ['m-spreadsheet'] = { local byte, format, gsub = string.byte, string.format, string.gsub local R, P, C, V, Cs, Cc, Carg, lpegmatch = lpeg.R, lpeg.P, lpeg.C, lpeg.V, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.match +local setmetatable, loadstring, next, tostring, tonumber,rawget = setmetatable, loadstring, next, tostring, tonumber, rawget local context = context @@ -75,7 +76,12 @@ function spreadsheets.reset(name) end function spreadsheets.start(name,s) - if not name or name == "" then name = defaultname end + if not name or name == "" then + name = defaultname + end + if not s then + s = { } + end table.insert(stack,current) current = name if data[current] then @@ -183,7 +189,9 @@ end function spreadsheets.get(name,r,c,str) name = propername(name) local dname = data[name] - if not str or str == "" then + if not dname then + -- nothing + elseif not str or str == "" then context(dname.data[c][r] or 0) else local result = execute(name,r,c,str) @@ -210,10 +218,49 @@ end function spreadsheets.doifelsecell(name,r,c) name = propername(name) local d = data[name] - commands.doifelse(d and d.data[c][r]) + local d = d and d.data + local r = d and rawget(d,r) + local c = r and rawget(r,c) + commands.doifelse(c) end -function spreadsheets.show(name) +local function simplify(name) name = propername(name) - inspect(data[name].data,name) + local data = data[name] + if data then + data = data.data + local temp = { } + for k, v in next, data do + local t = { } + temp[k] = t + for kk, vv in next, v do + if type(vv) == "function" then + t[kk] = "<function>" + else + t[kk] = vv + end + end + end + return temp + end +end + +local function serialize(name) + local s = simplify(name) + if s then + return table.serialize(s,name) + else + return format("<unknown spreadsheet %q>",name) + end +end + +spreadsheets.simplify = simplify +spreadsheets.serialize = serialize + +function spreadsheets.inspect(name) + inspect(serialize(name)) +end + +function spreadsheets.tocontext(name) + context.tocontext(simplify(name)) end diff --git a/tex/context/base/m-spreadsheet.mkiv b/tex/context/base/m-spreadsheet.mkiv index 9da9ba9b1..f4c87d100 100644 --- a/tex/context/base/m-spreadsheet.mkiv +++ b/tex/context/base/m-spreadsheet.mkiv @@ -65,7 +65,13 @@ {\dosingleempty\module_spreadsheet_show} \unexpanded\def\module_spreadsheet_show[#1]% - {\ctxlua{moduledata.spreadsheets.show("#1")}} + {\ctxlua{moduledata.spreadsheets.tocontext("#1")}} + +\unexpanded\def\inspectspreadsheet + {\dosingleempty\module_spreadsheet_inspect} + +\unexpanded\def\module_spreadsheet_inspect[#1]% + {\ctxlua{moduledata.spreadsheets.inspect("#1")}} \unexpanded\def\setspreadsheet {\dosingleempty\module_spreadsheet_set} @@ -83,7 +89,7 @@ {\dosingleempty\module_spreadsheet_doifelse_cell} \unexpanded\def\module_spreadsheet_doifelse_cell[#1]#2#3% - {\ctxlua{moduledata.spreadsheets.doifelsecell("#1","#2","#3")}} + {\ctxlua{moduledata.spreadsheets.doifelsecell("#1",\number#2,\number#3)}} \ifdefined\tblrow diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 3ef6fd827..7e7883e05 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 7ff12a5ba..e9ce17b5b 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index 1a9c6b6a1..75bc521f9 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -4608,7 +4608,7 @@ return { category = "lua", filename = "util-lua", loading = "luat-lib", - status = "todo", + status = "okay", }, { category = "lua", diff --git a/tex/context/base/typo-scr.mkiv b/tex/context/base/typo-scr.mkiv index 7ec6e6f59..50c360924 100644 --- a/tex/context/base/typo-scr.mkiv +++ b/tex/context/base/typo-scr.mkiv @@ -233,9 +233,9 @@ \dostarttagged\t!subsup\currentlowmidhigh \uselowmidhighstyleandcolor\c!style\c!color \setstrut - \setbox\plustwo \hbox{\strut\dostarttagged\t!sub\empty#3\dostoptagged}% + \setbox\plustwo \hbox{\strut\dostarttagged\t!sub\empty#4\dostoptagged}% \setbox\plusfour\hbox{\strut\dostarttagged\t!mid\empty#2\dostoptagged}% inefficient - \setbox\plussix \hbox{\strut\dostarttagged\t!sup\empty#4\dostoptagged}% + \setbox\plussix \hbox{\strut\dostarttagged\t!sup\empty#3\dostoptagged}% \scratchdimen \wd \ifdim\wd\plustwo>\wd\plusfour \ifdim\wd\plustwo>\wd\plussix @@ -262,6 +262,7 @@ \dostoptagged \egroup} -\unexpanded\def\lomihi{\typo_scripts_lowmidhigh\empty} +\unexpanded\def\lomihi {\typo_scripts_lowmidhigh\empty} +\unexpanded\def\himilo#1#2#3{\typo_scripts_lowmidhigh\empty{#1}{#3}{#2}} \protect \endinput diff --git a/tex/context/base/util-lua.lua b/tex/context/base/util-lua.lua index 9e5328044..2baeaa854 100644 --- a/tex/context/base/util-lua.lua +++ b/tex/context/base/util-lua.lua @@ -7,18 +7,18 @@ if not modules then modules = { } end modules ['util-lua'] = { license = "see context related readme files" } -local rep, sub, byte, dump = string.rep, string.sub, string.byte, string.dump -local loadstring, loadfile = loadstring, loadfile +local rep, sub, byte, dump, format = string.rep, string.sub, string.byte, string.dump, string.format +local loadstring, loadfile, type = loadstring, loadfile, type utilities = utilities or {} utilities.lua = utilities.lua or { } local luautilities = utilities.lua -utilities.report = logs and logs.reporter("system") or print +utilities.report = logs and logs.reporter("system") or print -- can be overloaded later local tracestripping = false -local forcestupidcompile = true -luautilities.stripcode = true +local forcestupidcompile = true -- use internal bytecode compiler +luautilities.stripcode = true -- support stripping when asked for luautilities.alwaysstripcode = false -- saves 1 meg on 7 meg compressed format file (2012.08.12) luautilities.nofstrippedchunks = 0 luautilities.nofstrippedbytes = 0 @@ -162,6 +162,7 @@ end local function stupidcompile(luafile,lucfile,strip) local code = io.loaddata(luafile) + local n = 0 if code and code ~= "" then code = loadstring(code) if not code then @@ -169,30 +170,39 @@ local function stupidcompile(luafile,lucfile,strip) end code = dump(code) if strip then - code = strippedbytecode(code,true,luafile) -- last one is reported + code, n = strippedbytecode(code,true,luafile) -- last one is reported end if code and code ~= "" then io.savedata(lucfile,code) end end + return n end +local luac_normal = "texluac -o %q %q" +local luac_strip = "texluac -s -o %q %q" + function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) -- defaults: cleanup=false strip=true utilities.report("lua: compiling %s into %s",luafile,lucfile) os.remove(lucfile) local done = false + if strip ~= false then + strip = true + end if forcestupidcompile then fallback = true + elseif strip then + done = os.spawn(format(luac_strip, lucfile,luafile)) == 0 else - local command = "-o " .. string.quoted(lucfile) .. " " .. string.quoted(luafile) - if strip ~= false then - command = "-s " .. command - end - done = os.spawn("texluac " .. command) == 0 -- or os.spawn("luac " .. command) == 0 + done = os.spawn(format(luac_normal,lucfile,luafile)) == 0 end if not done and fallback then - utilities.report("lua: dumping %s into %s (unstripped)",luafile,lucfile) - stupidcompile(luafile,lucfile,strip) + local n = stupidcompile(luafile,lucfile,strip) + if n > 0 then + utilities.report("lua: %s dumped into %s (%i bytes stripped)",luafile,lucfile,n) + else + utilities.report("lua: %s dumped into %s (unstripped)",luafile,lucfile) + end cleanup = false -- better see how bad it is end if done and cleanup == true and lfs.isfile(lucfile) and lfs.isfile(luafile) then @@ -201,7 +211,6 @@ function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) -- default end return done end - --~ local getmetatable, type = getmetatable, type --~ local types = { } diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 81280b892..49a55c0eb 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/11/12 11:43:49 +-- merge date : 08/11/12 14:11:43 do -- begin closure to overcome local limits and interference |