From 9ce4029363b79b66e4713c64a8695b392c068312 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sat, 11 Aug 2012 14:11:00 +0200 Subject: beta 2012.08.11 14:11 --- tex/context/base/cldf-ver.lua | 2 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4088 -> 4087 bytes tex/context/base/context-version.png | Bin 106517 -> 105941 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/m-spreadsheet.lua | 57 +++++++++++++++++++-- tex/context/base/m-spreadsheet.mkiv | 10 +++- tex/context/base/status-files.pdf | Bin 24422 -> 24408 bytes tex/context/base/status-lua.pdf | Bin 190438 -> 190434 bytes tex/context/base/status-mkiv.lua | 2 +- tex/context/base/typo-scr.mkiv | 7 +-- tex/context/base/util-lua.lua | 37 ++++++++----- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 15 files changed, 94 insertions(+), 31 deletions(-) (limited to 'tex') 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 index 0622580ce..1372d89dd 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index c28523396..67cdddeaa 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ 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] = "" + 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("",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 index 3ef6fd827..7e7883e05 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 7ff12a5ba..e9ce17b5b 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ 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 -- cgit v1.2.3