From a2ebcf294b4f2b10a3ecef1d1d3c7de7694c498c Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 6 May 2021 23:50:45 +0200 Subject: 2021-05-06 23:34:00 --- tex/context/base/mkii/cont-new.mkii | 2 +- tex/context/base/mkii/context.mkii | 2 +- tex/context/base/mkiv/cont-new.mkiv | 2 +- tex/context/base/mkiv/context.mkiv | 2 +- tex/context/base/mkiv/libs-ini.lua | 2 +- tex/context/base/mkiv/status-files.pdf | Bin 23956 -> 23958 bytes tex/context/base/mkiv/status-lua.pdf | Bin 225363 -> 225830 bytes tex/context/base/mkxl/cont-new.mkxl | 2 +- tex/context/base/mkxl/context.mkxl | 2 +- tex/context/base/mkxl/libs-imp-foreign.lmt | 58 +-------------------- tex/context/base/mkxl/libs-imp-lz4.lmt | 46 ++++++++++++++++ tex/context/base/mkxl/libs-imp-lzo.lmt | 37 +++++++++++++ tex/context/base/mkxl/libs-imp-zstd.lmt | 50 ++++++++++++++++++ tex/context/base/mkxl/libs-ini.mkxl | 11 +++- tex/context/base/mkxl/mlib-scn.lmt | 11 ++-- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 16 files changed, 157 insertions(+), 72 deletions(-) create mode 100644 tex/context/base/mkxl/libs-imp-lz4.lmt create mode 100644 tex/context/base/mkxl/libs-imp-lzo.lmt (limited to 'tex') diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 148bec8d9..119202772 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2021.05.05 19:22} +\newcontextversion{2021.05.06 23:31} %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/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 6d7654636..fd62edc3b 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2021.05.05 19:22} +\edef\contextversion{2021.05.06 23:31} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index f8620d2dc..44bbf2253 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.05.05 19:22} +\newcontextversion{2021.05.06 23:31} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index c5d091ace..1e4ecb731 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2021.05.05 19:22} +\edef\contextversion{2021.05.06 23:31} %D Kind of special: diff --git a/tex/context/base/mkiv/libs-ini.lua b/tex/context/base/mkiv/libs-ini.lua index 5b8390df2..ed3fb842f 100644 --- a/tex/context/base/mkiv/libs-ini.lua +++ b/tex/context/base/mkiv/libs-ini.lua @@ -137,7 +137,7 @@ function libraries.optionalloaded(name,libnames) for i=1,#libnames do local libname = libnames[i] local filename = foundlibraries[libname] - if filename then + if filename and filename ~= "" then libnames[i] = filename else report("unable to locate library %a",libname) diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf index f9c75ae72..7d80be3cf 100644 Binary files a/tex/context/base/mkiv/status-files.pdf and b/tex/context/base/mkiv/status-files.pdf differ diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf index a56c1254f..4b993fa62 100644 Binary files a/tex/context/base/mkiv/status-lua.pdf and b/tex/context/base/mkiv/status-lua.pdf differ diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index 5be5fa23f..e9e866256 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2021.05.05 19:22} +\newcontextversion{2021.05.06 23:31} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl index 5b5bdb60a..25fc6ca26 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2021.05.05 19:22} +\immutable\edef\contextversion{2021.05.06 23:31} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/libs-imp-foreign.lmt b/tex/context/base/mkxl/libs-imp-foreign.lmt index 7e4ec9239..7b1773078 100644 --- a/tex/context/base/mkxl/libs-imp-foreign.lmt +++ b/tex/context/base/mkxl/libs-imp-foreign.lmt @@ -43,6 +43,8 @@ local foreign = { types = libforeign.types, abivalues = libforeign.abivalues, totable = libforeign.totable, + newbuffer = libforeign.newbuffer, + getbuffer = libforeign.getbuffer, load = function(name) if okay() then local fullname = resolvers.findlib(name) @@ -61,59 +63,3 @@ package .loaded[libname] = foreign optional.loaded[libname] = foreign return foreign - --- A simple test: - --- \setupbodyfont[dejavu,10pt] --- --- \starttext --- --- \registerctxluafile{libs-imp-foreign}{autosuffix} --- --- \startluacode --- --- local foreign = optional.loaded.foreign --- --- local kplib = (os.platform == "win64" and "kpathsea*w64") --- or (os.platform == "win32" and "kpathsea*w32") --- or "libkpathsea" --- --- local kpse = foreign.load(kplib) --- --- local set_program_name = kpse.kpse_set_program_name --- local find_file = kpse.kpse_find_file --- --- set_program_name:types { "string", "string" } --- find_file :types { ret = "string", "string", "int", "int" } --- --- set_program_name("pdftex","pdftex") --- --- local function lookup(filename,filetype,n) --- local c = os.clock() --- for i=1,n do --- if find_file(filename,filetype,0) then --- -- okay --- end --- end --- c = os.clock() - c --- --- local NC, BC, NR = context.NC, context.BC, context.NR --- --- context.starttabulate() --- BC() context("asked") NC() context.type(filename) NC() NR() --- BC() context("found") NC() context.type(find_file(filename,filetype,0)) NC() NR() --- if n > 0 then --- BC() context("times") NC() context(n) NC() NR() --- BC() context("seconds") NC() context(" %0.3f",c) NC() NR() --- BC() context("lookup") NC() context(" %0.6f",c/n) NC() NR() --- end --- context.stoptabulate() --- end --- --- lookup("oeps.tex", 26,10000) --- lookup("metafun.mp", 16, 5000) --- lookup("logo10.afm", 4, 2500) --- --- \stopluacode --- --- \stoptext diff --git a/tex/context/base/mkxl/libs-imp-lz4.lmt b/tex/context/base/mkxl/libs-imp-lz4.lmt new file mode 100644 index 000000000..2367a640d --- /dev/null +++ b/tex/context/base/mkxl/libs-imp-lz4.lmt @@ -0,0 +1,46 @@ +if not modules then modules = { } end modules ['libs-imp-lz4'] = { + version = 1.001, + comment = "companion to luat-lib.mkxl", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- https://packages.msys2.org/package/mingw-w64-x86_64-lz4?repo=mingw64 + +-- Instead of linking in libs like this we now do them optional. After all, once +-- we start adding more and more stuff statically we en dup with a mess. + +local libname = "lz4" +local libfile = "liblz4" + +local lz4lib = resolvers.libraries.validoptional(libname) + +if not lz4lib then return end + +local lz4_compress = lz4lib.compress +----- lz4_decompress = lz4lib.decompress +local lz4_decompresssize = lz4lib.decompresssize +local lz4_framecompress = lz4lib.framecompress +local lz4_framedecompress = lz4lib.framedecompress + +local function okay() + if resolvers.libraries.optionalloaded(libname,libfile) then + okay = function() return true end + else + okay = function() return false end + end + return okay() +end + +local lz4 = { + compress = function (...) return okay() and lz4_compress (...) end, + -- decompress = function (...) return okay() and lz4_decompress (...) end, + decompresssize = function (...) return okay() and lz4_decompresssize (...) end, + framecompress = function (...) return okay() and lz4_framecompress (...) end, + framedecompress = function (...) return okay() and lz4_framedecompress(...) end, +} + +package.loaded[libname] = lz4 + +return lz4 diff --git a/tex/context/base/mkxl/libs-imp-lzo.lmt b/tex/context/base/mkxl/libs-imp-lzo.lmt new file mode 100644 index 000000000..1cc84a9e3 --- /dev/null +++ b/tex/context/base/mkxl/libs-imp-lzo.lmt @@ -0,0 +1,37 @@ +if not modules then modules = { } end modules ['libs-imp-lzo'] = { + version = 1.001, + comment = "companion to luat-lib.mkxl", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- https://packages.msys2.org/package/mingw-w64-x86_64-lzo2?repo=mingw64 + +local libname = "lzo" +local libfile = "liblzo" + +local lzolib = resolvers.libraries.validoptional(libname) + +if not lzolib then return end + +local lzo_compress = lzolib.compress +local lzo_decompresssize = lzolib.decompresssize + +local function okay() + if resolvers.libraries.optionalloaded(libname,libfile) then + okay = function() return true end + else + okay = function() return false end + end + return okay() +end + +local lzo = { + compress = function (...) return okay() and lzo_compress (...) end, + decompresssize = function (...) return okay() and lzo_decompresssize(...) end, +} + +package.loaded[libname] = lzo + +return lzo diff --git a/tex/context/base/mkxl/libs-imp-zstd.lmt b/tex/context/base/mkxl/libs-imp-zstd.lmt index a240c1ec7..958c34cc4 100644 --- a/tex/context/base/mkxl/libs-imp-zstd.lmt +++ b/tex/context/base/mkxl/libs-imp-zstd.lmt @@ -6,6 +6,10 @@ if not modules then modules = { } end modules ['libs-imp-zstd'] = { license = "see context related readme files" } +-- Instead of linking in libs like this we now do them optional. After all, once +-- we start adding more and more stuff statically we en dup with a mess. In fact, +-- this lib was the reason for no longer embedding lzo and lz4. + -- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/curl/libzstd.dll -- require("libs-imp-zstd.lmt") -- only loads @@ -46,3 +50,49 @@ package.loaded[libname] = zstd return zstd +-- local foreign = optional.loaded.foreign +-- local newbuffer = foreign.newbuffer +-- local getbuffer = foreign.getbuffer +-- +-- local zstd = foreign.load("libzstd") +-- +-- local ZSTD_compressBound = zstd:register { +-- name = "ZSTD_compressBound", +-- result = "int", +-- arguments = { "int" }, +-- } +-- +-- local ZSTD_getFrameContentSize = zstd:register { +-- name = "ZSTD_getFrameContentSize", +-- result = "int", +-- arguments = { "pointer", "int" }, +-- } +-- +-- local ZSTD_compress = zstd:register { +-- name = "ZSTD_compress", +-- result = "int", +-- arguments = { "pointer", "int", "string", "int", "int" }, +-- arguments = { "pointer", "int", "pointer", "int", "int" }, +-- } +-- +-- local ZSTD_decompress = zstd:register { +-- name = "ZSTD_decompress", +-- result = "int", +-- arguments = { "pointer", "int", "string", "int" }, +-- } +-- +-- local function zstd_compress(source,level) +-- local sourcesize = #source +-- local targetsize = ZSTD_compressBound(sourcesize) +-- local target = newbuffer(targetsize) +-- local result = ZSTD_compress(target,targetsize,source,sourcesize,tonumber(level) or 3) +-- return getbuffer(target,result) +-- end +-- +-- local function zstd_decompress(source) +-- local sourcesize = #source +-- local targetsize = ZSTD_getFrameContentSize(source,sourcesize) +-- local target = newbuffer(targetsize) +-- local result = ZSTD_decompress(target,targetsize,source,sourcesize) +-- return getbuffer(target,result) +-- end diff --git a/tex/context/base/mkxl/libs-ini.mkxl b/tex/context/base/mkxl/libs-ini.mkxl index d77046fbf..ef24536bf 100644 --- a/tex/context/base/mkxl/libs-ini.mkxl +++ b/tex/context/base/mkxl/libs-ini.mkxl @@ -13,6 +13,8 @@ \registerctxluafile{libs-ini}{} % shared with mkiv +% These are used by the graphic converters: + \registerctxluafile{libs-imp-curl}{autosuffix} \registerctxluafile{libs-imp-ghostscript}{autosuffix} \registerctxluafile{libs-imp-graphicsmagick}{autosuffix} @@ -22,11 +24,16 @@ % \registerctxluafile{libs-imp-mysql}{autosuffix} % \registerctxluafile{libs-imp-sqlite}{autosuffix} % \registerctxluafile{libs-imp-postgress}{autosuffix} + +% \registerctxluafile{libs-imp-lzo}{autosuffix} +% \registerctxluafile{libs-imp-lz4}{autosuffix} +% \registerctxluafile{libs-imp-zstd}{autosuffix} + % \registerctxluafile{libs-imp-kpse}{autosuffix} +% \registerctxluafile{libs-imp-hb}{autosuffix} \unprotect -% \permanent\protected\def\uselibrary[#1]% -% {\clf_uselibrary{#1}} +% \permanent\protected\def\uselibrary[#1]{\clf_uselibrary{#1}} \protect \endinput diff --git a/tex/context/base/mkxl/mlib-scn.lmt b/tex/context/base/mkxl/mlib-scn.lmt index 786ec2631..0a0e96105 100644 --- a/tex/context/base/mkxl/mlib-scn.lmt +++ b/tex/context/base/mkxl/mlib-scn.lmt @@ -398,12 +398,11 @@ local function getparameter() end v = vl end --- if v == nil then --- return injectnumeric(0) --- else --- return get(v) --- end - return v or 0 + if v == nil then + return 0 + else + return v + end end local function hasparameter() diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index b642df123..7a2804026 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 : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2021-05-05 19:22 +-- merge date : 2021-05-06 23:31 do -- begin closure to overcome local limits and interference -- cgit v1.2.3