diff options
author | Hans Hagen <pragma@wxs.nl> | 2013-02-05 13:35:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2013-02-05 13:35:00 +0100 |
commit | baae751ef69bcc2c205ec969dbd5788fe0ac26e8 (patch) | |
tree | 48d78cbe66786b60e549f4e21be3bcf2b47262aa /tex/context/base | |
parent | e2f3737b9e45d1cf4d553b3f6cce71d5428bfe51 (diff) | |
download | context-baae751ef69bcc2c205ec969dbd5788fe0ac26e8.tar.gz |
beta 2013.02.05 13:35
Diffstat (limited to 'tex/context/base')
-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 | 4124 -> 4107 bytes | |||
-rw-r--r-- | tex/context/base/context-version.png | bin | 40232 -> 40160 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/grph-inc.lua | 87 | ||||
-rw-r--r-- | tex/context/base/l-os.lua | 12 | ||||
-rw-r--r-- | tex/context/base/luat-env.lua | 234 | ||||
-rw-r--r-- | tex/context/base/luat-lib.mkiv | 1 | ||||
-rw-r--r-- | tex/context/base/m-graph.mkiv | 22 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24744 -> 24719 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 208557 -> 208685 bytes | |||
-rw-r--r-- | tex/context/base/strc-flt.mkvi | 8 | ||||
-rw-r--r-- | tex/context/base/trac-lmx.lua | 9 | ||||
-rw-r--r-- | tex/context/base/util-mrg.lua | 4 | ||||
-rw-r--r-- | tex/context/base/util-sql-tickets.lua | 2 | ||||
-rw-r--r-- | tex/context/base/util-sql.lua | 4 |
18 files changed, 120 insertions, 271 deletions
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 5a9ea173a..ad44564be 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{2013.01.31 22:47} +\newcontextversion{2013.02.05 13:35} %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 8e7d04564..c91c44933 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{2013.01.31 22:47} +\newcontextversion{2013.02.05 13:35} %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 1c49aea89..ee4931f5a 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 c90a939dd..ba3ff464b 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 8a8aa70dc..62235cc1c 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{2013.01.31 22:47} +\edef\contextversion{2013.02.05 13:35} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 8ad9f130e..64a146e60 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{2013.01.31 22:47} +\edef\contextversion{2013.02.05 13:35} %D For those who want to use this: diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index fd282dac2..4006dfdbe 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -72,6 +72,14 @@ local context, img = context, img local f_hash_part = formatters["%s->%s->%s"] local f_hash_full = formatters["%s->%s->%s->%s->%s->%s->%s"] +local v_yes = variables.yes +local v_low = variables.low +local v_medium = variables.medium +local v_high = variables.high +local v_global = variables["global"] +local v_local = variables["local"] +local v_default = variables.default + local maxdimen = 2^30-1 function img.check(figure) @@ -322,18 +330,18 @@ function figures.setpaths(locationset,pathlist) -- this function can be called each graphic so we provide this optimization return end - local iv, t, h = interfaces.variables, figure_paths, settings_to_hash(locationset) + local t, h = figure_paths, settings_to_hash(locationset) if last_locationset ~= locationset then -- change == reset (actually, a 'reset' would indeed reset - if h[iv["local"]] then + if h[v_local] then t = table.fastcopy(figures.localpaths or { }) else t = { } end - figures.defaultsearch = h[iv["default"]] + figures.defaultsearch = h[v_default] last_locationset = locationset end - if h[iv["global"]] then + if h[v_global] then local list = settings_to_array(pathlist) for i=1,#list do local s = list[i] @@ -423,15 +431,14 @@ function figures.initialize(request) -- request.page = math.max(tonumber(request.page) or 1,1) request.size = img.checksize(request.size) - request.object = request.object == variables.yes - request["repeat"] = request["repeat"] == variables.yes - request.preview = request.preview == variables.yes + request.object = request.object == v_yes + request["repeat"] = request["repeat"] == v_yes + request.preview = request.preview == v_yes request.cache = request.cache ~= "" and request.cache request.prefix = request.prefix ~= "" and request.prefix request.format = request.format ~= "" and request.format table.merge(figuredata.request,request) end - -- inspect(figuredata) return figuredata end @@ -650,7 +657,7 @@ local function register(askedname,specification) return specification end -local resolve_too = true -- urls +local resolve_too = false -- true local function locate(request) -- name, format, cache -- not resolvers.cleanpath(request.name) as it fails on a!b.pdf and b~c.pdf @@ -661,28 +668,58 @@ local function locate(request) -- name, format, cache if foundname then return foundname end + -- + local askedcache = request.cache + local askedconversion = request.conversion + local askedresolution = request.resolution + -- + if request.format == "" or request.format == "unknown" then + request.format = nil + end -- protocol check local hashed = url.hashed(askedname) - if hashed then - if hashed.scheme == "file" then - local path = hashed.path - if path and path ~= "" then - askedname = path + if not hashed then + -- go on + elseif hashed.scheme == "file" then + local path = hashed.path + if path and path ~= "" then + askedname = path + end + else + local foundname = resolvers.findbinfile(askedname) + if not lfs.isfile(foundname) then -- foundname can be dummy + if trace_figures then + report_inclusion("strategy: unresolved url: %s",askedname) end + -- url not found + return register(askedname) + end + local askedformat = request.format or file.suffix(askedname) or "" + local guessedformat = figures.guess(foundname) + if askedformat ~= guessedformat then + if trace_figures then + report_inclusion("strategy: resolved url: %s, unknown format",askedname) + end + -- url found, but wrong format + return register(askedname) else - local foundname = resolvers.findbinfile(askedname) - if foundname then - askedname = foundname + if trace_figures then + report_inclusion("strategy: resolved url: %s -> %s",askedname,foundname) end + return register(askedname, { + askedname = askedname, + fullname = foundname, + format = askedformat, + cache = askedcache, + conversion = askedconversion, + resolution = askedresolution, + }) end end -- we could use the hashed data instead local askedpath= file.is_rootbased_path(askedname) local askedbase = file.basename(askedname) - local askedformat = request.format ~= "" and request.format ~= "unknown" and request.format or file.suffix(askedname) or "" - local askedcache = request.cache - local askedconversion = request.conversion - local askedresolution = request.resolution + local askedformat = request.format or file.suffix(askedname) or "" if askedformat ~= "" then askedformat = lower(askedformat) if trace_figures then @@ -806,7 +843,7 @@ local function locate(request) -- name, format, cache report_inclusion("warning: skipping path %s",path) end else - local foundname, quitscanning, forcedformat = figures.exists(check,format,true) + local foundname, quitscanning, forcedformat = figures.exists(check,format,resolve_too) -- true) if foundname then return register(askedname, { askedname = askedname, @@ -1246,9 +1283,9 @@ converters.ps = epsconverter local epstopdf = { resolutions = { - [variables.low] = "screen", - [variables.medium] = "ebook", - [variables.high] = "prepress", + [v_low] = "screen", + [v_medium] = "ebook", + [v_high] = "prepress", }, command = os.type == "windows" and "gswin32c" or "gs", -- -dProcessDSCComments=false diff --git a/tex/context/base/l-os.lua b/tex/context/base/l-os.lua index 08136b24d..1e7c91757 100644 --- a/tex/context/base/l-os.lua +++ b/tex/context/base/l-os.lua @@ -193,7 +193,14 @@ os.resolvers = os.resolvers or { } -- will become private local resolvers = os.resolvers -local osmt = getmetatable(os) or { __index = function(t,k) t[k] = "unset" return "unset" end } -- maybe nil +local osmt = getmetatable(os) or { __index = function(t,k) + local v = function() + print(format("function os.%s in namespace is undefined")) + end + t[k] = v + return v +end } -- maybe nil + local osix = osmt.__index osmt.__index = function(t,k) @@ -456,6 +463,9 @@ function os.now() return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 end +if not os.sleep and socket then + os.sleep = socket.sleep +end -- print(os.which("inkscape.exe")) -- print(os.which("inkscape")) diff --git a/tex/context/base/luat-env.lua b/tex/context/base/luat-env.lua index e483169fd..efaaebf3e 100644 --- a/tex/context/base/luat-env.lua +++ b/tex/context/base/luat-env.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['luat-env'] = { + if not modules then modules = { } end modules ['luat-env'] = { version = 1.001, comment = "companion to luat-lib.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -6,94 +6,23 @@ if not modules then modules = { } end modules ['luat-env'] = { license = "see context related readme files" } --- A former version provided functionality for non embeded core --- scripts i.e. runtime library loading. Given the amount of --- Lua code we use now, this no longer makes sense. Much of this --- evolved before bytecode arrays were available and so a lot of +-- A former version provided functionality for non embeded core scripts i.e. runtime +-- library loading. Given the amount of Lua code we use now, this no longer makes +-- sense. Much of this evolved before bytecode arrays were available and so a lot of -- code has disappeared already. local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end) local report_lua = logs.reporter("resolvers","lua") -local allocate, mark = utilities.storage.allocate, utilities.storage.mark - -local format, sub, match, gsub, find = string.format, string.sub, string.match, string.gsub, string.find -local unquoted, quoted = string.unquoted, string.quoted -local concat, insert, remove = table.concat, table.insert, table.remove - local luautilities = utilities.lua local luasuffixes = luautilities.suffixes environment = environment or { } local environment = environment --- precautions - -os.setlocale(nil,nil) -- useless feature and even dangerous in luatex - -function os.setlocale() - -- no way you can mess with it -end - --- dirty tricks (we will replace the texlua call by luatex --luaonly) - -local validengines = allocate { - ["luatex"] = true, - ["luajittex"] = true, - -- ["luatex.exe"] = true, - -- ["luajittex.exe"] = true, -} - -local basicengines = allocate { - ["luatex"] = "luatex", - ["texlua"] = "luatex", - ["texluac"] = "luatex", - ["luajittex"] = "luajittex", - ["texluajit"] = "luajittex", - -- ["texlua.exe"] = "luatex", - -- ["texluajit.exe"] = "luajittex", -} - -environment.validengines = validengines -environment.basicengines = basicengines - -if arg and validengines[file.removesuffix(arg[0])] and arg[1] == "--luaonly" then - arg[-1] = arg[0] - arg[ 0] = arg[2] - for k=3,#arg do - arg[k-2] = arg[k] - end - remove(arg) -- last - remove(arg) -- pre-last -end - --- This is an ugly hack but it permits symlinking a script (say 'context') to 'mtxrun' as in: --- --- ln -s /opt/minimals/tex/texmf-linux-64/bin/mtxrun context --- --- The special mapping hack is needed because 'luatools' boils down to 'mtxrun --script base' --- but it's unlikely that there will be more of this - -do - - local originalzero = file.basename(arg[0]) - local specialmapping = { luatools == "base" } - - if originalzero ~= "mtxrun" and originalzero ~= "mtxrun.lua" then - arg[0] = specialmapping[originalzero] or originalzero - insert(arg,0,"--script") - insert(arg,0,"mtxrun") - end - -end - -- environment -environment.arguments = allocate() -environment.files = allocate() -environment.sortedflags = nil - local mt = { __index = function(_,k) if k == "version" then @@ -122,161 +51,6 @@ local mt = { setmetatable(environment,mt) --- context specific arguments (in order not to confuse the engine) - -function environment.initializearguments(arg) - local arguments, files = { }, { } - environment.arguments, environment.files, environment.sortedflags = arguments, files, nil - for index=1,#arg do - local argument = arg[index] - if index > 0 then - local flag, value = match(argument,"^%-+(.-)=(.-)$") - if flag then - flag = gsub(flag,"^c:","") - arguments[flag] = unquoted(value or "") - else - flag = match(argument,"^%-+(.+)") - if flag then - flag = gsub(flag,"^c:","") - arguments[flag] = true - else - files[#files+1] = argument - end - end - end - end - environment.ownname = file.reslash(environment.ownname or arg[0] or 'unknown.lua') -end - -function environment.setargument(name,value) - environment.arguments[name] = value -end - --- todo: defaults, better checks e.g on type (boolean versus string) --- --- tricky: too many hits when we support partials unless we add --- a registration of arguments so from now on we have 'partial' - -function environment.getargument(name,partial) - local arguments, sortedflags = environment.arguments, environment.sortedflags - if arguments[name] then - return arguments[name] - elseif partial then - if not sortedflags then - sortedflags = allocate(table.sortedkeys(arguments)) - for k=1,#sortedflags do - sortedflags[k] = "^" .. sortedflags[k] - end - environment.sortedflags = sortedflags - end - -- example of potential clash: ^mode ^modefile - for k=1,#sortedflags do - local v = sortedflags[k] - if find(name,v) then - return arguments[sub(v,2,#v)] - end - end - end - return nil -end - -environment.argument = environment.getargument - -function environment.splitarguments(separator) -- rather special, cut-off before separator - local done, before, after = false, { }, { } - local originalarguments = environment.originalarguments - for k=1,#originalarguments do - local v = originalarguments[k] - if not done and v == separator then - done = true - elseif done then - after[#after+1] = v - else - before[#before+1] = v - end - end - return before, after -end - -function environment.reconstructcommandline(arg,noquote) - arg = arg or environment.originalarguments - if noquote and #arg == 1 then - -- we could just do: return unquoted(resolvers.resolve(arg[i])) - local a = arg[1] - a = resolvers.resolve(a) - a = unquoted(a) - return a - elseif #arg > 0 then - local result = { } - for i=1,#arg do - -- we could just do: result[#result+1] = format("%q",unquoted(resolvers.resolve(arg[i]))) - local a = arg[i] - a = resolvers.resolve(a) - a = unquoted(a) - a = gsub(a,'"','\\"') -- tricky - if find(a," ") then - result[#result+1] = quoted(a) - else - result[#result+1] = a - end - end - return concat(result," ") - else - return "" - end -end - --- -- to be tested: --- --- function environment.reconstructcommandline(arg,noquote) --- arg = arg or environment.originalarguments --- if noquote and #arg == 1 then --- return unquoted(resolvers.resolve(arg[1])) --- elseif #arg > 0 then --- local result = { } --- for i=1,#arg do --- result[#result+1] = format("%q",unquoted(resolvers.resolve(arg[i]))) -- always quote --- end --- return concat(result," ") --- else --- return "" --- end --- end - -if arg then - - -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later) - local newarg, instring = { }, false - - for index=1,#arg do - local argument = arg[index] - if find(argument,"^\"") then - newarg[#newarg+1] = gsub(argument,"^\"","") - if not find(argument,"\"$") then - instring = true - end - elseif find(argument,"\"$") then - newarg[#newarg] = newarg[#newarg] .. " " .. gsub(argument,"\"$","") - instring = false - elseif instring then - newarg[#newarg] = newarg[#newarg] .. " " .. argument - else - newarg[#newarg+1] = argument - end - end - for i=1,-5,-1 do - newarg[i] = arg[i] - end - - environment.initializearguments(newarg) - - environment.originalarguments = mark(newarg) - environment.rawarguments = mark(arg) - - arg = { } -- prevent duplicate handling - -end - -- weird place ... depends on a not yet loaded module function environment.texfile(filename) diff --git a/tex/context/base/luat-lib.mkiv b/tex/context/base/luat-lib.mkiv index 521ecbf5e..4ece2a29a 100644 --- a/tex/context/base/luat-lib.mkiv +++ b/tex/context/base/luat-lib.mkiv @@ -65,6 +65,7 @@ \registerctxluafile{luat-lua}{1.001} \registerctxluafile{luat-sto}{1.001} \registerctxluafile{luat-ini}{1.001} +\registerctxluafile{util-env}{1.001} \registerctxluafile{luat-env}{1.001} \registerctxluafile{luat-exe}{1.001} \registerctxluafile{luat-iop}{1.001} diff --git a/tex/context/base/m-graph.mkiv b/tex/context/base/m-graph.mkiv index 8acbe1f8d..c80e4ad91 100644 --- a/tex/context/base/m-graph.mkiv +++ b/tex/context/base/m-graph.mkiv @@ -15,6 +15,8 @@ % are limited by what mp can do. We support @ as replacement for % the percent symbol. We also add a specifier when no one is given. +\unprotect + \startluacode local format, gsub, find, match = string.format, string.gsub, string.find, string.match @@ -54,10 +56,24 @@ % We could also delegate parsing using lower level plugins. -\startMPextensions - if unknown Fe_plus : picture Fe_plus ; Fe_plus := textext("+") ; fi ; +\defineMPinstance + [graph] + [\s!format=metafun, + \s!extensions=\v!yes, + \s!initializations=\v!yes, + \c!method=\s!double] + +\startMPdefinitions{graph} if unknown context_grap: input "mp-grap.mpiv" ; fi ; -\stopMPextensions +\stopMPdefinitions + +% gone: +% +% \startMPextensions +% if unknown Fe_plus : picture Fe_plus ; Fe_plus := textext("+") ; fi ; +% \stopMPextensions + +\protect \continueifinputfile{m-graph.mkiv} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 1a957aa56..26f01897e 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 0d0ded3d8..d4b7fb4c5 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi index e268afee7..6199a3e6b 100644 --- a/tex/context/base/strc-flt.mkvi +++ b/tex/context/base/strc-flt.mkvi @@ -756,8 +756,8 @@ \def\floatcaptionattribute {\iflocation - \ifnofloatnumber - \else + %\ifnofloatnumber + %\else \ifnofloatcaption \else \ifinsidesplitfloat @@ -769,7 +769,7 @@ attr \destinationattribute \currentfloatattribute \fi \fi - \fi + %\fi \fi} \newconditional\usesamefloatnumber @@ -1029,7 +1029,7 @@ \unexpanded\def\placefloats {\page_otr_command_flush_floats} - + \newdimen\d_strc_floats_margin \newdimen\d_strc_floats_top \newdimen\d_strc_floats_bottom diff --git a/tex/context/base/trac-lmx.lua b/tex/context/base/trac-lmx.lua index 2754dd16d..d20241735 100644 --- a/tex/context/base/trac-lmx.lua +++ b/tex/context/base/trac-lmx.lua @@ -142,6 +142,10 @@ local function loadedfile(name) return data end +local function loadedsubfile(name) + return io.loaddata(resolvers and resolvers.findfile and resolvers.findfile(name) or name) +end + lmx.loadedfile = loadedfile -- A few helpers (the next one could end up in l-lpeg): @@ -208,14 +212,15 @@ local function do_type_variable(str) end local function do_include(filename) - local data = loadedfile(filename) + local data = loadedsubfile(filename) if (not data or data == "") and type(usedpaths) == "table" then for i=1,#usedpaths do - data = loadedfile(joinpath(usedpaths[i],filename)) + data = loadedsubfile(joinpath(usedpaths[i],filename)) end end if not data or data == "" then data = format("<!-- unknown lmx include file: %s -->",filename) + report_lmx("empty include file: %s",filename) end return data end diff --git a/tex/context/base/util-mrg.lua b/tex/context/base/util-mrg.lua index cdac10ac1..276531d79 100644 --- a/tex/context/base/util-mrg.lua +++ b/tex/context/base/util-mrg.lua @@ -120,6 +120,10 @@ local compact = Cs ( ( local strip = Cs((emptyline^2/"\n" + 1)^0) local stripreturn = Cs((1-P("return") * space^1 * P(1-space-eol)^1 * (space+eol)^0 * P(-1))^1) +function merger.compact(data) + return lpegmatch(strip,lpegmatch(compact,data)) +end + local function self_compact(data) local delta = 0 if merger.strip_comment then diff --git a/tex/context/base/util-sql-tickets.lua b/tex/context/base/util-sql-tickets.lua index 2dc334ce6..63bbf4d44 100644 --- a/tex/context/base/util-sql-tickets.lua +++ b/tex/context/base/util-sql-tickets.lua @@ -87,9 +87,7 @@ local template =[[ ]] function tickets.createdb(presets,datatable) - local db = checkeddb(presets,datatable) - local data, keys = db.execute { template = template, variables = { diff --git a/tex/context/base/util-sql.lua b/tex/context/base/util-sql.lua index 5310ea699..5d57c22f5 100644 --- a/tex/context/base/util-sql.lua +++ b/tex/context/base/util-sql.lua @@ -111,7 +111,9 @@ local defaults = { __index = } table.setmetatableindex(sql.methods,function(t,k) + report_state("start loading method %q",k) require("util-sql-imp-"..k) + report_state("loading method %q done",k) return rawget(t,k) end) @@ -328,6 +330,8 @@ function sql.usedatabase(presets,datatable) deserialize = deserialize, unpackdata = unpackdata, } + else + report_state("missing name in usedatabase specification") end end |