From c9b642d1b85111d8dcd94c443161e74583207e7d Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Thu, 10 Jul 2014 14:15:03 +0200 Subject: 2014-07-10 13:17:00 --- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4432 -> 4436 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/data-env.lua | 15 +++- tex/context/base/data-exp.lua | 49 ++++++++---- tex/context/base/data-res.lua | 11 ++- tex/context/base/data-tre.lua | 2 +- tex/context/base/file-job.lua | 12 +-- tex/context/base/file-lib.lua | 89 +++++++++------------ tex/context/base/luat-cod.lua | 2 +- tex/context/base/status-files.pdf | Bin 24924 -> 24913 bytes tex/context/base/status-lua.pdf | Bin 326283 -> 326320 bytes tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 13 files changed, 104 insertions(+), 82 deletions(-) (limited to 'tex') diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index b87b4d5cd..59be62f4b 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{2014.07.09 10:26} +\newcontextversion{2014.07.10 13:14} %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 index 73fc6286d..93b4e9264 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.mkiv b/tex/context/base/context.mkiv index 24c3c8244..168658a29 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2014.07.09 10:26} +\edef\contextversion{2014.07.10 13:14} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/data-env.lua b/tex/context/base/data-env.lua index 03a382e7b..1d7728c22 100644 --- a/tex/context/base/data-env.lua +++ b/tex/context/base/data-env.lua @@ -18,11 +18,13 @@ local formats = allocate() local suffixes = allocate() local dangerous = allocate() local suffixmap = allocate() +local usertypes = allocate() resolvers.formats = formats resolvers.suffixes = suffixes resolvers.dangerous = dangerous resolvers.suffixmap = suffixmap +resolvers.usertypes = usertypes local luasuffixes = utilities.lua.suffixes @@ -92,11 +94,13 @@ local relations = allocate { -- todo: handlers also here names = { "mp" }, variable = 'MPINPUTS', suffixes = { 'mp', 'mpvi', 'mpiv', 'mpii' }, + usertype = true, }, tex = { names = { "tex" }, variable = 'TEXINPUTS', suffixes = { "tex", "mkvi", "mkiv", "mkii", "cld", "lfg", "xml" }, -- known suffixes have less lookups + usertype = true, }, icc = { names = { "icc", "icc profile", "icc profiles" }, @@ -112,6 +116,7 @@ local relations = allocate { -- todo: handlers also here names = { "lua" }, variable = 'LUAINPUTS', suffixes = { luasuffixes.lua, luasuffixes.luc, luasuffixes.tma, luasuffixes.tmc }, + usertype = true, }, lib = { names = { "lib" }, @@ -122,11 +127,13 @@ local relations = allocate { -- todo: handlers also here names = { 'bib' }, variable = 'BIBINPUTS', suffixes = { 'bib' }, + usertype = true, }, bst = { names = { 'bst' }, variable = 'BSTINPUTS', suffixes = { 'bst' }, + usertype = true, }, fontconfig = { names = { 'fontconfig', 'fontconfig file', 'fontconfig files' }, @@ -212,8 +219,9 @@ function resolvers.updaterelations() for name, relation in next, categories do local rn = relation.names local rv = relation.variable - local rs = relation.suffixes if rn and rv then + local rs = relation.suffixes + local ru = relation.usertype for i=1,#rn do local rni = lower(gsub(rn[i]," ","")) formats[rni] = rv @@ -225,8 +233,9 @@ function resolvers.updaterelations() end end end - end - if rs then + if ru then + usertypes[name] = true + end end end end diff --git a/tex/context/base/data-exp.lua b/tex/context/base/data-exp.lua index 6edaa8c6a..b8c66909e 100644 --- a/tex/context/base/data-exp.lua +++ b/tex/context/base/data-exp.lua @@ -11,6 +11,7 @@ local concat, sort = table.concat, table.sort local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns local Ct, Cs, Cc, Carg, P, C, S = lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.P, lpeg.C, lpeg.S local type, next = type, next +local isdir = lfs.isdir local ostype = os.type local collapsepath, joinpath, basename = file.collapsepath, file.join, file.basename @@ -187,7 +188,7 @@ local doslashes = (P("\\")/"/" + 1)^0 local function expandedhome() if not usedhomedir then usedhomedir = lpegmatch(Cs(donegation * doslashes),environment.homedir or "") - if usedhomedir == "~" or usedhomedir == "" or not lfs.isdir(usedhomedir) then + if usedhomedir == "~" or usedhomedir == "" or not isdir(usedhomedir) then if trace_expansions then report_expansions("no home dir set, ignoring dependent path using current path") end @@ -415,19 +416,36 @@ function resolvers.scanfiles(path,branch,usecache,onlyonce) if trace_locating then report_expansions("scanning path %a, branch %a",path,branch or path) end - local files, remap, n, m, r = scan({ },{ },realpath .. '/',"",0,0,0,onlyonce) - local content = { - metadata = { - path = path, -- can be selfautoparent:texmf-whatever - files = n, - directories = m, - remappings = r, - }, - files = files, - remap = remap, - } - if trace_locating then - report_expansions("%s files found on %s directories with %s uppercase remappings",n,m,r) + local content + if isdir(realpath) then + local files, remap, n, m, r = scan({ },{ },realpath .. '/',"",0,0,0,onlyonce) + content = { + metadata = { + path = path, -- can be selfautoparent:texmf-whatever + files = n, + directories = m, + remappings = r, + }, + files = files, + remap = remap, + } + if trace_locating then + report_expansions("%s files found on %s directories with %s uppercase remappings",n,m,r) + end + else + content = { + metadata = { + path = path, -- can be selfautoparent:texmf-whatever + files = 0, + directories = 0, + remappings = 0, + }, + files = { }, + remap = { }, + } + if trace_locating then + report_expansions("invalid path %a",realpath) + end end if usecache then scanned[#scanned+1] = realpath @@ -453,6 +471,9 @@ function resolvers.scandata() end function resolvers.get_from_content(content,path,name) -- or (content,name) + if not content then + return + end local files = content.files if not files then return diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua index a22aea27f..dfb50413f 100644 --- a/tex/context/base/data-res.lua +++ b/tex/context/base/data-res.lua @@ -146,6 +146,7 @@ local unset_variable = "unset" local formats = resolvers.formats local suffixes = resolvers.suffixes +local usertypes = resolvers.usertypes local dangerous = resolvers.dangerous local suffixmap = resolvers.suffixmap @@ -1140,7 +1141,7 @@ end local function find_intree(filename,filetype,wantedfiles,allresults) local typespec = resolvers.variableofformat(filetype) - local pathlist = resolvers.expandedpathlist(typespec,filetype=="tex") -- only extra path with user files + local pathlist = resolvers.expandedpathlist(typespec,filetype and usertypes[filetype]) -- only extra path with user files local method = "intree" if pathlist and #pathlist > 0 then -- list search @@ -1358,7 +1359,11 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste else local method, result, stamp, filetype, wantedfiles if instance.remember then - stamp = formatters["%s--%s"](filename,askedformat) + if askedformat == "" then + stamp = formatters["%s::%s"](suffixonly(filename),filename) + else + stamp = formatters["%s::%s"](askedformat,filename) + end result = stamp and instance.found[stamp] if result then if trace_locating then @@ -1394,7 +1399,7 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste end if stamp then if trace_locating then - report_resolving("remembering file %a",filename) + report_resolving("remembering file %a using hash %a",filename,stamp) end instance.found[stamp] = result end diff --git a/tex/context/base/data-tre.lua b/tex/context/base/data-tre.lua index 58e44c23b..dc9440deb 100644 --- a/tex/context/base/data-tre.lua +++ b/tex/context/base/data-tre.lua @@ -137,7 +137,7 @@ end local function resolve(specification) -- can be called directly too local filename = specification.filename - -- print(filename) -- in case we want to check for unwanted lookups + -- inspect(specification) if filename ~= "" then local root, rest = lpegmatch(splitter,filename) if root and rest then diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua index ca0de2696..bbc7abcd0 100644 --- a/tex/context/base/file-job.lua +++ b/tex/context/base/file-job.lua @@ -234,21 +234,23 @@ local suffixes = { } local function useanyfile(name,onlyonce) - local s = suffixes[file.suffix(name)] + local s = suffixes[suffixonly(name)] if s then - s(removesuffix(name),onlyonce) + -- s(removesuffix(name),onlyonce) + s(name,onlyonce) -- so, first with suffix, then without else usetexfile(name,onlyonce) -- e.g. ctx file ---~ resolvers.readfilename(name) + -- resolvers.readfilename(name) end end commands.useanyfile = useanyfile function resolvers.jobs.usefile(name,onlyonce,notext) - local s = suffixes[file.suffix(name)] + local s = suffixes[suffixonly(name)] if s then - s(removesuffix(name),onlyonce,notext) + -- s(removesuffix(name),onlyonce,notext) + s(name,onlyonce,notext) -- so, first with suffix, then without end end diff --git a/tex/context/base/file-lib.lua b/tex/context/base/file-lib.lua index 409559cd3..7489a317b 100644 --- a/tex/context/base/file-lib.lua +++ b/tex/context/base/file-lib.lua @@ -11,8 +11,16 @@ if not modules then modules = { } end modules ['file-lib'] = { local format = string.format -local trace_files = false trackers.register("resolvers.readfile", function(v) trace_files = v end) -local report_files = logs.reporter("files","readfile") +local trace_libraries = false trackers.register("resolvers.libraries", function(v) trace_libraries = v end) +----- trace_files = false trackers.register("resolvers.readfile", function(v) trace_files = v end) + +local report_library = logs.reporter("files","library") +----- report_files = logs.reporter("files","readfile") + +local suffixonly = file.suffix +local removesuffix = file.removesuffix + +local getreadfilename = resolvers.getreadfilename local loaded = { } local defaultpatterns = { "%s" } @@ -25,45 +33,6 @@ local function defaultfailure(name) report_files("asked name %a, not found",name) end --- function commands.uselibrary(specification) -- todo; reporter --- local name = specification.name --- if name and name ~= "" then --- local patterns = specification.patterns or defaultpatterns --- local action = specification.action or defaultaction --- local failure = specification.failure or defaultfailure --- local onlyonce = specification.onlyonce --- local files = utilities.parsers.settings_to_array(name) --- local truename = environment.truefilename --- local done = false --- for i=1,#files do --- local filename = files[i] --- if not loaded[filename] then --- if onlyonce then --- loaded[filename] = true -- todo: base this on return value --- end --- for i=1,#patterns do --- local somename = format(patterns[i],filename) --- if truename then --- somename = truename(somename) --- end --- local foundname = resolvers.getreadfilename("any",".",somename) or "" --- if foundname ~= "" then --- action(name,foundname) --- done = true --- break --- end --- end --- if done then --- break --- end --- end --- end --- if failure and not done then --- failure(name) --- end --- end --- end - function commands.uselibrary(specification) -- todo: reporter local name = specification.name if name and name ~= "" then @@ -73,6 +42,11 @@ function commands.uselibrary(specification) -- todo: reporter local onlyonce = specification.onlyonce local files = utilities.parsers.settings_to_array(name) local truename = environment.truefilename + local function found(filename) + local somename = truename and truename(filename) or filename + local foundname = getreadfilename("any",".",somename) + return foundname ~= "" and foundname + end for i=1,#files do local filename = files[i] if loaded[filename] then @@ -81,20 +55,31 @@ function commands.uselibrary(specification) -- todo: reporter if onlyonce then loaded[filename] = true -- todo: base this on return value end - local done = false - for i=1,#patterns do - local somename = format(patterns[i],filename) - if truename then - somename = truename(somename) + local foundname = nil + local barename = removesuffix(filename) + -- direct search (we have an explicit suffix) + if barename ~= filename then + foundname = found(filename) + if trace_libraries then + report_library("checking %a: %s",filename,foundname or "not found") end - local foundname = resolvers.getreadfilename("any",".",somename) or "" - if foundname ~= "" then - action(name,foundname) - done = true - break + end + if not foundname then + -- pattern based search + for i=1,#patterns do + local wanted = format(patterns[i],barename) + foundname = found(wanted) + if trace_libraries then + report_library("checking %a as %a: %s",filename,wanted,foundname or "not found") + end + if foundname then + break + end end end - if failure and not done then + if foundname then + action(name,foundname) + elseif failure then failure(name) end end diff --git a/tex/context/base/luat-cod.lua b/tex/context/base/luat-cod.lua index c16a3b110..c436ee6d7 100644 --- a/tex/context/base/luat-cod.lua +++ b/tex/context/base/luat-cod.lua @@ -162,7 +162,7 @@ local function target_file(name) return targetpath .. "/" .. name end -local function find_read_file (id,name) +local function find_read_file(id,name) return source_file(name) end diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 8541081c8..469b8c6dd 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 5160a3765..92da8bdc0 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index a7b7b83d0..d82d95d6b 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 : 07/09/14 10:26:17 +-- merge date : 07/10/14 13:14:58 do -- begin closure to overcome local limits and interference -- cgit v1.2.3