diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lang-ini.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/lang-ini.lua | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-ini.lua b/Master/texmf-dist/tex/context/base/lang-ini.lua index 4ae7656d354..64221325338 100644 --- a/Master/texmf-dist/tex/context/base/lang-ini.lua +++ b/Master/texmf-dist/tex/context/base/lang-ini.lua @@ -91,6 +91,23 @@ end -- patterns=en -- patterns=en,de +local function validdata(dataset,what,tag) + if dataset then + local data = dataset.data + if not data or data == "" then + return nil + elseif dataset.compression == "zlib" then + data = zlib.decompress(data) + if dataset.length and dataset.length ~= #data then + report_initialization("compression error in %a for language %a","patterns",what,tag) + end + return data + else + return data + end + end +end + local function loaddefinitions(tag,specification) statistics.starttiming(languages) local data, instance = resolve(tag) @@ -113,15 +130,21 @@ local function loaddefinitions(tag,specification) dataused[definition] = definition local filename = "lang-" .. definition .. ".lua" local fullname = resolvers.findfile(filename) or "" + if fullname == "" then + fullname = resolvers.findfile(filename .. ".gz") or "" + end if fullname ~= "" then if trace_patterns then report_initialization("loading definition %a for language %a from %a",definition,tag,fullname) end - local defs = dofile(fullname) -- use regular loader instead + local suffix, gzipped = gzip.suffix(fullname) + local defs = table.load(fullname,gzipped and gzip.load) if defs then -- todo: version test ok, nofloaded = true, nofloaded + 1 - instance:patterns (defs.patterns and defs.patterns .data or "") - instance:hyphenation(defs.exceptions and defs.exceptions.data or "") + -- instance:patterns (defs.patterns and defs.patterns .data or "") + -- instance:hyphenation(defs.exceptions and defs.exceptions.data or "") + instance:patterns (validdata(defs.patterns, "patterns", tag) or "") + instance:hyphenation(validdata(defs.exceptions,"exceptions",tag) or "") else report_initialization("invalid definition %a for language %a in %a",definition,tag,filename) end @@ -329,13 +352,15 @@ languages.associate('fr','latn','fra') statistics.register("loaded patterns", function() local result = languages.logger.report() if result ~= "none" then - return result +-- return result + return format("%s, load time: %s",result,statistics.elapsedtime(languages)) end end) -statistics.register("language load time", function() - return statistics.elapsedseconds(languages, format(", nofpatterns: %s",nofloaded)) -end) +-- statistics.register("language load time", function() +-- -- often zero so we can merge that in the above +-- return statistics.elapsedseconds(languages, format(", nofpatterns: %s",nofloaded)) +-- end) -- interface |