diff options
37 files changed, 593 insertions, 395 deletions
diff --git a/scripts/context/lua/mtx-patterns.lua b/scripts/context/lua/mtx-patterns.lua index fbcb251b1..a436b0157 100644 --- a/scripts/context/lua/mtx-patterns.lua +++ b/scripts/context/lua/mtx-patterns.lua @@ -484,7 +484,7 @@ function scripts.patterns.convert() else local destination = environment.argument("destination") or "." if path == destination then - resport("source path and destination path should differ (use --path and/or --destination)") + report("source path and destination path should differ (use --path and/or --destination)") else local files = environment.files local only = false diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 7a721829e..c2c8f0581 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -947,7 +947,7 @@ local function flattened(t,f,depth) f = { } depth = 0xFFFF elseif tonumber(f) then - -- assume then only two arguments are given + -- assume that only two arguments are given depth = f f = { } elseif not depth then @@ -2997,6 +2997,15 @@ end os.which = which os.where = which +function os.today() + return date("!*t") -- table with values +end + +function os.now() + return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 +end + + -- print(os.which("inkscape.exe")) -- print(os.which("inkscape")) -- print(os.which("gs.exe")) @@ -4989,7 +4998,7 @@ local function serialize(t,r,outer) -- no mixes return r end -function table.fastserialize(t,prefix) +function table.fastserialize(t,prefix) -- so prefix should contain the = return concat(serialize(t,{ prefix or "return" },true)) end @@ -5392,6 +5401,9 @@ 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 +local strippedchunks = { } -- allocate() +luautilities.strippedchunks = strippedchunks + -- The next function was posted by Peter Cawley on the lua list and strips line -- number information etc. from the bytecode data blob. We only apply this trick @@ -5467,6 +5479,7 @@ local function strip_code_pc(dump,name) if tracestripping then utilities.report("stripped bytecode: %s, before %s, after %s, delta %s",name or "unknown",before,after,delta) end + strippedchunks[#strippedchunks+1] = name luautilities.nofstrippedchunks = luautilities.nofstrippedchunks + 1 luautilities.nofstrippedbytes = luautilities.nofstrippedbytes + delta return dump, delta @@ -5588,6 +5601,7 @@ end + end -- of closure do -- create closure to overcome 200 locals limit @@ -6367,36 +6381,43 @@ local data = { } -- maybe just local local trace_initialize = false -- only for testing during development -function setters.initialize(filename,name,values) -- filename only for diagnostics +function setters.initialize(filename,name,values,frozen) -- filename only for diagnostics local setter = data[name] if setter then +-- trace_initialize = true local data = setter.data if data then - for key, value in next, values do - -- key = gsub(key,"_",".") - value = is_boolean(value,value) + for key, newvalue in next, values do + local newvalue = is_boolean(newvalue,newvalue) local functions = data[key] if functions then - if #functions > 0 and not functions.value then + local oldvalue = functions.value + if functions.frozen then + if trace_initialize then + setter.report("%s: %q is frozen to %q",filename,key,tostring(oldvalue)) + end + elseif #functions > 0 and not oldvalue then +-- elseif #functions > 0 and oldvalue == nil then if trace_initialize then - setter.report("executing %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q is set to %q",filename,key,tostring(newvalue)) end for i=1,#functions do - functions[i](value) + functions[i](newvalue) end - functions.value = value + functions.value = newvalue + functions.frozen = functions.frozen or frozen else if trace_initialize then - setter.report("skipping %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q is kept as %q",filename,key,tostring(oldvalue)) end end else -- we do a simple preregistration i.e. not in the -- list as it might be an obsolete entry - functions = { default = value } + functions = { default = newvalue, frozen = frozen } data[key] = functions if trace_initialize then - setter.report("storing %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q default to %q",filename,key,tostring(newvalue)) end end end @@ -6408,46 +6429,52 @@ end -- user interface code local function set(t,what,newvalue) - local data, done = t.data, t.done - if type(what) == "string" then - what = settings_to_hash(what) -- inefficient but ok - end - if type(what) ~= "table" then - return - end - if not done then -- catch ... why not set? - done = { } - t.done = done - end - for w, value in next, what do - if value == "" then - value = newvalue - elseif not value then - value = false -- catch nil - else - value = is_boolean(value,value) + local data = t.data + if not data.frozen then + local done = t.done + if type(what) == "string" then + what = settings_to_hash(what) -- inefficient but ok end - w = "^" .. escapedpattern(w,true) .. "$" -- new: anchored - for name, functions in next, data do - if done[name] then - -- prevent recursion due to wildcards - elseif find(name,w) then - done[name] = true - for i=1,#functions do - functions[i](value) + if type(what) ~= "table" then + return + end + if not done then -- catch ... why not set? + done = { } + t.done = done + end + for w, value in next, what do + if value == "" then + value = newvalue + elseif not value then + value = false -- catch nil + else + value = is_boolean(value,value) + end + w = "^" .. escapedpattern(w,true) .. "$" -- new: anchored + for name, functions in next, data do + if done[name] then + -- prevent recursion due to wildcards + elseif find(name,w) then + done[name] = true + for i=1,#functions do + functions[i](value) + end + functions.value = value end - functions.value = value end end end end local function reset(t) - for name, functions in next, t.data do - for i=1,#functions do - functions[i](false) + local data = t.data + if not data.frozen then + for name, functions in next, data do + for i=1,#functions do + functions[i](false) + end + functions.value = false end - functions.value = false end end @@ -6559,6 +6586,8 @@ end local enable, disable, register, list, show = setters.enable, setters.disable, setters.register, setters.list, setters.show +local write_nl = texio and texio.write_nl or print + local function report(setter,...) local report = logs and logs.report if report then @@ -6650,14 +6679,14 @@ if environment then if trackers then local list = engineflags["c:trackers"] or engineflags["trackers"] if type(list) == "string" then - setters.initialize("flags","trackers",settings_to_hash(list)) + setters.initialize("commandline flags","trackers",settings_to_hash(list),true) -- t_enable(list) end end if directives then local list = engineflags["c:directives"] or engineflags["directives"] if type(list) == "string" then - setters.initialize("flags","directives", settings_to_hash(list)) + setters.initialize("commandline flags","directives", settings_to_hash(list),true) -- d_enable(list) end end @@ -7768,16 +7797,27 @@ function environment.luafile(filename) -- needs checking return resolvers.findfile(filename,'luatexlibs') or "" end -local function checkstrip(filename) - local modu = modules[file.nameonly(filename)] - return modu and modu.dataonly +-- local function checkstrip(filename) +-- local modu = modules[file.nameonly(filename)] +-- return modu and modu.dataonly +-- end + +local stripindeed = true directives.register("system.compile.strip", function(v) stripindeed = v end) + +local function strippable(filename) + if stripindeed then + local modu = modules[file.nameonly(filename)] + return modu and modu.dataonly + else + return false + end end function environment.luafilechunk(filename,silent) -- used for loading lua bytecode in the format filename = file.replacesuffix(filename, "lua") local fullname = environment.luafile(filename) if fullname and fullname ~= "" then - local data = loadedluacode(fullname,checkstrip,filename) + local data = loadedluacode(fullname,strippable,filename) if trace_locating then report_lua("loading file %s%s", fullname, not data and " failed" or "") elseif not silent then @@ -16183,7 +16223,8 @@ package.libpaths = getlibpaths package.clibpaths = getclibpaths function package.extralibpath(...) - local paths = { ... } + local libpaths = getlibpaths() + local paths = table.flattened { ... } for i=1,#paths do local path = cleanpath(paths[i]) if not libhash[path] then @@ -16197,7 +16238,8 @@ function package.extralibpath(...) end function package.extraclibpath(...) - local paths = { ... } + local clibpaths = getclibpaths() + local paths = table.flattened { ... } for i=1,#paths do local path = cleanpath(paths[i]) if not clibhash[path] then @@ -16858,6 +16900,8 @@ local escapers = { end, } +lpeg.patterns.sqlescape = sqlescape + local function replacekeyunquoted(s,t,how,recurse) -- ".. \" " local escaper = how and escapers[how] or escapers.lua return escaper(replacekey(s,t,recurse)) diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 7a721829e..c2c8f0581 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -947,7 +947,7 @@ local function flattened(t,f,depth) f = { } depth = 0xFFFF elseif tonumber(f) then - -- assume then only two arguments are given + -- assume that only two arguments are given depth = f f = { } elseif not depth then @@ -2997,6 +2997,15 @@ end os.which = which os.where = which +function os.today() + return date("!*t") -- table with values +end + +function os.now() + return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 +end + + -- print(os.which("inkscape.exe")) -- print(os.which("inkscape")) -- print(os.which("gs.exe")) @@ -4989,7 +4998,7 @@ local function serialize(t,r,outer) -- no mixes return r end -function table.fastserialize(t,prefix) +function table.fastserialize(t,prefix) -- so prefix should contain the = return concat(serialize(t,{ prefix or "return" },true)) end @@ -5392,6 +5401,9 @@ 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 +local strippedchunks = { } -- allocate() +luautilities.strippedchunks = strippedchunks + -- The next function was posted by Peter Cawley on the lua list and strips line -- number information etc. from the bytecode data blob. We only apply this trick @@ -5467,6 +5479,7 @@ local function strip_code_pc(dump,name) if tracestripping then utilities.report("stripped bytecode: %s, before %s, after %s, delta %s",name or "unknown",before,after,delta) end + strippedchunks[#strippedchunks+1] = name luautilities.nofstrippedchunks = luautilities.nofstrippedchunks + 1 luautilities.nofstrippedbytes = luautilities.nofstrippedbytes + delta return dump, delta @@ -5588,6 +5601,7 @@ end + end -- of closure do -- create closure to overcome 200 locals limit @@ -6367,36 +6381,43 @@ local data = { } -- maybe just local local trace_initialize = false -- only for testing during development -function setters.initialize(filename,name,values) -- filename only for diagnostics +function setters.initialize(filename,name,values,frozen) -- filename only for diagnostics local setter = data[name] if setter then +-- trace_initialize = true local data = setter.data if data then - for key, value in next, values do - -- key = gsub(key,"_",".") - value = is_boolean(value,value) + for key, newvalue in next, values do + local newvalue = is_boolean(newvalue,newvalue) local functions = data[key] if functions then - if #functions > 0 and not functions.value then + local oldvalue = functions.value + if functions.frozen then + if trace_initialize then + setter.report("%s: %q is frozen to %q",filename,key,tostring(oldvalue)) + end + elseif #functions > 0 and not oldvalue then +-- elseif #functions > 0 and oldvalue == nil then if trace_initialize then - setter.report("executing %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q is set to %q",filename,key,tostring(newvalue)) end for i=1,#functions do - functions[i](value) + functions[i](newvalue) end - functions.value = value + functions.value = newvalue + functions.frozen = functions.frozen or frozen else if trace_initialize then - setter.report("skipping %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q is kept as %q",filename,key,tostring(oldvalue)) end end else -- we do a simple preregistration i.e. not in the -- list as it might be an obsolete entry - functions = { default = value } + functions = { default = newvalue, frozen = frozen } data[key] = functions if trace_initialize then - setter.report("storing %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q default to %q",filename,key,tostring(newvalue)) end end end @@ -6408,46 +6429,52 @@ end -- user interface code local function set(t,what,newvalue) - local data, done = t.data, t.done - if type(what) == "string" then - what = settings_to_hash(what) -- inefficient but ok - end - if type(what) ~= "table" then - return - end - if not done then -- catch ... why not set? - done = { } - t.done = done - end - for w, value in next, what do - if value == "" then - value = newvalue - elseif not value then - value = false -- catch nil - else - value = is_boolean(value,value) + local data = t.data + if not data.frozen then + local done = t.done + if type(what) == "string" then + what = settings_to_hash(what) -- inefficient but ok end - w = "^" .. escapedpattern(w,true) .. "$" -- new: anchored - for name, functions in next, data do - if done[name] then - -- prevent recursion due to wildcards - elseif find(name,w) then - done[name] = true - for i=1,#functions do - functions[i](value) + if type(what) ~= "table" then + return + end + if not done then -- catch ... why not set? + done = { } + t.done = done + end + for w, value in next, what do + if value == "" then + value = newvalue + elseif not value then + value = false -- catch nil + else + value = is_boolean(value,value) + end + w = "^" .. escapedpattern(w,true) .. "$" -- new: anchored + for name, functions in next, data do + if done[name] then + -- prevent recursion due to wildcards + elseif find(name,w) then + done[name] = true + for i=1,#functions do + functions[i](value) + end + functions.value = value end - functions.value = value end end end end local function reset(t) - for name, functions in next, t.data do - for i=1,#functions do - functions[i](false) + local data = t.data + if not data.frozen then + for name, functions in next, data do + for i=1,#functions do + functions[i](false) + end + functions.value = false end - functions.value = false end end @@ -6559,6 +6586,8 @@ end local enable, disable, register, list, show = setters.enable, setters.disable, setters.register, setters.list, setters.show +local write_nl = texio and texio.write_nl or print + local function report(setter,...) local report = logs and logs.report if report then @@ -6650,14 +6679,14 @@ if environment then if trackers then local list = engineflags["c:trackers"] or engineflags["trackers"] if type(list) == "string" then - setters.initialize("flags","trackers",settings_to_hash(list)) + setters.initialize("commandline flags","trackers",settings_to_hash(list),true) -- t_enable(list) end end if directives then local list = engineflags["c:directives"] or engineflags["directives"] if type(list) == "string" then - setters.initialize("flags","directives", settings_to_hash(list)) + setters.initialize("commandline flags","directives", settings_to_hash(list),true) -- d_enable(list) end end @@ -7768,16 +7797,27 @@ function environment.luafile(filename) -- needs checking return resolvers.findfile(filename,'luatexlibs') or "" end -local function checkstrip(filename) - local modu = modules[file.nameonly(filename)] - return modu and modu.dataonly +-- local function checkstrip(filename) +-- local modu = modules[file.nameonly(filename)] +-- return modu and modu.dataonly +-- end + +local stripindeed = true directives.register("system.compile.strip", function(v) stripindeed = v end) + +local function strippable(filename) + if stripindeed then + local modu = modules[file.nameonly(filename)] + return modu and modu.dataonly + else + return false + end end function environment.luafilechunk(filename,silent) -- used for loading lua bytecode in the format filename = file.replacesuffix(filename, "lua") local fullname = environment.luafile(filename) if fullname and fullname ~= "" then - local data = loadedluacode(fullname,checkstrip,filename) + local data = loadedluacode(fullname,strippable,filename) if trace_locating then report_lua("loading file %s%s", fullname, not data and " failed" or "") elseif not silent then @@ -16183,7 +16223,8 @@ package.libpaths = getlibpaths package.clibpaths = getclibpaths function package.extralibpath(...) - local paths = { ... } + local libpaths = getlibpaths() + local paths = table.flattened { ... } for i=1,#paths do local path = cleanpath(paths[i]) if not libhash[path] then @@ -16197,7 +16238,8 @@ function package.extralibpath(...) end function package.extraclibpath(...) - local paths = { ... } + local clibpaths = getclibpaths() + local paths = table.flattened { ... } for i=1,#paths do local path = cleanpath(paths[i]) if not clibhash[path] then @@ -16858,6 +16900,8 @@ local escapers = { end, } +lpeg.patterns.sqlescape = sqlescape + local function replacekeyunquoted(s,t,how,recurse) -- ".. \" " local escaper = how and escapers[how] or escapers.lua return escaper(replacekey(s,t,recurse)) diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 7a721829e..c2c8f0581 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -947,7 +947,7 @@ local function flattened(t,f,depth) f = { } depth = 0xFFFF elseif tonumber(f) then - -- assume then only two arguments are given + -- assume that only two arguments are given depth = f f = { } elseif not depth then @@ -2997,6 +2997,15 @@ end os.which = which os.where = which +function os.today() + return date("!*t") -- table with values +end + +function os.now() + return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 +end + + -- print(os.which("inkscape.exe")) -- print(os.which("inkscape")) -- print(os.which("gs.exe")) @@ -4989,7 +4998,7 @@ local function serialize(t,r,outer) -- no mixes return r end -function table.fastserialize(t,prefix) +function table.fastserialize(t,prefix) -- so prefix should contain the = return concat(serialize(t,{ prefix or "return" },true)) end @@ -5392,6 +5401,9 @@ 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 +local strippedchunks = { } -- allocate() +luautilities.strippedchunks = strippedchunks + -- The next function was posted by Peter Cawley on the lua list and strips line -- number information etc. from the bytecode data blob. We only apply this trick @@ -5467,6 +5479,7 @@ local function strip_code_pc(dump,name) if tracestripping then utilities.report("stripped bytecode: %s, before %s, after %s, delta %s",name or "unknown",before,after,delta) end + strippedchunks[#strippedchunks+1] = name luautilities.nofstrippedchunks = luautilities.nofstrippedchunks + 1 luautilities.nofstrippedbytes = luautilities.nofstrippedbytes + delta return dump, delta @@ -5588,6 +5601,7 @@ end + end -- of closure do -- create closure to overcome 200 locals limit @@ -6367,36 +6381,43 @@ local data = { } -- maybe just local local trace_initialize = false -- only for testing during development -function setters.initialize(filename,name,values) -- filename only for diagnostics +function setters.initialize(filename,name,values,frozen) -- filename only for diagnostics local setter = data[name] if setter then +-- trace_initialize = true local data = setter.data if data then - for key, value in next, values do - -- key = gsub(key,"_",".") - value = is_boolean(value,value) + for key, newvalue in next, values do + local newvalue = is_boolean(newvalue,newvalue) local functions = data[key] if functions then - if #functions > 0 and not functions.value then + local oldvalue = functions.value + if functions.frozen then + if trace_initialize then + setter.report("%s: %q is frozen to %q",filename,key,tostring(oldvalue)) + end + elseif #functions > 0 and not oldvalue then +-- elseif #functions > 0 and oldvalue == nil then if trace_initialize then - setter.report("executing %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q is set to %q",filename,key,tostring(newvalue)) end for i=1,#functions do - functions[i](value) + functions[i](newvalue) end - functions.value = value + functions.value = newvalue + functions.frozen = functions.frozen or frozen else if trace_initialize then - setter.report("skipping %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q is kept as %q",filename,key,tostring(oldvalue)) end end else -- we do a simple preregistration i.e. not in the -- list as it might be an obsolete entry - functions = { default = value } + functions = { default = newvalue, frozen = frozen } data[key] = functions if trace_initialize then - setter.report("storing %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q default to %q",filename,key,tostring(newvalue)) end end end @@ -6408,46 +6429,52 @@ end -- user interface code local function set(t,what,newvalue) - local data, done = t.data, t.done - if type(what) == "string" then - what = settings_to_hash(what) -- inefficient but ok - end - if type(what) ~= "table" then - return - end - if not done then -- catch ... why not set? - done = { } - t.done = done - end - for w, value in next, what do - if value == "" then - value = newvalue - elseif not value then - value = false -- catch nil - else - value = is_boolean(value,value) + local data = t.data + if not data.frozen then + local done = t.done + if type(what) == "string" then + what = settings_to_hash(what) -- inefficient but ok end - w = "^" .. escapedpattern(w,true) .. "$" -- new: anchored - for name, functions in next, data do - if done[name] then - -- prevent recursion due to wildcards - elseif find(name,w) then - done[name] = true - for i=1,#functions do - functions[i](value) + if type(what) ~= "table" then + return + end + if not done then -- catch ... why not set? + done = { } + t.done = done + end + for w, value in next, what do + if value == "" then + value = newvalue + elseif not value then + value = false -- catch nil + else + value = is_boolean(value,value) + end + w = "^" .. escapedpattern(w,true) .. "$" -- new: anchored + for name, functions in next, data do + if done[name] then + -- prevent recursion due to wildcards + elseif find(name,w) then + done[name] = true + for i=1,#functions do + functions[i](value) + end + functions.value = value end - functions.value = value end end end end local function reset(t) - for name, functions in next, t.data do - for i=1,#functions do - functions[i](false) + local data = t.data + if not data.frozen then + for name, functions in next, data do + for i=1,#functions do + functions[i](false) + end + functions.value = false end - functions.value = false end end @@ -6559,6 +6586,8 @@ end local enable, disable, register, list, show = setters.enable, setters.disable, setters.register, setters.list, setters.show +local write_nl = texio and texio.write_nl or print + local function report(setter,...) local report = logs and logs.report if report then @@ -6650,14 +6679,14 @@ if environment then if trackers then local list = engineflags["c:trackers"] or engineflags["trackers"] if type(list) == "string" then - setters.initialize("flags","trackers",settings_to_hash(list)) + setters.initialize("commandline flags","trackers",settings_to_hash(list),true) -- t_enable(list) end end if directives then local list = engineflags["c:directives"] or engineflags["directives"] if type(list) == "string" then - setters.initialize("flags","directives", settings_to_hash(list)) + setters.initialize("commandline flags","directives", settings_to_hash(list),true) -- d_enable(list) end end @@ -7768,16 +7797,27 @@ function environment.luafile(filename) -- needs checking return resolvers.findfile(filename,'luatexlibs') or "" end -local function checkstrip(filename) - local modu = modules[file.nameonly(filename)] - return modu and modu.dataonly +-- local function checkstrip(filename) +-- local modu = modules[file.nameonly(filename)] +-- return modu and modu.dataonly +-- end + +local stripindeed = true directives.register("system.compile.strip", function(v) stripindeed = v end) + +local function strippable(filename) + if stripindeed then + local modu = modules[file.nameonly(filename)] + return modu and modu.dataonly + else + return false + end end function environment.luafilechunk(filename,silent) -- used for loading lua bytecode in the format filename = file.replacesuffix(filename, "lua") local fullname = environment.luafile(filename) if fullname and fullname ~= "" then - local data = loadedluacode(fullname,checkstrip,filename) + local data = loadedluacode(fullname,strippable,filename) if trace_locating then report_lua("loading file %s%s", fullname, not data and " failed" or "") elseif not silent then @@ -16183,7 +16223,8 @@ package.libpaths = getlibpaths package.clibpaths = getclibpaths function package.extralibpath(...) - local paths = { ... } + local libpaths = getlibpaths() + local paths = table.flattened { ... } for i=1,#paths do local path = cleanpath(paths[i]) if not libhash[path] then @@ -16197,7 +16238,8 @@ function package.extralibpath(...) end function package.extraclibpath(...) - local paths = { ... } + local clibpaths = getclibpaths() + local paths = table.flattened { ... } for i=1,#paths do local path = cleanpath(paths[i]) if not clibhash[path] then @@ -16858,6 +16900,8 @@ local escapers = { end, } +lpeg.patterns.sqlescape = sqlescape + local function replacekeyunquoted(s,t,how,recurse) -- ".. \" " local escaper = how and escapers[how] or escapers.lua return escaper(replacekey(s,t,recurse)) diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua index db1849c5a..7fc27222d 100644 --- a/tex/context/base/chem-str.lua +++ b/tex/context/base/chem-str.lua @@ -517,7 +517,7 @@ commands.chemicalcomponent = chemistry.component local inline = { ["single"] = "\\chemicalsinglebond", ["-"] = "\\chemicalsinglebond", - ["double"] = "\\chemicaldoublebond", ["--"] = "\\chemicaldoublebond", -- also =? and unicode triple? + ["double"] = "\\chemicaldoublebond", ["--"] = "\\chemicaldoublebond", ["triple"] = "\\chemicaltriplebond", ["---"] = "\\chemicaltriplebond", ["gives"] = "\\chemicalgives", ["->"] = "\\chemicalgives", ["equilibrium"] = "\\chemicalequilibrium", ["<->"] = "\\chemicalequilibrium", diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 4248e3d70..9066b1651 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.11.14 11:37} +\newcontextversion{2012.11.16 23:27} %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 fae4ce095..efa105fa1 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.11.14 11:37} +\newcontextversion{2012.11.16 23:27} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 57902b179..cbbe23209 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 c9adb2c42..6dc237eb2 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 d97023628..0ded382c0 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.11.14 11:37} +\edef\contextversion{2012.11.16 23:27} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index b5885fe57..bd6fdd717 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.11.14 11:37} +\edef\contextversion{2012.11.16 23:27} %D For those who want to use this: diff --git a/tex/context/base/data-lua.lua b/tex/context/base/data-lua.lua index fec5856ea..87d346201 100644 --- a/tex/context/base/data-lua.lua +++ b/tex/context/base/data-lua.lua @@ -86,7 +86,8 @@ package.libpaths = getlibpaths package.clibpaths = getclibpaths function package.extralibpath(...) - local paths = { ... } + local libpaths = getlibpaths() + local paths = table.flattened { ... } for i=1,#paths do local path = cleanpath(paths[i]) if not libhash[path] then @@ -100,7 +101,8 @@ function package.extralibpath(...) end function package.extraclibpath(...) - local paths = { ... } + local clibpaths = getclibpaths() + local paths = table.flattened { ... } for i=1,#paths do local path = cleanpath(paths[i]) if not clibhash[path] then diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua index 864e5bd16..f50e57113 100644 --- a/tex/context/base/font-def.lua +++ b/tex/context/base/font-def.lua @@ -34,6 +34,7 @@ local readers = fonts.readers local definers = fonts.definers local specifiers = fonts.specifiers local constructors = fonts.constructors +local fontgoodies = fonts.goodies readers.sequence = allocate { 'otf', 'ttf', 'afm', 'tfm', 'lua' } -- dfont ttc @@ -47,6 +48,8 @@ local internalized = allocate() -- internal tex numbers (private) local loadedfonts = constructors.loadedfonts local designsizes = constructors.designsizes +local resolvefile = fontgoodies.filenames.resolve + --[[ldx-- <p>We hardly gain anything when we cache the final (pre scaled) <l n='tfm'/> table. But it can be handy for debugging, so we no @@ -164,10 +167,13 @@ local resolvers = definers.resolvers -- todo: reporter function resolvers.file(specification) - local suffix = file.suffix(specification.name) + local name = resolvefile(specification.name) -- catch for renames + local suffix = file.suffix(name) if fonts.formats[suffix] then specification.forced = suffix - specification.name = file.removesuffix(specification.name) + specification.name = file.removesuffix(name) + else + specification.name = name -- cna be resolved end end diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua index b4b073433..ea24b203a 100644 --- a/tex/context/base/font-gds.lua +++ b/tex/context/base/font-gds.lua @@ -41,6 +41,8 @@ fontgoodies.list = list -- no allocate as we want to see what is there local addotffeature = otf.enhancers.addfeature +local findfile = resolvers.findfile + function fontgoodies.report(what,trace,goodies) if trace_goodies or trace then local whatever = goodies[what] @@ -55,9 +57,9 @@ local function loadgoodies(filename) -- maybe a merge is better if goodies ~= nil then -- found or tagged unfound elseif type(filename) == "string" then - local fullname = resolvers.findfile(file.addsuffix(filename,"lfg")) or "" -- prefered suffix + local fullname = findfile(file.addsuffix(filename,"lfg")) or "" -- prefered suffix if fullname == "" then - fullname = resolvers.findfile(file.addsuffix(filename,"lua")) or "" -- fallback suffix + fullname = findfile(file.addsuffix(filename,"lua")) or "" -- fallback suffix end if fullname == "" then report_goodies("goodie file '%s.lfg' is not found",filename) @@ -603,6 +605,38 @@ end fontgoodies.register("compositions", initialize) +local filenames = fontgoodies.filenames or allocate() +fontgoodies.filenames = filenames + +local filedata = filenames.data or allocate() +filenames.data = filedata + +local function initialize(goodies) -- design sizes are registered global + local fn = goodies.filenames + if fn then + for usedname, alternativenames in next, fn do + filedata[usedname] = alternativenames + end + end +end + +fontgoodies.register("filenames", initialize) + +function fontgoodies.filenames.resolve(name) + local fd = filedata[name] + if fd and findfile(name) == "" then + for i=1,#fd do + local fn = fd[i] + if findfile(fn) ~= "" then + return fn + end + end + else + -- no lookup, just use the regular mechanism + end + return name +end + local designsizes = fontgoodies.designsizes or allocate() fontgoodies.designsizes = designsizes diff --git a/tex/context/base/l-os.lua b/tex/context/base/l-os.lua index 799f44957..08136b24d 100644 --- a/tex/context/base/l-os.lua +++ b/tex/context/base/l-os.lua @@ -448,6 +448,15 @@ end os.which = which os.where = which +function os.today() + return date("!*t") -- table with values +end + +function os.now() + return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 +end + + -- print(os.which("inkscape.exe")) -- print(os.which("inkscape")) -- print(os.which("gs.exe")) diff --git a/tex/context/base/l-pdfview.lua b/tex/context/base/l-pdfview.lua index e48358d78..e42462a3d 100644 --- a/tex/context/base/l-pdfview.lua +++ b/tex/context/base/l-pdfview.lua @@ -22,18 +22,19 @@ local opencalls, closecalls, allcalls, runner if os.type == "windows" then opencalls = { - ['default'] = "pdfopen --ax --file", -- --back --file --ax - ['acrobat'] = "pdfopen --ax --file", -- --back --file --ax - ['okular'] = 'start "test" "c:/data/system/kde/bin/okular.exe" --unique' -- todo! + ['default'] = "pdfopen --rxi --file", + ['acrobat'] = "pdfopen --rxi --file", + ['fullacrobat'] = "pdfopen --axi --file", + ['okular'] = 'start "test" "c:/data/system/kde/bin/okular.exe" --unique' -- todo! } closecalls= { - ['default'] = "pdfclose --ax --file", -- --ax - ['acrobat'] = "pdfclose --ax --file", -- --ax + ['default'] = "pdfclose --file", + ['acrobat'] = "pdfclose --file", ['okular'] = false, } allcalls = { - ['default'] = "pdfclose --ax --all", -- --ax - ['acrobat'] = "pdfclose --ax --all", -- --ax + ['default'] = "pdfclose --all", + ['acrobat'] = "pdfclose --all", ['okular'] = false, } @@ -85,7 +86,7 @@ function pdfview.status() return format("pdfview methods: %s, current method: %s (directives_pdfview_method)",pdfview.methods(),tostring(pdfview.method)) end -local openedfiles = { } +-- local openedfiles = { } local function fullname(name) return file.addsuffix(name,"pdf") @@ -99,7 +100,7 @@ function pdfview.open(...) local name = fullname(t[i]) if io.exists(name) then runner(format('%s "%s"', opencall, name)) - openedfiles[name] = true + -- openedfiles[name] = true end end end @@ -111,13 +112,13 @@ function pdfview.close(...) local t = { ... } for i=1,#t do local name = fullname(t[i]) - if openedfiles[name] then + -- if openedfiles[name] then runner(format('%s "%s"', closecall, name)) - openedfiles[name] = nil - else - pdfview.closeall() - break - end + -- openedfiles[name] = nil + -- else + -- pdfview.closeall() + -- break + -- end end end end @@ -127,7 +128,7 @@ function pdfview.closeall() if allcall then runner(format('%s', allcall)) end - openedfiles = { } + -- openedfiles = { } end --~ pdfview.open("t:/document/show-exa.pdf") diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua index c95696553..62e0cae14 100644 --- a/tex/context/base/l-table.lua +++ b/tex/context/base/l-table.lua @@ -762,7 +762,7 @@ local function flattened(t,f,depth) f = { } depth = 0xFFFF elseif tonumber(f) then - -- assume then only two arguments are given + -- assume that only two arguments are given depth = f f = { } elseif not depth then diff --git a/tex/context/base/luat-env.lua b/tex/context/base/luat-env.lua index c8a391e76..e5893e911 100644 --- a/tex/context/base/luat-env.lua +++ b/tex/context/base/luat-env.lua @@ -273,16 +273,27 @@ function environment.luafile(filename) -- needs checking return resolvers.findfile(filename,'luatexlibs') or "" end -local function checkstrip(filename) - local modu = modules[file.nameonly(filename)] - return modu and modu.dataonly +-- local function checkstrip(filename) +-- local modu = modules[file.nameonly(filename)] +-- return modu and modu.dataonly +-- end + +local stripindeed = true directives.register("system.compile.strip", function(v) stripindeed = v end) + +local function strippable(filename) + if stripindeed then + local modu = modules[file.nameonly(filename)] + return modu and modu.dataonly + else + return false + end end function environment.luafilechunk(filename,silent) -- used for loading lua bytecode in the format filename = file.replacesuffix(filename, "lua") local fullname = environment.luafile(filename) if fullname and fullname ~= "" then - local data = loadedluacode(fullname,checkstrip,filename) + local data = loadedluacode(fullname,strippable,filename) if trace_locating then report_lua("loading file %s%s", fullname, not data and " failed" or "") elseif not silent then diff --git a/tex/context/base/luat-sto.lua b/tex/context/base/luat-sto.lua index fddf262c2..acf658505 100644 --- a/tex/context/base/luat-sto.lua +++ b/tex/context/base/luat-sto.lua @@ -34,6 +34,11 @@ storage.nofmodules = storage.nofmodules or 0 storage.mark = utilities.storage.mark storage.allocate = utilities.storage.allocate storage.marked = utilities.storage.marked +storage.strip = true + +directives.register("system.compile.strip", function(v) + storage.strip = v +end) function storage.register(...) local t = { ... } @@ -54,6 +59,7 @@ local function dump() local d = data[i] local message, original, target = d[1], d[2] ,d[3] local c, code, name = 0, { }, nil + -- we have a nice definer for this for str in gmatch(target,"([^%.]+)") do if name then name = name .. "." .. str @@ -71,7 +77,7 @@ local function dump() report_storage('saving %s in slot %s (%s bytes)',message,max,#code[c]) end -- we don't need tracing in such tables - bytecode[max] = strippedloadstring(concat(code,"\n"),true,format("slot %s",max)) + bytecode[max] = strippedloadstring(concat(code,"\n"),storage.strip,format("slot %s (%s)",max,name)) collectgarbage("step") end storage.max = max @@ -113,12 +119,22 @@ statistics.register("stored bytecode data", function() local tofmodules = storage.tofmodules or 0 local tofdumps = storage.toftables or 0 if environment.initex then - return format("%s modules, %s tables, %s chunks, %s bytes stripped (%s chunks)", - nofmodules, - nofdumps, - nofmodules + nofdumps, - utilities.lua.nofstrippedbytes, utilities.lua.nofstrippedchunks - ) + local luautilities = utilities.lua + if luautilities.nofstrippedbytes > 0 then + -- print(concat(luautilities.strippedchunks," ")) + return format("%s modules, %s tables, %s chunks, %s bytes stripped (%s chunks)", + nofmodules, + nofdumps, + nofmodules + nofdumps, + luautilities.nofstrippedbytes, luautilities.nofstrippedchunks + ) + else + return format("%s modules, %s tables, %s chunks", + nofmodules, + nofdumps, + nofmodules + nofdumps + ) + end else return format("%s modules (%0.3f sec), %s tables (%0.3f sec), %s chunks (%0.3f sec)", nofmodules, tofmodules, diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 536621c97..e188794ea 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -570,7 +570,8 @@ \def\meta_unique_graphic#1#2% {\meta_begin_graphic_group{#1}% \setupMPvariables[\currentMPgraphicname][#2]% - \getvalue{\??mpgraphic\currentMPgraphicname}\empty + %\getvalue{\??mpgraphic\currentMPgraphicname}\empty + \getvalue{\??mpgraphic#1}\empty \meta_end_graphic_group} \def\meta_handle_use_graphic#1#2#3% @@ -622,7 +623,8 @@ \def\meta_use_graphic#1#2% {\meta_begin_graphic_group{#1}% \doifsomething{#2}{\setupMPvariables[\currentMPgraphicname][#2]}% - \getvalue{\??mpgraphic\currentMPgraphicname}\empty + %\getvalue{\??mpgraphic\currentMPgraphicname}\empty + \getvalue{\??mpgraphic#1}\empty \meta_end_graphic_group} \let\reuseMPgraphic \useMPgraphic % we can save a setup here if needed @@ -658,7 +660,8 @@ {\meta_begin_graphic_group{#1}% \let\overlaystamp\overlaypagestamp \setupMPvariables[\m_meta_page_prefix:\currentMPgraphicname][#2]% prefix is new here - \getvalue{\??mpgraphic\m_meta_page_prefix:\currentMPgraphicname}{}% +% \getvalue{\??mpgraphic\m_meta_page_prefix:\currentMPgraphicname}{}% + \getvalue{\??mpgraphic\m_meta_page_prefix:#1}{}% \meta_end_graphic_group} %D One way of defining a stamp is: diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index cdd6c3bd5..bccca24eb 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -29,7 +29,9 @@ approach is way faster than an external <l n='metapost'/> and processing time nears zero.</p> --ldx]]-- +local type, tostring, tonumber = type, tostring, tonumber local format, gsub, match, find = string.format, string.gsub, string.match, string.find +local concat = table.concat local emptystring = string.is_empty local lpegmatch, P = lpeg.match, lpeg.P @@ -49,6 +51,7 @@ local mplibone = tonumber(mplib.version()) <= 1.50 metapost.showlog = false metapost.lastlog = "" +metapost.collapse = true -- currently mplib cannot deal with begingroup/endgroup mismatch in stepwise processing metapost.texerrors = false metapost.exectime = metapost.exectime or { } -- hack @@ -59,16 +62,6 @@ function metapost.resetlastlog() metapost.lastlog = "" end --- local function realfinder(name, mode, ftype) --- if mode == "w" then --- return name --- elseif file.is_qualified_path(name) then --- return name --- else --- return resolvers.findfile(name,ftype) --- end --- end - ----- mpbasepath = lpeg.instringchecker(lpeg.append { "/metapost/context/", "/metapost/base/" }) local mpbasepath = lpeg.instringchecker(P("/metapost/") * (P("context") + P("base")) * P("/")) @@ -401,6 +394,13 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, mp_inp[mpx]:write(banner) mp_log[mpx]:write(banner) end + if metapost.collapse and type(data) == "table" then + if #data > 1 then + data = concat(data,"\n") + else + data = data[1] + end + end if type(data) == "table" then for i=1,#data do local d = data[i] @@ -438,7 +438,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, mp_inp:write(data) end starttiming(metapost.exectime) - result = mpx[mpx]:execute(data) + result = mpx:execute(data) stoptiming(metapost.exectime) if trace_graphics and result then local str = result.log or result.error diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex c081ae5f3..3b58a36cc 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 c8c9717c4..9499d5a84 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-mar.mkiv b/tex/context/base/strc-mar.mkiv index 19fc30c31..3685b66a7 100644 --- a/tex/context/base/strc-mar.mkiv +++ b/tex/context/base/strc-mar.mkiv @@ -77,8 +77,14 @@ \def\strc_markings_synchronize[#1][#2][#3]% #1=class #2=boxnumber (some day also name) #3=options, maybe second argument table {\ifvoid#2\else\ctxcommand{synchronizemarking("#1",\number#2,"#3")}\fi} +% \def\doifelsemarking#1% why no \unexpanded +% {\ctxcommand{doifelsemarking("#1")}} + +% \def\doifelsemarking#1% +% {\normalexpanded{\noexpand\ctxcommand{doifelsemarking("\noexpand\detokenize{#1}")}}} + \def\doifelsemarking#1% - {\ctxcommand{doifelsemarking("#1")}} + {\ctxcommand{doifelsemarking(\!!bs#1\!!es)}} % \appendtoks % \strc_markings_synchronize[\v!page][\normalpagebox][\v!keep]% keep if no marks diff --git a/tex/context/base/trac-set.lua b/tex/context/base/trac-set.lua index bac448f77..60e57b015 100644 --- a/tex/context/base/trac-set.lua +++ b/tex/context/base/trac-set.lua @@ -28,36 +28,43 @@ local data = { } -- maybe just local local trace_initialize = false -- only for testing during development -function setters.initialize(filename,name,values) -- filename only for diagnostics +function setters.initialize(filename,name,values,frozen) -- filename only for diagnostics local setter = data[name] if setter then +-- trace_initialize = true local data = setter.data if data then - for key, value in next, values do - -- key = gsub(key,"_",".") - value = is_boolean(value,value) + for key, newvalue in next, values do + local newvalue = is_boolean(newvalue,newvalue) local functions = data[key] if functions then - if #functions > 0 and not functions.value then + local oldvalue = functions.value + if functions.frozen then + if trace_initialize then + setter.report("%s: %q is frozen to %q",filename,key,tostring(oldvalue)) + end + elseif #functions > 0 and not oldvalue then +-- elseif #functions > 0 and oldvalue == nil then if trace_initialize then - setter.report("executing %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q is set to %q",filename,key,tostring(newvalue)) end for i=1,#functions do - functions[i](value) + functions[i](newvalue) end - functions.value = value + functions.value = newvalue + functions.frozen = functions.frozen or frozen else if trace_initialize then - setter.report("skipping %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q is kept as %q",filename,key,tostring(oldvalue)) end end else -- we do a simple preregistration i.e. not in the -- list as it might be an obsolete entry - functions = { default = value } + functions = { default = newvalue, frozen = frozen } data[key] = functions if trace_initialize then - setter.report("storing %s (%s -> %s)",key,filename,tostring(value)) + setter.report("%s: %q default to %q",filename,key,tostring(newvalue)) end end end @@ -69,46 +76,52 @@ end -- user interface code local function set(t,what,newvalue) - local data, done = t.data, t.done - if type(what) == "string" then - what = settings_to_hash(what) -- inefficient but ok - end - if type(what) ~= "table" then - return - end - if not done then -- catch ... why not set? - done = { } - t.done = done - end - for w, value in next, what do - if value == "" then - value = newvalue - elseif not value then - value = false -- catch nil - else - value = is_boolean(value,value) + local data = t.data + if not data.frozen then + local done = t.done + if type(what) == "string" then + what = settings_to_hash(what) -- inefficient but ok end - w = "^" .. escapedpattern(w,true) .. "$" -- new: anchored - for name, functions in next, data do - if done[name] then - -- prevent recursion due to wildcards - elseif find(name,w) then - done[name] = true - for i=1,#functions do - functions[i](value) + if type(what) ~= "table" then + return + end + if not done then -- catch ... why not set? + done = { } + t.done = done + end + for w, value in next, what do + if value == "" then + value = newvalue + elseif not value then + value = false -- catch nil + else + value = is_boolean(value,value) + end + w = "^" .. escapedpattern(w,true) .. "$" -- new: anchored + for name, functions in next, data do + if done[name] then + -- prevent recursion due to wildcards + elseif find(name,w) then + done[name] = true + for i=1,#functions do + functions[i](value) + end + functions.value = value end - functions.value = value end end end end local function reset(t) - for name, functions in next, t.data do - for i=1,#functions do - functions[i](false) + local data = t.data + if not data.frozen then + for name, functions in next, data do + for i=1,#functions do + functions[i](false) + end + functions.value = false end - functions.value = false end end @@ -220,6 +233,8 @@ end local enable, disable, register, list, show = setters.enable, setters.disable, setters.register, setters.list, setters.show +local write_nl = texio and texio.write_nl or print + local function report(setter,...) local report = logs and logs.report if report then @@ -311,14 +326,14 @@ if environment then if trackers then local list = engineflags["c:trackers"] or engineflags["trackers"] if type(list) == "string" then - setters.initialize("flags","trackers",settings_to_hash(list)) + setters.initialize("commandline flags","trackers",settings_to_hash(list),true) -- t_enable(list) end end if directives then local list = engineflags["c:directives"] or engineflags["directives"] if type(list) == "string" then - setters.initialize("flags","directives", settings_to_hash(list)) + setters.initialize("commandline flags","directives", settings_to_hash(list),true) -- d_enable(list) end end diff --git a/tex/context/base/trac-vis.lua b/tex/context/base/trac-vis.lua index 31821ab3f..e20171959 100644 --- a/tex/context/base/trac-vis.lua +++ b/tex/context/base/trac-vis.lua @@ -70,8 +70,8 @@ local free_node_list = node.flush_list local has_attribute = node.has_attribute local set_attribute = node.set_attribute local unset_attribute = node.unset_attribute -local insert_node_before = node.insert_node_before -local insert_node_after = node.insert_node_after +local insert_node_before = node.insert_before +local insert_node_after = node.insert_after local fast_hpack = nodes.fasthpack local tex_attribute = tex.attribute diff --git a/tex/context/base/type-imp-latinmodern.mkiv b/tex/context/base/type-imp-latinmodern.mkiv index 698834a4b..69b773e93 100644 --- a/tex/context/base/type-imp-latinmodern.mkiv +++ b/tex/context/base/type-imp-latinmodern.mkiv @@ -171,8 +171,8 @@ \starttypescript [\s!math] [modern,latin-modern] \loadfontgoodies[lm] - \definefontsynonym [LMMathRoman-Regular] [\v!file:lmmath-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm] - \definefontsynonym [LMMathRoman-Bold] [\v!file:lmmath-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm] + \definefontsynonym [LMMathRoman-Regular] [\v!file:lmodernmath-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm] + \definefontsynonym [LMMathRoman-Bold] [\v!file:lmodernmath-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm] \stoptypescript \starttypescript [modern-designsize] diff --git a/tex/context/base/util-lua.lua b/tex/context/base/util-lua.lua index 2baeaa854..017964deb 100644 --- a/tex/context/base/util-lua.lua +++ b/tex/context/base/util-lua.lua @@ -22,6 +22,9 @@ 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 +local strippedchunks = { } -- allocate() +luautilities.strippedchunks = strippedchunks + -- The next function was posted by Peter Cawley on the lua list and strips line -- number information etc. from the bytecode data blob. We only apply this trick @@ -97,6 +100,7 @@ local function strip_code_pc(dump,name) if tracestripping then utilities.report("stripped bytecode: %s, before %s, after %s, delta %s",name or "unknown",before,after,delta) end + strippedchunks[#strippedchunks+1] = name luautilities.nofstrippedchunks = luautilities.nofstrippedchunks + 1 luautilities.nofstrippedbytes = luautilities.nofstrippedbytes + delta return dump, delta @@ -211,6 +215,7 @@ function luautilities.compile(luafile,lucfile,cleanup,strip,fallback) -- default end return done end + --~ local getmetatable, type = getmetatable, type --~ local types = { } diff --git a/tex/context/base/util-sql-imp-library.lua b/tex/context/base/util-sql-imp-library.lua index 374a34350..05b4f5b06 100644 --- a/tex/context/base/util-sql-imp-library.lua +++ b/tex/context/base/util-sql-imp-library.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['util-sql-library'] = { license = "see context related readme files" } +-- local function pcall(f,...) return true, f(...) end + -- For some reason the sql lib partially fails in luatex when creating hashed row. So far -- we couldn't figure it out (some issue with adapting the table that is passes as first -- argument in the fetch routine. Apart from this it looks like the mysql binding has some @@ -91,133 +93,6 @@ local function connect(session,specification) ) end --- local function datafetched(specification,query,converter) --- if not query or query == "" then --- report_state("no valid query") --- return { }, { } --- end --- local id = specification.id --- local session, connection --- if id then --- local c = cache[id] --- if c then --- session = c.session --- connection = c.connection --- end --- if not connection then --- session = initialize() --- connection = connect(session,specification) --- cache[id] = { session = session, connection = connection } --- end --- else --- session = initialize() --- connection = connect(session,specification) --- end --- if not connection then --- report_state("error in connection: %s@%s to %s:%s", --- specification.database or "no database", --- specification.username or "no username", --- specification.host or "no host", --- specification.port or "no port" --- ) --- return { }, { } --- end --- query = lpegmatch(querysplitter,query) --- local result, message, okay --- -- todo: check if open ! --- for i=1,#query do --- local q = query[i] --- local r, m = connection:execute(q) --- if m then --- report_state("error in query, stage 1: %s",string.collapsespaces(q)) --- message = message and format("%s\n%s",message,m) or m --- end --- local t = type(r) --- if t == "userdata" then --- result = r --- okay = true --- elseif t == "number" then --- okay = true --- end --- end --- if not okay and id then -- can go --- if session then --- session:close() --- end --- if connection then --- connection:close() --- end --- session = initialize() -- maybe not needed --- connection = connect(session,specification) --- if connection then --- cache[id] = { session = session, connection = connection } --- for i=1,#query do --- local q = query[i] --- local r, m = connection:execute(q) --- if m then --- report_state("error in query, stage 2: %s",string.collapsespaces(q)) --- message = message and format("%s\n%s",message,m) or m --- end --- local t = type(r) --- if t == "userdata" then --- result = r --- okay = true --- elseif t == "number" then --- okay = true --- end --- end --- else --- message = "unable to connect" --- report_state(message) --- end --- end --- local data, keys --- if result then --- if converter then --- data = converter.library(result) --- -- data = converter(result) --- else --- keys = result:getcolnames() --- if keys then --- local n = result:numrows() or 0 --- if n == 0 then --- data = { } --- -- elseif n == 1 then --- -- -- data = { result:fetch({},"a") } --- else --- data = { } --- -- for i=1,n do --- -- data[i] = result:fetch({},"a") --- -- end --- local k = #keys --- for i=1,n do --- local v = { result:fetch() } --- local d = { } --- for i=1,k do --- d[keys[i]] = v[i] --- end --- data[#data+1] = d --- end --- end --- end --- end --- result:close() --- elseif message then --- report_state("message %s",message) --- end --- if not keys then --- keys = { } --- end --- if not data then --- data = { } --- end --- if not id then --- connection:close() --- session:close() --- end --- return data, keys --- end - local function fetched(specification,query,converter) if not query or query == "" then report_state("no valid query") diff --git a/tex/context/base/util-tab.lua b/tex/context/base/util-tab.lua index b9f41ce9b..c1cedf9bb 100644 --- a/tex/context/base/util-tab.lua +++ b/tex/context/base/util-tab.lua @@ -233,7 +233,7 @@ local function serialize(t,r,outer) -- no mixes return r end -function table.fastserialize(t,prefix) +function table.fastserialize(t,prefix) -- so prefix should contain the = return concat(serialize(t,{ prefix or "return" },true)) end diff --git a/tex/context/base/util-tpl.lua b/tex/context/base/util-tpl.lua index 4cde1863b..5775a4e92 100644 --- a/tex/context/base/util-tpl.lua +++ b/tex/context/base/util-tpl.lua @@ -59,6 +59,8 @@ local escapers = { end, } +lpeg.patterns.sqlescape = sqlescape + local function replacekeyunquoted(s,t,how,recurse) -- ".. \" " local escaper = how and escapers[how] or escapers.lua return escaper(replacekey(s,t,recurse)) diff --git a/tex/context/fonts/lm.lfg b/tex/context/fonts/lm.lfg index 406902ef2..d534b6fc5 100644 --- a/tex/context/fonts/lm.lfg +++ b/tex/context/fonts/lm.lfg @@ -11,6 +11,9 @@ return { }, }, }, + filenames = { -- for a while: + ["lmodernmath-regular.otf"] = { "lmmath-regular.otf" }, + }, designsizes = { ["LMMathRoman-Regular"] = { ["4pt"] = "LMMath5-Regular@lmroman5-math", diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 512d71faa..29cba0db3 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 : 11/14/12 11:37:52 +-- merge date : 11/16/12 23:27:39 do -- begin closure to overcome local limits and interference @@ -924,7 +924,7 @@ local function flattened(t,f,depth) f = { } depth = 0xFFFF elseif tonumber(f) then - -- assume then only two arguments are given + -- assume that only two arguments are given depth = f f = { } elseif not depth then @@ -12637,6 +12637,7 @@ local readers = fonts.readers local definers = fonts.definers local specifiers = fonts.specifiers local constructors = fonts.constructors +local fontgoodies = fonts.goodies readers.sequence = allocate { 'otf', 'ttf', 'afm', 'tfm', 'lua' } -- dfont ttc @@ -12650,6 +12651,8 @@ local internalized = allocate() -- internal tex numbers (private) local loadedfonts = constructors.loadedfonts local designsizes = constructors.designsizes +local resolvefile = fontgoodies.filenames.resolve + --[[ldx-- <p>We hardly gain anything when we cache the final (pre scaled) <l n='tfm'/> table. But it can be handy for debugging, so we no @@ -12767,10 +12770,13 @@ local resolvers = definers.resolvers -- todo: reporter function resolvers.file(specification) - local suffix = file.suffix(specification.name) + local name = resolvefile(specification.name) -- catch for renames + local suffix = file.suffix(name) if fonts.formats[suffix] then specification.forced = suffix - specification.name = file.removesuffix(specification.name) + specification.name = file.removesuffix(name) + else + specification.name = name -- cna be resolved end end diff --git a/tex/generic/context/luatex/luatex-languages.lua b/tex/generic/context/luatex/luatex-languages.lua new file mode 100644 index 000000000..712118dbc --- /dev/null +++ b/tex/generic/context/luatex/luatex-languages.lua @@ -0,0 +1,45 @@ +if not modules then modules = { } end modules ['luatex-languages'] = { + version = 1.001, + comment = "companion to luatex-languages.tex", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- We borrow fron ConTeXt. + +languages = languages or { } + +local loaded = { } + +function languages.loadpatterns(tag) + if not loaded[tag] then + loaded[tag] = 0 + local filename = kpse.find_file("lang-" .. tag .. ".lua") + if filename and filename == "" then + print("<unknown language file for: " .. tag .. ">") + else + local whatever = loadfile(filename) + if type(whatever) == "function" then + whatever = whatever() + if type(whatever) == "table" then + local characters = whatever.patterns.characters or "" + local patterns = whatever.patterns.data or "" + local exceptions = whatever.exceptions.data or "" + local language = lang.new() + for b in string.utfvalues(characters) do + tex.setlccode(b,b) + end + lang.patterns(language, patterns) + lang.hyphenation(language, exceptions) + loaded[tag] = lang.id(language) + else + print("<invalid language table: " .. tag .. ">") + end + else + print("<invalid language file: " .. tag .. ">") + end + end + end + return loaded[tag] +end diff --git a/tex/generic/context/luatex/luatex-languages.tex b/tex/generic/context/luatex/luatex-languages.tex new file mode 100644 index 000000000..9778da39a --- /dev/null +++ b/tex/generic/context/luatex/luatex-languages.tex @@ -0,0 +1,17 @@ +%D \module +%D [ file=luatex-fonts, +%D version=2009.12.01, +%D title=\LUATEX\ Support Macros, +%D subtitle=Generic \OPENTYPE\ Font Handler, +%D author=Hans Hagen, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] + +%D Cf. discussion on \CONTEXT\ list: + +\directlua { + dofile(kpse.find_file("luatex-languages.lua","tex")) +} + +\def\loadpatterns#1{\directlua{tex.language = languages.loadpatterns("#1")}} + +\endinput diff --git a/tex/generic/context/luatex/luatex-plain.tex b/tex/generic/context/luatex/luatex-plain.tex index e47ad58ad..028d4ab0e 100644 --- a/tex/generic/context/luatex/luatex-plain.tex +++ b/tex/generic/context/luatex/luatex-plain.tex @@ -15,9 +15,10 @@ \everyjob \expandafter {% \the\everyjob - \input luatex-basics\relax - \input luatex-fonts\relax - \input luatex-mplib\relax + \input {luatex-basics}% + \input {luatex-fonts}% + \input {luatex-languages}% + \input {luatex-mplib}% } \edef\fmtversion{\fmtversion+luatex} diff --git a/tex/generic/context/luatex/luatex-test.tex b/tex/generic/context/luatex/luatex-test.tex index 3020b5594..7fddc673f 100644 --- a/tex/generic/context/luatex/luatex-test.tex +++ b/tex/generic/context/luatex/luatex-test.tex @@ -54,8 +54,17 @@ \mine \input tufte \par - % \font\mine=file:luatex-fonts-demo-vf-2.lua at 12pt \mine [abab] \par % \font\mine=file:luatex-fonts-demo-vf-3.lua at 12pt \mine [abab] \par +\font\test=dejavuserif:+kern at 10pt \test + +\hsize 1mm + +\noindent Циолковский + +\loadpatterns{ru} + +\noindent Циолковский + \end |