summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl2
-rw-r--r--tex/context/base/mkxl/libs-imp-foreign.lmt58
-rw-r--r--tex/context/base/mkxl/libs-imp-lz4.lmt46
-rw-r--r--tex/context/base/mkxl/libs-imp-lzo.lmt37
-rw-r--r--tex/context/base/mkxl/libs-imp-zstd.lmt50
-rw-r--r--tex/context/base/mkxl/libs-ini.mkxl11
-rw-r--r--tex/context/base/mkxl/mlib-scn.lmt11
8 files changed, 151 insertions, 66 deletions
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()