diff options
Diffstat (limited to 'tex')
40 files changed, 1690 insertions, 100 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index d2b57d4a6..340f7ad1b 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{2019.12.31 11:28} +\newcontextversion{2020.01.09 11:17} %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 d90c73f8d..c167e30e3 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{2019.12.31 11:28} +\edef\contextversion{2020.01.09 11:17} %D For those who want to use this: diff --git a/tex/context/base/mkiv/colo-ini.lua b/tex/context/base/mkiv/colo-ini.lua index d39e87878..7d946c729 100644 --- a/tex/context/base/mkiv/colo-ini.lua +++ b/tex/context/base/mkiv/colo-ini.lua @@ -1101,7 +1101,7 @@ local function failure(name) end local function usecolors(name) - commands.uselibrary { + resolvers.uselibrary { category = "color definition", name = name, patterns = patterns, diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 59829a0de..00d450516 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{2019.12.31 11:28} +\newcontextversion{2020.01.09 11:17} %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/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 2d821e5a4..bb60e8ad3 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{2019.12.31 11:28} +\edef\contextversion{2020.01.09 11:17} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index c20380d19..a2e1ef4c5 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.12.31 11:28} +\edef\contextversion{2020.01.09 11:17} \edef\contextkind {beta} %D Kind of special: @@ -590,6 +590,8 @@ \loadmarkfile{syst-cmp} % compatibility stuff moved here +\loadmkxlfile{libs-ini} + \loadmarkfile{cont-run} % the main runner (used in cont-yes.mkiv) \setupcurrentlanguage[\defaultlanguagetag] diff --git a/tex/context/base/mkiv/data-lst.lua b/tex/context/base/mkiv/data-lst.lua index 8e0061c4d..f349409e4 100644 --- a/tex/context/base/mkiv/data-lst.lua +++ b/tex/context/base/mkiv/data-lst.lua @@ -25,15 +25,24 @@ local knownvariables = resolvers.knownvariables local report_lists = logs.reporter("resolvers","lists") local report_resolved = logs.reporter("system","resolved") +local function tabstr(str) + if not str then + return "unset" + elseif type(str) == 'table' then + return concat(str," | ") + else + return str + end +end + function listers.variables(pattern) local result = resolvers.knownvariables(pattern) - local unset = { "unset" } for key, value in sortedhash(result) do report_lists(key) - report_lists(" env: % | t",value.environment or unset) - report_lists(" var: % | t",value.variable or unset) - report_lists(" exp: % | t",value.expansion or unset) - report_lists(" res: % | t",value.resolved or unset) + report_lists(" env: %s",tabstr(value.environment)) + report_lists(" var: %s",tabstr(value.variable)) + report_lists(" exp: %s",tabstr(value.expansion)) + report_lists(" res: %s",tabstr(value.resolved)) end end diff --git a/tex/context/base/mkiv/data-res.lua b/tex/context/base/mkiv/data-res.lua index 01b8f1aca..d8ad81656 100644 --- a/tex/context/base/mkiv/data-res.lua +++ b/tex/context/base/mkiv/data-res.lua @@ -1023,7 +1023,7 @@ function resolvers.renewcache() end local function isreadable(name) - local readable = isfile(name) -- not file.is_readable(name) asit can be a dir + local readable = isfile(name) -- not file.is_readable(name) as it can be a dir if trace_details then if readable then report_resolving("file %a is readable",name) diff --git a/tex/context/base/mkiv/file-lib.lua b/tex/context/base/mkiv/file-lib.lua index 8ef1a48d3..7fc599d00 100644 --- a/tex/context/base/mkiv/file-lib.lua +++ b/tex/context/base/mkiv/file-lib.lua @@ -93,5 +93,3 @@ function resolvers.uselibrary(specification) -- todo: reporter end end end - -commands.uselibrary = resolvers.uselibrary -- for the moment diff --git a/tex/context/base/mkiv/libs-imp-curl.lua b/tex/context/base/mkiv/libs-imp-curl.lua new file mode 100644 index 000000000..b30739794 --- /dev/null +++ b/tex/context/base/mkiv/libs-imp-curl.lua @@ -0,0 +1,296 @@ +if not modules then modules = { } end modules ['libs-imp-curl'] = { + 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" +} + +-- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/curl/libcurl.dll + +local libname = "curl" +local libfile = "libcurl" + +local curllib = resolvers.libraries.validoptional(libname) + +if not curllib then return end + +-- We're good, so we continue. + +local next, type = next, type +local lower, gsub = string.lower, string.gsub + +local mapping = { + ["acceptencoding"] = 102, + ["accepttimeoutms"] = 212, + ["addressscope"] = 171, + ["append"] = 50, + ["autoreferer"] = 58, + ["buffersize"] = 98, + ["cainfo"] = 65, + ["capath"] = 97, + ["certinfo"] = 172, + -- ["chunkbgnfunction"] = 198, + ["chunkdata"] = 201, + -- ["chunkendfunction"] = 199, + ["closepolicy"] = 72, + ["closesocketdata"] = 209, + -- ["closesocketfunction"] = 208, + ["connectonly"] = 141, + ["connecttimeout"] = 78, + ["connecttimeoutms"] = 156, + -- ["convfromnetworkfunction"] = 142, + -- ["convfromutf8function"] = 144, + -- ["convtonetworkfunction"] = 143, + ["cookie"] = 22, + ["cookiefile"] = 31, + ["cookiejar"] = 82, + ["cookielist"] = 135, + ["cookiesessionv"] = 96, + ["copypostfields"] = 165, + ["crlf"] = 27, + ["crlfile"] = 169, + ["customrequest"] = 36, + ["debugdata"] = 95, + -- ["debugfunction"] = 94, + ["dirlistonly"] = 48, + ["dnscachetimeout"] = 92, + ["dnsinterface"] = 221, + ["dnslocalip4"] = 222, + ["dnslocalip6"] = 223, + ["dnsservers"] = 211, + ["dnsuseglobalcache"] = 91, + ["egdsocket"] = 77, + ["errorbuffer"] = 10, + ["expect100timeoutms"] = 227, + ["failonerror"] = 45, + ["file"] = 1, + ["filetime"] = 69, + ["fnmatchdata"] = 202, + -- ["fnmatchfunction"] = 200, + ["followlocation"] = 52, + ["forbidreuse"] = 75, + ["freshconnect"] = 74, + ["ftpaccount"] = 134, + ["ftpalternativetouser"] = 147, + ["ftpcreatemissingdirs"] = 110, + ["ftpfilemethod"] = 138, + ["ftpresponsetimeout"] = 112, + ["ftpskippasvip"] = 137, + ["ftpsslccc"] = 154, + ["ftpuseeprt"] = 106, + ["ftpuseepsv"] = 85, + ["ftpusepret"] = 188, + ["ftpport"] = 17, + ["ftpsslauth"] = 129, + ["gssapidelegation"] = 210, + ["header"] = 42, + ["headerdata"] = 29, + -- ["headerfunction"] = 79, + ["http200aliases"] = 104, + ["httpcontentdecoding"] = 158, + ["httptransferdecoding"] = 157, + ["httpversion"] = 84, + ["httpauth"] = 107, + ["httpget"] = 80, + ["httpheader"] = 23, + ["httppost"] = 24, + ["httpproxytunnel"] = 61, + ["ignorecontentlength"] = 136, + ["infile"] = 9, + ["infilesize"] = 14, + ["infilesizelarge"] = 115, + ["interface"] = 62, + ["interleavedata"] = 195, + -- ["interleavefunction"] = 196, + ["ioctldata"] = 131, + -- ["ioctlfunction"] = 130, + ["ipresolve"] = 113, + ["issuercert"] = 170, + ["keypasswd"] = 26, + ["krblevel"] = 63, + ["localport"] = 139, + ["localportrange"] = 140, + ["loginoptions"] = 224, + ["lowspeedlimit"] = 19, + ["lowspeedtime"] = 20, + ["mailauth"] = 217, + ["mailfrom"] = 186, + ["mailrcpt"] = 187, + ["maxrecvspeedlarge"] = 146, + ["maxsendspeedlarge"] = 145, + ["maxconnects"] = 71, + ["maxfilesize"] = 114, + ["maxfilesizelarge"] = 117, + ["maxredirs"] = 68, + ["netrc"] = 51, + ["netrcfile"] = 118, + ["newdirectoryperms"] = 160, + ["newfileperms"] = 159, + ["nobody"] = 44, + ["noprogress"] = 43, + ["noproxy"] = 177, + ["nosignal"] = 99, + ["opensocketdata"] = 164, + -- ["opensocketfunction"] = 163, + ["password"] = 174, + ["port"] = 3, + ["post"] = 47, + -- ["postfields"] = 15, + -- ["postfieldsize"] = 60, + -- ["postfieldsizelarge"] = 120, + ["postquote"] = 39, + ["postredir"] = 161, + ["prequote"] = 93, + ["private"] = 103, + ["progressdata"] = 57, + -- ["progressfunction"] = 56, + ["protocols"] = 181, + ["proxy"] = 4, + ["proxytransfermode"] = 166, + ["proxyauth"] = 111, + ["proxypassword"] = 176, + ["proxyport"] = 59, + ["proxytype"] = 101, + ["proxyusername"] = 175, + ["proxyuserpwd"] = 6, + ["put"] = 54, + ["quote"] = 28, + ["randomfile"] = 76, + ["range"] = 7, + ["readdata"] = 9, + -- ["readfunction"] = 12, + ["redirprotocols"] = 182, + ["referer"] = 16, + ["resolve"] = 203, + ["resumefrom"] = 21, + ["resumefromlarge"] = 116, + ["rtspclientcseq"] = 193, + ["rtsprequest"] = 189, + ["rtspservercseq"] = 194, + ["rtspsessionid"] = 190, + ["rtspstreamuri"] = 191, + ["rtsptransport"] = 192, + ["rtspheader"] = 23, + ["saslir"] = 218, + ["seekdata"] = 168, + -- ["seekfunction"] = 167, + ["serverresponsetimeout"] = 112, + ["share"] = 100, + ["sockoptdata"] = 149, + -- ["sockoptfunction"] = 148, + ["socks5gssapinec"] = 180, + ["socks5gssapiservice"] = 179, + ["sshauthtypes"] = 151, + ["sshhostpublickeymd5"] = 162, + ["sshkeydata"] = 185, + -- ["sshkeyfunction"] = 184, + ["sshknownhosts"] = 183, + ["sshprivatekeyfile"] = 153, + ["sshpublickeyfile"] = 152, + ["sslcipherlist"] = 83, + ["sslctxdata"] = 109, + -- ["sslctxfunction"] = 108, + ["sslenablealpn"] = 226, + ["sslenablenpn"] = 225, + ["ssloptions"] = 216, + ["sslsessionidcache"] = 150, + ["sslverifyhost"] = 81, + ["sslverifypeer"] = 64, + ["sslcert"] = 25, + ["sslcerttype"] = 86, + ["sslengine"] = 89, + ["sslenginedefault"] = 90, + ["sslkey"] = 87, + ["sslkeytype"] = 88, + ["sslversion"] = 32, + ["stderr"] = 37, + ["tcpkeepalive"] = 213, + ["tcpkeepidle"] = 214, + ["tcpkeepintvl"] = 215, + ["tcpnodelay"] = 121, + ["telnetoptions"] = 70, + ["tftpblksize"] = 178, + ["timecondition"] = 33, + ["timeout"] = 13, + ["timeoutms"] = 155, + ["timevalue"] = 34, + ["tlsauthpassword"] = 205, + ["tlsauthtype"] = 206, + ["tlsauthusername"] = 204, + ["transferencoding"] = 207, + ["transfertext"] = 53, + ["unrestrictedauth"] = 105, + ["upload"] = 46, + ["url"] = 2, + ["usessl"] = 119, + ["useragent"] = 18, + ["username"] = 173, + ["userpwd"] = 5, + ["verbose"] = 41, + ["wildcardmatch"] = 197, + ["writedata"] = 1, + -- ["writefunction"] = 11, + ["writeheader"] = 29, + ["writeinfo"] = 40, + ["xferinfodata"] = 57, + -- ["xferinfofunction"] = 219, + ["xoauth2bearer"] = 220, +} + +table.setmetatableindex(mapping,function(t,k) + local s = gsub(lower(k),"[^a-z0-9]","") + local v = rawget(t,s) or false + t[k] = v + return v +end) + +local curl_fetch = curllib.fetch +local curl_escape = curllib.escape +local curl_unescape = curllib.unescape +local curl_getversion = curllib.getversion + +local report = logs.reporter(libname) + +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 function fetch(options) + if okay() then + local t = type(options) + if t == "table" then + local o = { } + for name, value in next, options do + local index = mapping[name] + if index then + o[index] = value + end + end + return curl_fetch(o) + elseif t == "string" then + return curl_fetch { [mapping.url] = options } + else + report("invalid argument") + end + end +end + +local curl = { + getversion = function () return okay() and curl_getversion() end, + escape = function (s) return okay() and curl_escape (s) end, + unescape = function (s) return okay() and curl_unescape (s) end, + fetch = fetch, +} + +-- inspect(curl.fetch("http://www.pragma-ade.com/index.html")) +-- inspect(curl.fetch { url = "http://www.pragma-ade.com/index.html" }) + +package.loaded[libname] = curl + +return curl diff --git a/tex/context/base/mkiv/libs-imp-ghostscript.lua b/tex/context/base/mkiv/libs-imp-ghostscript.lua new file mode 100644 index 000000000..b129a58c1 --- /dev/null +++ b/tex/context/base/mkiv/libs-imp-ghostscript.lua @@ -0,0 +1,111 @@ +if not modules then modules = { } end modules ['libs-imp-ghostscript'] = { + 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", +} + +local libname = "ghostscript" +local libfile = "gsdll64" -- what on unix? + +local gslib = resolvers.libraries.validoptional(libname) + +if not gslib then return end + +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 insert = table.insert +local formatters = string.formatters + +local ghostscript = utilities.ghostscript or { } +utilities.ghostscript = ghostscript + +local gs_execute = gslib.execute +local nofruns = 0 +local report = logs.reporter(libname) + +function ghostscript.convert(specification) + if okay() then + -- + nofruns = nofruns + 1 + statistics.starttiming(ghostscript) + -- + local inputname = specification.inputname + if not inputname or inputname == "" then + report("invalid run %s, no inputname specified",nofruns) + statistics.stoptiming(ghostscript) + return false + end + local outputname = specification.outputname + if not outputname or outputname == "" then + outputname = file.replacesuffix(inputname,"pdf") + end + -- + if not lfs.isfile(inputname) then + report("invalid run %s, input file %a is not found",nofruns,inputname) + statistics.stoptiming(ghostscript) + return false + end + -- + local device = specification.device + if not device or device == "" then + device = "pdfwrite" + end + -- + local code = specification.code + if not code or code == "" then + code = ".setpdfwrite" + end + -- + local options = specification.options or { } + -- + insert(options,"-dNOPAUSE") + insert(options,"-dBATCH") + insert(options,"-dSAFER") + insert(options,formatters["-sDEVICE=%s"](device)) + insert(options,formatters["-sOutputFile=%s"](outputname)) + insert(options,"-c") + insert(options,code) + insert(options,"-f") + insert(options,inputname) + -- + report("run %s, input file %a, outputfile %a",nofruns,inputname,outputname) + report("") + local done = gslib_execute(options) + report("") + -- + statistics.stoptiming(ghostscript) + if done then + return outputname + else + report("run %s quit with errors",nofruns) + return false + end + end +end + +function ghostscript.statistics(report) + local runtime = statistics.elapsedtime(ghostscript) + if report then + report("nofruns %s, runtime %s",nofruns,runtime) + else + return { + runtime = runtime, + nofruns = nofruns, + } + end +end + +-- for i=1,100 do +-- ghostscript.convert { inputname = "temp.eps" } +-- ghostscript.convert { inputname = "t:/escrito/tiger.eps" } +-- end +-- ghostscript.statistics(true) diff --git a/tex/context/base/mkiv/libs-imp-graphicsmagick.lua b/tex/context/base/mkiv/libs-imp-graphicsmagick.lua new file mode 100644 index 000000000..6f5d1d967 --- /dev/null +++ b/tex/context/base/mkiv/libs-imp-graphicsmagick.lua @@ -0,0 +1,77 @@ +if not modules then modules = { } end modules ['libs-imp-graphicsmagick'] = { + 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", +} + +local libname = "graphicsmagick" +local libfile = { "CORE_RL_magick_", "CORE_RL_wand_" } + +local gmlib = resolvers.libraries.validoptional(libname) + +if not gmlib then return end + +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 graphicsmagick = utilities.graphicsmagick or { } +utilities.graphicsmagick = graphicsmagick +utilities.graphicmagick = graphicsmagick + +local gm_execute = gmlib.execute +local nofruns = 0 +local report = logs.reporter(libname) + +function graphicsmagick.convert(specification) + if okay() then + -- + nofruns = nofruns + 1 + statistics.starttiming(graphicsmagick) + -- + local inputname = specification.inputname + if not inputname or inputname == "" then + report("invalid run %s, no inputname specified",nofruns) + statistics.stoptiming(graphicsmagick) + return false + end + local outputname = specification.outputname + if not outputname or outputname == "" then + outputname = file.replacesuffix(inputname,"pdf") + end + -- + if not lfs.isfile(inputname) then + report("invalid run %s, input file %a is not found",nofruns,inputname) + statistics.stoptiming(graphicsmagick) + return false + end + -- + report("run %s, input file %a, outputfile %a",nofruns,inputname,outputname) + -- + gm_execute { inputfile = inputname, outputfile = outputname } + -- + statistics.stoptiming(graphicsmagick) + end +end + +function graphicsmagick.statistics(report) + local runtime = statistics.elapsedtime(graphicsmagick) + if report then + report("nofruns %s, runtime %s",nofruns,runtime) + else + return { + runtime = runtime, + nofruns = nofruns, + } + end +end + +-- graphicsmagick.convert { inputname = "t:/sources/hacker.jpg", outputname = "e:/tmp/hacker.png" } +-- graphicsmagick.statistics(true) diff --git a/tex/context/base/mkiv/libs-imp-mysql.lua b/tex/context/base/mkiv/libs-imp-mysql.lua new file mode 100644 index 000000000..b3896acd4 --- /dev/null +++ b/tex/context/base/mkiv/libs-imp-mysql.lua @@ -0,0 +1,196 @@ +if not modules then modules = { } end modules ['libs-imp-mysql'] = { + version = 1.001, + comment = "companion to util-sql.lua", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/mysql/libmysql.dll + +local libname = "mysql" +local libfile = "libmysql" + +local mysqllib = resolvers.libraries.validoptional(libname) + +if not mysqllib then return end + +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 lpegmatch = lpeg.match +local setmetatable = setmetatable + +local sql = utilities.sql or require("util-sql") +local report = logs.reporter(libname) + +local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end) +local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end) + +local mysql_open = mysqllib.open +local mysql_close = mysqllib.close +local mysql_execute = mysqllib.execute +local mysql_getmessage = mysqllib.getmessage + +local helpers = sql.helpers +local methods = sql.methods +local validspecification = helpers.validspecification +local preparetemplate = helpers.preparetemplate +local querysplitter = helpers.querysplitter +local cache = { } + +local function connect(specification) + return mysql_open( + specification.database or "", + specification.username or "", + specification.password or "", + specification.host or "", + specification.port + ) +end + +local function execute_once(specification,retry) + if okay() then + if trace_sql then + report("executing mysql") + end + if not validspecification(specification) then + report("error in specification") + end + local query = preparetemplate(specification) + if not query then + report("error in preparation") + return + else + query = lpegmatch(querysplitter,query) + end + local base = specification.database -- or specification.presets and specification.presets.database + if not base then + report("no database specified") + return + end + local result = { } + local keys = { } + local id = specification.id + local db = nil + if id then + local session = cache[id] + if session then + db = session.db + else + db = connect(specification) + if not db then + report("no session database specified") + else + cache[id] = { + specification = specification, + db = db, + } + end + end + else + db = connect(specification) + end + if not db then + report("no database opened") + else + local converter = specification.converter + local nofrows = 0 + local callback = nil + if converter then + local convert = converter.mysql + callback = function(nofcolumns,values,fields) + nofrows = nofrows + 1 + result[nofrows] = convert(values) + end + else + local column = { } + callback = function(nofcolumns,values,fields) + for i=1,nofcolumns do + local field + if fields then + field = fields[i] + keys[i+1] = field + else + field = keys[i] + end + if field then + column[field] = values[i] + end + end + nofrows = nofrows + 1 + result[nofrows] = column + end + end + for i=1,#query do + local okay = mysql_execute(db,query[i],callback) + if not okay then + if id and option == "retry" and i == 1 then + report("error: %s, retrying to connect",mysql_getmessage(db)) + mysql_close(db) + cache[id] = nil + return execute_once(specification,false) + else + report("error: %s",mysql_getmessage(db)) + end + end + end + end + if db and not id then + mysql_close(db) + end + -- bonus + local one = result[1] + if one then + setmetatable(result,{ __index = one } ) + end + -- + return result, keys + else + report("error: ","no library loaded") + end +end + +local function execute(specification) + return execute_once(specification,true) +end + +-- Here we build the dataset stepwise so we don't use the data hack that +-- is used in the client variant. + +local wraptemplate = [[ +local converters = utilities.sql.converters +local deserialize = utilities.sql.deserialize + +local tostring = tostring +local tonumber = tonumber +local booleanstring = string.booleanstring + +%s + +return function(cells) + -- %s (not needed) + -- %s (not needed) + return { + %s + } +end +]] + +local celltemplate = "cells[%s]" + +methods.mysql = { + execute = execute, + usesfiles = false, + wraptemplate = wraptemplate, + celltemplate = celltemplate, +} + +package.loaded["util-sql-imp-mysql"] = methods.mysql +package.loaded[libname] = methods.mysql diff --git a/tex/context/base/mkiv/libs-imp-postgress.lua b/tex/context/base/mkiv/libs-imp-postgress.lua new file mode 100644 index 000000000..5cd04e03b --- /dev/null +++ b/tex/context/base/mkiv/libs-imp-postgress.lua @@ -0,0 +1,200 @@ +if not modules then modules = { } end modules ['libs-imp-postgress'] = { + version = 1.001, + comment = "companion to util-sql.lua", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- Not yet untested ! + +-- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/postgress/libpq.dll + +-- we can now share the code between mysql, postgress, sqlite ... todo + +local libname = "postgress" +local libfile = "libpq" + +local postgresslib = resolvers.libraries.validoptional(libname) + +if not postgresslib then return end + +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 lpegmatch = lpeg.match +local setmetatable = setmetatable + +local sql = utilities.sql or require("util-sql") +local report = logs.reporter(libname) + +local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end) +local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end) + +local postgress_open = postgresslib.open +local postgress_close = postgresslib.close +local postgress_execute = postgresslib.execute +local postgress_getmessage = postgresslib.getmessage + +local helpers = sql.helpers +local methods = sql.methods +local validspecification = helpers.validspecification +local preparetemplate = helpers.preparetemplate +local querysplitter = helpers.querysplitter -- not needed +local cache = { } + +local function connect(specification) + return postgress_open( + specification.database or "", + specification.username or "", + specification.password or "", + specification.host or "", + specification.port + ) +end + +local function execute_once(specification,retry) + if okay() then + if trace_sql then + report("executing postgress") + end + if not validspecification(specification) then + report("error in specification") + end + local query = preparetemplate(specification) + if not query then + report("error in preparation") + return + else + query = lpegmatch(querysplitter,query) -- not needed + end + local base = specification.database -- or specification.presets and specification.presets.database + if not base then + report("no database specified") + return + end + local result = { } + local keys = { } + local id = specification.id + local db = nil + if id then + local session = cache[id] + if session then + db = session.db + else + db = connect(specification) + if not db then + report("no session database specified") + else + cache[id] = { + specification = specification, + db = db, + } + end + end + else + db = connect(specification) + end + if not db then + report("no database opened") + else + local converter = specification.converter + local nofrows = 0 + local callback = nil + if converter then + local convert = converter.postgress + callback = function(nofcolumns,values,fields) + nofrows = nofrows + 1 + result[nofrows] = convert(values) + end + else + local column = { } + callback = function(nofcolumns,values,fields) + for i=1,nofcolumns do + local field + if fields then + field = fields[i] + keys[i+1] = field + else + field = keys[i] + end + if field then + column[field] = values[i] + end + end + nofrows = nofrows + 1 + result[nofrows] = column + end + end + for i=1,#query do + local okay = postgress_execute(db,query[i],callback) + if not okay then + if id and option == "retry" and i == 1 then + report("error: %s, retrying to connect",postgress_getmessage(db)) + postgress_close(db) + cache[id] = nil + return execute_once(specification,false) + else + report("error: %s",postgress_getmessage(db)) + end + end + end + end + if db and not id then + postgress_close(db) + end + -- bonus + local one = result[1] + if one then + setmetatable(result,{ __index = one } ) + end + -- + return result, keys + else + report("error: ","no library loaded") + end +end + +local function execute(specification) + return execute_once(specification,true) +end + +-- Here we build the dataset stepwise so we don't use the data hack that +-- is used in the client variant. + +local wraptemplate = [[ +local converters = utilities.sql.converters +local deserialize = utilities.sql.deserialize + +local tostring = tostring +local tonumber = tonumber +local booleanstring = string.booleanstring + +%s + +return function(cells) + -- %s (not needed) + -- %s (not needed) + return { + %s + } +end +]] + +local celltemplate = "cells[%s]" + +methods.postgress = { + execute = execute, + usesfiles = false, + wraptemplate = wraptemplate, + celltemplate = celltemplate, +} + +package.loaded["util-sql-imp-postgress"] = methods.postgress +package.loaded[libname] = methods.postgress diff --git a/tex/context/base/mkiv/libs-imp-sqlite.lua b/tex/context/base/mkiv/libs-imp-sqlite.lua new file mode 100644 index 000000000..15c3222ea --- /dev/null +++ b/tex/context/base/mkiv/libs-imp-sqlite.lua @@ -0,0 +1,187 @@ +if not modules then modules = { } end modules ['libs-imp-sqlite'] = { + version = 1.001, + comment = "companion to util-sql.lua", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- c:/data/develop/tex-context/tex/texmf-win64/bin/lib/luametatex/lua/copies/sqlite/sqlite3.dll + +local libname = "sqlite" +local libfile = "sqlite3" + +local sqlitelib = resolvers.libraries.validoptional(libname) + +if not sqlitelib then return end + +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 next, tonumber = next, tonumber +local setmetatable = setmetatable +local formatters = string.formatters + +local sql = utilities.sql or require("util-sql") +local report = logs.reporter(libname) + +local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end) +local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end) + +local sqlite_open = sqlitelib.open +local sqlite_close = sqlitelib.close +local sqlite_execute = sqlitelib.execute +local sqlite_getmessage = sqlitelib.getmessage + +local helpers = sql.helpers +local methods = sql.methods +local validspecification = helpers.validspecification +local preparetemplate = helpers.preparetemplate +local cache = { } + +-- synchronous journal_mode locking_mode 1000 logger inserts +-- +-- normal normal normal 6.8 +-- off off normal 0.1 +-- normal off normal 2.1 +-- normal persist normal 5.8 +-- normal truncate normal 4.2 +-- normal truncate exclusive 4.1 + +local f_preamble = formatters[ [[ +ATTACH `%s` AS `%s` ; +PRAGMA `%s`.synchronous = normal ; +]] ] + +local function execute(specification) + if okay() then + if trace_sql then + report("executing sqlite") + end + if not validspecification(specification) then + report("error in specification") + end + local query = preparetemplate(specification) + if not query then + report("error in preparation") + return + end + local base = specification.database -- or specification.presets and specification.presets.database + if not base then + report("no database specified") + return + end + local filename = file.addsuffix(base,"db") + local result = { } + local keys = { } + local id = specification.id + local db = nil + local preamble = nil + if id then + local session = cache[id] + if session then + db = session.db + else + db = sqlite_open(filename) + preamble = f_preamble(filename,base,base) + if not db then + report("no session database specified") + else + cache[id] = { + name = filename, + db = db, + } + end + end + else + db = open_db(filename) + preamble = f_preamble(filename,base,base) + end + if not db then + report("no database opened") + else + local converter = specification.converter + local nofrows = 0 + local callback = nil + if preamble then + query = preamble .. query -- only needed in open + end + if converter then + local convert = converter.sqlite + callback = function(nofcolumns,values,fields) + nofrows = nofrows + 1 + result[nofrows] = convert(values) + end + else + local column = { } + callback = function(nofcolumns,values,fields) + for i=1,nofcolumns do + local field + if fields then + field = fields[i] + keys[i+1] = field + else + field = keys[i] + end + if field then + column[field] = values[i] + end + end + nofrows = nofrows + 1 + result[nofrows] = column + end + end + local okay = sqlite_execute(db,query,callback) + if not okay then + report("error: %s",sqlite_getmessage(db)) + -- elseif converter then + -- result = converter.sqlite(result) + end + end + if db and not id then + sqlite_close(db) + end + return result, keys + else + report("error: ","no library loaded") + end +end + +local wraptemplate = [[ +local converters = utilities.sql.converters +local deserialize = utilities.sql.deserialize + +local tostring = tostring +local tonumber = tonumber +local booleanstring = string.booleanstring + +%s + +return function(cells) + -- %s (not needed) + -- %s (not needed) + return { + %s + } +end +]] + +local celltemplate = "cells[%s]" + +methods.sqlite = { + execute = execute, + usesfiles = false, + wraptemplate = wraptemplate, + celltemplate = celltemplate, +} + +package.loaded["util-sql-imp-sqlite"] = methods.sqlite +package.loaded[libname] = methods.sqlite + +return methods.sqlite diff --git a/tex/context/base/mkiv/libs-imp-zint.lua b/tex/context/base/mkiv/libs-imp-zint.lua new file mode 100644 index 000000000..eef2cd605 --- /dev/null +++ b/tex/context/base/mkiv/libs-imp-zint.lua @@ -0,0 +1,148 @@ +if not modules then modules = { } end modules ['libs-imp-ghostscript'] = { + 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", +} + +local libname = "zint" +local libfile = "libzint" -- what on unix? +-- local libfile = "/usr/local/lib/libzint.so" + +local zintlib = resolvers.libraries.validoptional(libname) + +if not zintlib then return end + +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 zint = utilities.zint or { } +utilities.zint = zint + +local zintlib_execute = zintlib.execute + +local next, type, unpack = next, type, unpack +local lower, gsub = string.lower, string.gsub + +local mapping = { + ["code 11"] = 1, ["pharma one-track"] = 51, ["aztec code"] = 92, + ["standard 2of5"] = 2, ["pzn"] = 52, ["daft code"] = 93, + ["interleaved 2of5"] = 3, ["pharma two-track"] = 53, ["micro qr code"] = 97, + ["iata 2of5"] = 4, ["pdf417"] = 55, ["hibc code 128"] = 98, + ["data logic"] = 6, ["pdf417 trunc"] = 56, ["hibc code 39"] = 99, + ["industrial 2of5"] = 7, ["maxicode"] = 57, ["hibc data matrix"] = 102, + ["code 39"] = 8, ["qr code"] = 58, ["hibc qr code"] = 104, + ["extended code 39"] = 9, ["code 128-b"] = 60, ["hibc pdf417"] = 106, + ["ean"] = 13, ["ap standard customer"] = 63, ["hibc micropdf417"] = 108, + ["ean + check"] = 14, ["ap reply paid"] = 66, ["hibc codablock-f"] = 110, + ["gs1-128"] = 16, ["ap routing"] = 67, ["hibc aztec code"] = 112, + ["codabar"] = 18, ["ap redirection"] = 68, ["dotcode"] = 115, + ["code 128"] = 20, ["isbn"] = 69, ["han xin code"] = 116, + ["leitcode"] = 21, ["rm4scc"] = 70, ["rm mailmark"] = 121, + ["identcode"] = 22, ["data matrix"] = 71, ["aztec runes"] = 128, + ["code 16k"] = 23, ["ean-14"] = 72, ["code 32"] = 129, + ["code 49"] = 24, ["vin (north america)"] = 73, ["comp ean"] = 130, + ["code 93"] = 25, ["codablock-f"] = 74, ["comp gs1-128"] = 131, + ["flattermarken"] = 28, ["nve-18"] = 75, ["comp databar omni"] = 132, + ["gs1 databar omni"] = 29, ["japanese post"] = 76, ["comp databar ltd"] = 133, + ["gs1 databar ltd"] = 30, ["korea post"] = 77, ["comp databar expom"] = 134, + ["gs1 databar expom"] = 31, ["gs1 databar stack"] = 79, ["comp upc-a"] = 135, + ["telepen alpha"] = 32, ["gs1 databar stack omni"] = 80, ["comp upc-e"] = 136, + ["upc-a"] = 34, ["gs1 databar eso"] = 81, ["comp databar stack"] = 137, + ["upc-a + check"] = 35, ["planet"] = 82, ["comp databar stack omni"] = 138, + ["upc-e"] = 37, ["micropdf"] = 84, ["comp databar eso"] = 139, + ["upc-e + check"] = 38, ["usps onecode"] = 85, ["channel code"] = 140, + ["postnet"] = 40, ["uk plessey"] = 86, ["code one"] = 141, + ["msi plessey"] = 47, ["telepen numeric"] = 87, ["grid matrix"] = 142, + ["fim"] = 49, ["itf-14"] = 89, ["upnqr"] = 143, + ["logmars"] = 50, ["kix code"] = 90, ["rmqr"] = 145, +} + +table.setmetatableindex(mapping,function(t,k) + local s = gsub(lower(k),"[^a-z0-9]","") + local v = rawget(t,s) or false + t[k] = v + return v +end) + +local report = logs.reporter("zint") +local context = context +local shown = false + +----- f_rectangle = string.formatters["%sofill unitsquare xysized (%N,%N) shifted (%N,%N);"] + +function zint.execute(specification) + if okay() then + local code = specification.code + local text = specification.text + if code then + local id = mapping[code] + if id then + specification.code = id + local result = zintlib_execute(specification) + if result then + -- not that fast but if needed we can speed it up + context.startMPcode() + local rectangles = result.rectangles + local hexagons = result.hexagons + local circles = result.circles + local strings = result.strings + if rectangles then + local n = #rectangles + for i=1,n do + local r = rectangles[i] + context("%sofill unitsquare xysized (%N,%N) shifted (%N,%N);", + i == n and "d" or "n",r[3],r[4],r[1],r[2]) + -- rectangles[i] = f_rectangle(i == n and "d" or "n",r[3],r[4],r[1],r[2]) + end + -- context("% t",rectangles) + end + if hexagons then + local n = #hexagons + for i=1,#hexagons do + context("%sofill (%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--(%N,%N)--cycle;", + i == n and "d" or "n",unpack(hexagons[i])) + end + end + if circles then + local n = #circles + for i=1,#circles do + local c = circles[i] + context("%sofill unitcircle scaled %N shifted (%N,%N);", + i == n and "d" or "n",c[3],c[1],c[2]) + end + end + if strings then + -- We set the font at the encapsulating level. + for i=1,#strings do + local s = strings[i] + context('draw textext("%s") scaled (%N/10) shifted (%N,%N);', + s[4],s[3],s[1],s[2]) + end + end + context.stopMPcode() + end + else + report("unknown barcode alternative %a",code) + if not shown then + report("") + report("valid barcode alternatives:") + report("") + local list = table.sortedkeys(mapping) + for i=1,#list do + report(" %s", list[i]) + end + report("") + shown = true + end + end + end + end +end diff --git a/tex/context/base/mkiv/libs-imp-zint.mkxl b/tex/context/base/mkiv/libs-imp-zint.mkxl new file mode 100644 index 000000000..d7436a4a4 --- /dev/null +++ b/tex/context/base/mkiv/libs-imp-zint.mkxl @@ -0,0 +1,61 @@ +%D \module +%D [ file=m-zint, +%D version=2010.12.07, +%D title=\CONTEXT\ Extra Modules, +%D subtitle=Zint Barcode Generator, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Using \type {zint} seems to be the easiest way to generate +%D (PDF417) barcodes so therefore we now have this module. There +%D are proper (also windows) binaries at: +%D +%D \starttyping +%D http://www.zint.org.uk +%D \stoptyping +%D +%D There is a bit more code than needed as we want to be able to +%D feed names. + +\registerctxluafile{libs-imp-zint}{} + +\unprotect + +\definefont[usedzintfont][dejavusansmono at 10bp] + +\unexpanded\def\barcode[#1]% [alternative=,text=] + {\bgroup + \usedzintfont + \getdummyparameters + [\c!alternative=,\c!text=,#1]% + \scale + [#1]% + {\ctxlua{utilities.zint.execute{code="\dummyparameter\c!alternative",text=\!!bs\dummyparameter\c!text\!!es}}}% + \egroup} + +\protect + +\continueifinputfile{libs-imp-zint.mkxl} + +\starttext + +% \dorecurse{1000}{ + \startTEXpage + \barcode[alternative=PDF417,text={Hans Hagen}]% + \blank + \barcode[alternative=PDF417,text={Ton Otten}]% + \blank + \barcode[alternative=ISBN,text=9789490688011]% + \blank + \barcode[alternative=isbn,text=9789490688011,width=3cm]% + \stopTEXpage +% } + +\stoptext + + diff --git a/tex/context/base/mkiv/libs-ini.lua b/tex/context/base/mkiv/libs-ini.lua new file mode 100644 index 000000000..2422305f0 --- /dev/null +++ b/tex/context/base/mkiv/libs-ini.lua @@ -0,0 +1,179 @@ +if not modules then modules = { } end modules ['libs-ini'] = { + version = 1.001, + comment = "companion to luat-lib.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- This is a loader for optional libraries in luametatex with context lmtx. It's +-- kind of experimental. We also use a different locator than in mkiv because we +-- don't support loading lua libraries and swiglibs any more. Of course one can +-- try the regular lua loaders but we just assume that a user then knows what (s)he +-- is doing. + +local type, unpack = type, unpack + +-- here we implement the resolver + +local type = type + +local nameonly = file.nameonly +local joinfile = file.join +local addsuffix = file.addsuffix +local qualifiedpath = file.is_qualified_path + +local isfile = lfs.isfile + +local findfile = resolvers.findfile +local expandpaths = resolvers.expandedpathlistfromvariable + +local report = logs.reporter("resolvers","libraries") +local trace = false + +trackers.register("resolvers.lib", function(v) trace = v end) + +local function findlib(required) -- todo: cache + local suffix = os.libsuffix or "so" + if not qualifiedpath(required) then + local list = directives.value("system.librarynames" ) + local only = nameonly(required) + if type(list) == "table" then + list = list[only] + if type(list) ~= "table" then + list = { only } + end + else + list = { only } + end + if trace then + report("using lookup list for library %a: % | t",only,list) + end + for i=1,#list do + local name = list[i] + local found = findfile(name,"lib") + if not found then + found = findfile(addsuffix(name,suffix),"lib") + end + if found then + if trace then + report("library %a resolved via %a path to %a",name,"tds lib",found) + end + return found + end + end + if expandpaths then + local list = expandpaths("PATH") + local base = addsuffix(only,suffix) + for i=1,#list do + local full = joinfile(list[i],base) + local found = isfile(full) and full + if found then + if trace then + report("library %a resolved via %a path to %a",name,"system",found) + end + return found + end + end + end + elseif isfile(addsuffix(required,suffix)) then + if trace then + report("library with qualified name %a %sfound",required,"") + end + return required + else + if trace then + report("library with qualified name %a %sfound",required,"not ") + end + end + return false +end + +local foundlibraries = table.setmetatableindex(function(t,k) + local v = findlib(k) + t[k] = v + return v +end) + +function resolvers.findlib(required) + return foundlibraries[required] +end + +-- here we implement the loader + +local libraries = { } +resolvers.libraries = libraries + +local report = logs.reporter("optional") + +function libraries.validoptional(name) + local thelib = optional and optional[name] + if not thelib then + -- forget about it, no message here + elseif thelib.initialize then + return thelib + else + report("invalid optional library %a",libname) + end +end + +function libraries.optionalloaded(name,libnames) + local thelib = optional and optional[name] + if not thelib then + report("no optional %a library found",name) + else + local thelib_initialize = thelib.initialize + if not thelib_initialize then + report("invalid optional library %a",name) + else + if type(libnames) == "string" then + libnames = { libnames } + end + if type(libnames) == "table" then + for i=1,#libnames do + local libname = libnames[i] + local filename = foundlibraries[libname] + if filename then + libnames[i] = filename + else + report("unable to locate library %a",libname) + return + end + end + local initialized = thelib_initialize(unpack(libnames)) + if initialized then + report("using library '% + t'",libnames) + else + report("unable to initialize library '% + t'",libnames) + end + return initialized + end + end + end +end + +-- local patterns = { +-- "libs-imp-%s.mkxl", +-- "libs-imp-%s.mklx", +-- } +-- +-- local function action(name,foundname) +-- -- could be one command +-- context.startreadingfile() +-- context.input(foundname) +-- context.stopreadingfile() +-- end +-- +-- interfaces.implement { +-- name = "uselibrary", +-- arguments = "string" +-- actions = function(name) +-- resolvers.uselibrary { +-- category = "color definition", +-- name = name, +-- patterns = patterns, +-- action = action, +-- onlyonce = true, +-- } +-- end +-- } diff --git a/tex/context/base/mkiv/libs-ini.mkxl b/tex/context/base/mkiv/libs-ini.mkxl new file mode 100644 index 000000000..18163beed --- /dev/null +++ b/tex/context/base/mkiv/libs-ini.mkxl @@ -0,0 +1,31 @@ +%D \module +%D [ file=libs-ini, +%D version=2020.01.02, +%D title=\CONTEXT\ Lua Macros, +%D subtitle=Libraries, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\registerctxluafile{libs-ini}{} + +\registerctxluafile{libs-imp-curl}{} +\registerctxluafile{libs-imp-ghostscript}{} +\registerctxluafile{libs-imp-graphicsmagick}{} + +% These are loaded on demand: + +% \registerctxluafile{libs-imp-mysql}{} +% \registerctxluafile{libs-imp-sqlite}{} +% \registerctxluafile{libs-imp-postgress}{} + +\unprotect + +% \unexpanded\def\uselibrary[#1]% +% {\clf_uselibrary{#1}} + +\protect \endinput diff --git a/tex/context/base/mkiv/luat-cnf.lua b/tex/context/base/mkiv/luat-cnf.lua index ebda6e8cd..a39106744 100644 --- a/tex/context/base/mkiv/luat-cnf.lua +++ b/tex/context/base/mkiv/luat-cnf.lua @@ -157,7 +157,12 @@ function texconfig.init() local i = start local t = os.clock() while true do - local b = callbytecode(i) + -- local b = callbytecode(i) + local e, b = pcall(callbytecode,i) + if not e then + print("\nfatal error : unable to load bytecode, maybe wipe the cache first\n") + os.exit() + end if b then setbytecode(i,nil) ; i = i + 1 diff --git a/tex/context/base/mkiv/luat-lib.mkiv b/tex/context/base/mkiv/luat-lib.mkiv index 8c80072e5..c3bbd8e19 100644 --- a/tex/context/base/mkiv/luat-lib.mkiv +++ b/tex/context/base/mkiv/luat-lib.mkiv @@ -73,7 +73,9 @@ \registerctxluafile{data-use}{} \registerctxluafile{data-aux}{} -\registerctxluafile{util-lib}{} +\ifcase\contextlmtxmode + \registerctxluafile{util-lib}{} +\fi \registerctxluafile{luat-cbk}{} \registerctxluafile{luat-run}{} diff --git a/tex/context/base/mkiv/m-fonts-plugins.mkiv b/tex/context/base/mkiv/m-fonts-plugins.mkiv index 154e47804..255a2ac72 100644 --- a/tex/context/base/mkiv/m-fonts-plugins.mkiv +++ b/tex/context/base/mkiv/m-fonts-plugins.mkiv @@ -193,6 +193,7 @@ [mode=plug, features=harfbuzz, % method=binary, +% method=internal, script=arab,language=dflt, % ccmp=yes, % init=yes,medi=yes,fina=yes,isol=yes, diff --git a/tex/context/base/mkiv/m-zint.mkxl b/tex/context/base/mkiv/m-zint.mkxl new file mode 100644 index 000000000..7135126ba --- /dev/null +++ b/tex/context/base/mkiv/m-zint.mkxl @@ -0,0 +1,7 @@ +% this is a stub: + +% \uselibrary[zint] + +\input libs-imp-zint.mkxl + +\endinput diff --git a/tex/context/base/mkiv/pack-rul.mkiv b/tex/context/base/mkiv/pack-rul.mkiv index f44f547c0..8732c7e6b 100644 --- a/tex/context/base/mkiv/pack-rul.mkiv +++ b/tex/context/base/mkiv/pack-rul.mkiv @@ -468,40 +468,25 @@ {\def\pack_framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\executedefinedoverlay{##1}{#2}}}% \processcommalist[#1]\pack_framed_define_overlay_indeed} -% \unexpanded\def\executedefinedoverlay#1#2% we can share the definitions -% {\bgroup % redundant grouping -% \setbox\scratchbox\hbox\bgroup -% \ifzeropt\d_framed_target_dp -% \the\everyoverlay#2% saves wrapping (and lua call) -% \else -% \lower\d_framed_target_dp -% \hbox{\the\everyoverlay#2}% -% \fi -% \egroup -% \setlayoutcomponentattribute{\v!overlay:#1}% -% \setbox\scratchbox\hpack \layoutcomponentboxattribute -% {\kern -.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \d_overlay_width -% \raise-.5\dimexpr\ht\scratchbox-\d_framed_target_ht\relax % not \d_overlay_height ! -% \box\scratchbox}% -% \wd\scratchbox\d_framed_target_wd -% \ht\scratchbox\d_framed_target_ht -% \dp\scratchbox\d_framed_target_dp -% \box\scratchbox -% \egroup} - -% 20191231: moved from cont-exp: - \unexpanded\def\executedefinedoverlay#1#2% we can share the definitions {\bgroup % redundant grouping + \setbox\scratchbox\hbox\bgroup + \ifzeropt\d_framed_target_dp + \the\everyoverlay#2% saves wrapping (and lua call) + \else + \lower\d_framed_target_dp + \hbox{\the\everyoverlay#2}% + \fi + \egroup \setlayoutcomponentattribute{\v!overlay:#1}% - \setbox\scratchbox\hbox{\the\everyoverlay#2}% - \hpack to \d_framed_target_wd \layoutcomponentboxattribute - {\hskip-.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax - \box\scratchbox - \hss}% + \setbox\scratchbox\hpack \layoutcomponentboxattribute + {\kern -.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \d_overlay_width + \raise-.5\dimexpr\ht\scratchbox-\d_framed_target_ht\relax % not \d_overlay_height ! + \box\scratchbox}% \wd\scratchbox\d_framed_target_wd \ht\scratchbox\d_framed_target_ht \dp\scratchbox\d_framed_target_dp + \box\scratchbox \egroup} %D \macros diff --git a/tex/context/base/mkiv/pack-rul.mkxl b/tex/context/base/mkiv/pack-rul.mkxl index f0dc7de1b..8fd23fbb1 100644 --- a/tex/context/base/mkiv/pack-rul.mkxl +++ b/tex/context/base/mkiv/pack-rul.mkxl @@ -491,26 +491,13 @@ % \egroup} % 20191231: moved from cont-exp: -% -% % this is like the old: -% -% \unexpanded\def\executedefinedoverlay#1#2% we can share the definitions -% {\bgroup % redundant grouping -% \setlayoutcomponentattribute{\v!overlay:#1}% -% \setbox\scratchbox\hbox \layoutcomponentboxattribute{\the\everyoverlay#2}% -% \boxxoffset\scratchbox-.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \d_overlay_width -% % \boxyoffset\scratchbox-.5\dimexpr\ht\scratchbox-\d_framed_target_ht+\d_framed_target_dp\relax % not \d_overlay_height ! -% \wd\scratchbox\d_framed_target_wd -% \ht\scratchbox\d_framed_target_ht -% \dp\scratchbox\d_framed_target_dp -% \box\scratchbox -% \egroup} \unexpanded\def\executedefinedoverlay#1#2% we can share the definitions {\bgroup % redundant grouping \setlayoutcomponentattribute{\v!overlay:#1}% - \setbox\scratchbox\layoutcomponentboxattribute\hbox{\the\everyoverlay#2}% - \boxxoffset\scratchbox-.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax + \setbox\scratchbox\hbox \layoutcomponentboxattribute{\the\everyoverlay#2}% + \boxxoffset\scratchbox-.5\dimexpr\wd\scratchbox-\d_framed_target_wd\relax % was \d_overlay_width + \boxyoffset\scratchbox-.5\dimexpr\ht\scratchbox-\d_framed_target_ht+\d_framed_target_dp\relax % not \d_overlay_height ! \wd\scratchbox\d_framed_target_wd \ht\scratchbox\d_framed_target_ht \dp\scratchbox\d_framed_target_dp diff --git a/tex/context/base/mkiv/spac-hor.mkiv b/tex/context/base/mkiv/spac-hor.mkiv index 1a13b39af..0f65eea33 100644 --- a/tex/context/base/mkiv/spac-hor.mkiv +++ b/tex/context/base/mkiv/spac-hor.mkiv @@ -66,7 +66,9 @@ \ifzeropt\parindent\else \doifemptytoks\everypar\spac_indentation_set_everypar \fi - \ifconditional\c_spac_indentation_indent_first\else + \ifconditional\c_spac_indentation_indent_first + \spac_indentation_variant_yes % better than: \let\checkindentation\relax + \else \spac_indentation_variant_no \fi \spac_indentation_check_toggle} diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 5ec34ac15..9344f8692 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex a036e1f44..11bf6a7cd 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/type-ini.lua b/tex/context/base/mkiv/type-ini.lua index cd5b32d3e..798b9a894 100644 --- a/tex/context/base/mkiv/type-ini.lua +++ b/tex/context/base/mkiv/type-ini.lua @@ -81,7 +81,7 @@ local patterns = { -- elseif name_two == name then -- report("unknown library %a",name_one) -- else --- commands.uselibrary { +-- resolvers.uselibrary { -- name = name_two, -- patterns = patterns, -- action = action, diff --git a/tex/context/base/mkiv/util-lib.lua b/tex/context/base/mkiv/util-lib.lua index fb65a566e..a49507c60 100644 --- a/tex/context/base/mkiv/util-lib.lua +++ b/tex/context/base/mkiv/util-lib.lua @@ -120,7 +120,8 @@ local function locate(required,version,trace,report,action) -- initialize a few variables local required_name = required_base .. "." .. os.libsuffix local version = type(version) == "string" and version ~= "" and version or false - local engine = "luatex" -- environment.ownmain or false +-- local engine = "luatex" -- environment.ownmain or false + local engine = environment.ownmain or false -- if trace and not done then local list = expandpaths("lib") -- fresh, no reuse @@ -240,6 +241,8 @@ local function locate(required,version,trace,report,action) return library or nil end +resolvers.locatelib = locate -- for now + do local report_swiglib = logs.reporter("swiglib") @@ -458,3 +461,53 @@ ffilib("libmysql","5.6.14") -- Watch out, the last one is less explicit and lacks the swiglib prefix. ]]-- + +do + + local isfile = lfs.isfile + local report = logs.reporter("resolvers","lib") + local trace = false + + trackers.register("resolvers.lib", function(v) trace = v end) + + local function action(filename) + return isfile(filename) and filename or false + end + + function resolvers.findlib(required) -- todo: cache + local list = directives.value("system.librarynames" ) + local only = nameonly(required) + if type(list) == "table" then + list = list[only] + if type(list) == "table" then + if trace then + report("using lookup list for library %a: % | t",only,list) + end + else + list = { only } + end + else + list = { only } + end + for i=1,#list do + local name = list[i] + local found = locate(name,false,trace,report,action) + if found then + return found + end + end + local getpaths = resolvers.expandedpathlistfromvariable + if getpaths then + local list = getpaths("PATH") + local base = addsuffix(only,os.libsuffix) + for i=1,#list do + local full = joinfile(list[i],base) + local found = locate(full,false,trace,report,action) + if found then + return found + end + end + end + end + +end diff --git a/tex/context/base/mkiv/util-sql-imp-ffi.lua b/tex/context/base/mkiv/util-sql-imp-ffi.lua index 2b9f113af..f44069502 100644 --- a/tex/context/base/mkiv/util-sql-imp-ffi.lua +++ b/tex/context/base/mkiv/util-sql-imp-ffi.lua @@ -66,9 +66,6 @@ ffi.cdef [[ void *extension; } MYSQL_field; - void free(void*ptr); - void * malloc(size_t size); - MYSQL_instance * mysql_init ( MYSQL_instance *mysql ); diff --git a/tex/context/base/mkiv/util-sql-imp-sqlite.lua b/tex/context/base/mkiv/util-sql-imp-sqlite.lua index cf4a3a8b0..a88035f68 100644 --- a/tex/context/base/mkiv/util-sql-imp-sqlite.lua +++ b/tex/context/base/mkiv/util-sql-imp-sqlite.lua @@ -66,6 +66,7 @@ ffi.cdef [[ const char *sqlite3_errmsg ( sqlite3* ); + ]] local ffi_tostring = ffi.string diff --git a/tex/context/base/mkiv/util-sql.lua b/tex/context/base/mkiv/util-sql.lua index 2f8c862ad..61f1f19fa 100644 --- a/tex/context/base/mkiv/util-sql.lua +++ b/tex/context/base/mkiv/util-sql.lua @@ -109,16 +109,43 @@ local defaults = { __index = }, } -setmetatableindex(sql.methods,function(t,k) - if type(k) == "string" then - report_state("start loading method %a",k) - require("util-sql-imp-"..k) - report_state("loading method %a done",k) - return rawget(t,k) - else - report_state("invalid method %a",tostring(k)) - end -end) +if optional then + + local methods = { + ffi = "mysql", + library = "mysql", + swiglib = "mysql", + postgress = "postgress", + sqlite = "sqlite" + sqlite3 = "sqlite" + } + + setmetatableindex(sql.methods,function(t,k) + local m = methods[k + if m then + report_state("start loading method %a as %a",k,m) + require("libs-imp-" .. m) + report_state("loading method %a done",k) + return rawget(t,m) + else + report_state("invalid method %a",tostring(k)) + end + end) + +else + + setmetatableindex(sql.methods,function(t,k) + if type(k) == "string" then + report_state("start loading method %a",k) + require("util-sql-imp-" .. k) + report_state("loading method %a done",k) + return rawget(t,k) + else + report_state("invalid method %a",tostring(k)) + end + end) + +end -- converters diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 7690ea2ae..e8ccc0a93 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 7c07d9996..af101f6ed 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/context/modules/common/s-abbreviations-logos.tex b/tex/context/modules/common/s-abbreviations-logos.tex index 5dc37abcc..cafc296b5 100644 --- a/tex/context/modules/common/s-abbreviations-logos.tex +++ b/tex/context/modules/common/s-abbreviations-logos.tex @@ -73,6 +73,7 @@ \logo [CSV] {csv} \logo [CTAN] {ctan} \logo [CTXTOOLS] {ctxtools} +\logo [CURL] {Curl} \logo [CWEB] {cweb} \logo [DAC] {dac} \logo [DARWIN] {Darwin} @@ -132,6 +133,7 @@ \logo [GIF] {gif} \logo [GNU] {gnu} \logo [GNUPLOT] {gnuplot} +\logo [GRAPHICSMAGICK]{GraphicsMagick} \logo [GS] {Ghost\-Script} \logo [GUST] {Gust} \logo [GWTEX] {gw\TeXsuffix} @@ -152,6 +154,7 @@ \logo [JAVA] {Java} \logo [JAVASCRIPT] {Java\-Script} \logo [JBIG] {jbig} +\logo [JIT] {jit} \logo [JPEG] {jpeg} \logo [JPG] {jpg} \logo [JSON] {json} @@ -239,6 +242,7 @@ \logo [PLAIN] {Plain} \logo [PNG] {png} \logo [POSIX] {posix} +\logo [POSTGRESS] {Post\-gress} \logo [POSTSCRIPT] {Post\-Script} \logo [PPCHTEX] {\PPCHTeX} \logo [PRAGMA] {Pragma ADE} @@ -272,6 +276,7 @@ \logo [SWIG] {swig} \logo [SWIGLIB] {SwigLib} \logo [SYNCTEX] {Sync\TeX} +\logo [SQLITE] {SQLite} \logo [TABLE] {\TaBlE} \logo [TCPIP] {tcp/ip} \logo [TDS] {tds} % no sc te @@ -357,6 +362,7 @@ \logo [YandY] {y\&y} \logo [YOUTUBE] {YouTube} \logo [ZIP] {zip} +\logo [ZINT] {zint} \logo [KB] {KB} \logo [MB] {MB} diff --git a/tex/context/modules/mkiv/m-sql.mkiv b/tex/context/modules/mkiv/m-sql.mkiv index f1df2833a..ed9dae99a 100644 --- a/tex/context/modules/mkiv/m-sql.mkiv +++ b/tex/context/modules/mkiv/m-sql.mkiv @@ -16,6 +16,11 @@ \registerctxluafile{util-tpl}{} \registerctxluafile{util-sql}{} +\ifcase\contextlmtxmode\else + \registerctxluafile{libs-imp-mysql}{} + \registerctxluafile{libs-imp-sqlite}{} +\fi + \setupmodule \doifsomething {\currentmoduleparameter{method}}{ diff --git a/tex/context/modules/mkiv/s-inf-01.mkvi b/tex/context/modules/mkiv/s-inf-01.mkvi index 2fda9997a..67fc45d46 100644 --- a/tex/context/modules/mkiv/s-inf-01.mkvi +++ b/tex/context/modules/mkiv/s-inf-01.mkvi @@ -26,8 +26,13 @@ \startluacode local format, gsub, find, match = string.format, string.gsub, string.find, string.match + local setmetatableindex = table.setmetatableindex - local list, size, comp, used, nope = { }, { }, { }, { mkii = { }, mkiv = { }, mkvi = { } }, { 0, 0, 0, 0, 0 } + local list = { } + local size = { } + local comp = { } + local used = setmetatableindex("table") + local nope = setmetatableindex("number") local omit = { "char%-def%.lua", @@ -39,7 +44,7 @@ "colo%-pan.tex", ".*test.*" } local types = { - "tex", "mkii", "mkiv", "mkvi", "lua", -- "mpiv" + "tex", "mkii", "mkiv", "mkvi", "mkxl", "mklx", "lua", -- "mpiv" } local patterns = { "^([a-z][a-z][a-z][a-z])%-[a-z0-9%-]+%.[a-z]+", @@ -64,10 +69,16 @@ end end if okay then - local lm, sm, cm = list[category], size[category], comp[category] + local lm = list[category] + local sm = size[category] + local cm = comp[category] if not lm then - lm, sm, cm = { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } - list[category], size[category], comp[category] = lm, sm, cm + lm = setmetatableindex("number") + sm = setmetatableindex("number") + cm = setmetatableindex("number") + list[category] = lm + size[category] = sm + comp[category] = cm end lm[n] = lm[n] + 1 local done = true @@ -90,7 +101,7 @@ logs.report("error","unknown file %a",name) data = "" end - sm[n+5] = sm[n+5] + #data + sm[n+#types] = sm[n+#types] + #data if done then sm[n] = sm[n] + #data else @@ -121,7 +132,7 @@ end local max, what = 0, (what == "size" and size) or list for k, v in table.sortedpairs(what) do - for i=1,5 do if v[i] > max then max = v[i] end end + for i=1,7 do if v[i] > max then max = v[i] end end end return max, what, function(n) return (max == 0 and 0) or (n == 0 and 0) or n/max end end @@ -130,14 +141,15 @@ function document.context_state_1(what) local max, what, norm = prepare(what) - context.starttabulate { "|Tl|T|T|T|T|T|" } + context.starttabulate { "|Tl|T|T|T|T|T|T|T|" } context.NC() context(category) context.NC() for i=1,#types do local n, m = 0, 0 for k, v in next, list do - local nn, mm = what[k][i], what[k][i+5] + local nn = what[k][i] + local mm = what[k][i+#types] n = n + nn m = m + (mm or nn) end @@ -150,18 +162,14 @@ for k, v in table.sortedpairs(what) do local c = what == size and comp[k] or nope context.NC() - context("\\bf %s~%s~~%s~~%s", + context("\\bf %s~%s~~%s~~%s~~%s~~%s", (used.mkii[k] and "ii") or "~~", (used.mkiv[k] and "iv") or "~~", (used.mkvi[k] and "vi") or "~~", + (used.mkiv[k] and "xl") or "~~", + (used.mkvi[k] and "lx") or "~~", k ) - -- context("%s\\enspace %s\\quad %s\\quad %s", - -- (used.mkii[k] and "ii") or "\\quad", - -- (used.mkiv[k] and "iv") or "\\quad", - -- (used.mkvi[k] and "vi") or "\\quad", - -- k - -- ) context.NC() for i=1,#types do context.Bar(types[i],v[i],c[i],f_norm(norm(v[i]))) @@ -190,19 +198,21 @@ \definecolor[bar:mkii][middleblue] \definecolor[bar:mkiv][middlered] \definecolor[bar:mkvi][middleyellow] +\definecolor[bar:mkxl][middlemagenta] +\definecolor[bar:mklx][middlecyan] \definecolor[bar:lua] [middlegray] \newcount\UpCounter \starttexdefinition Top #what#fraction#total#bigones - \hbox to 5em{\hss#total}% + \hbox to 7em{\hss#total}% \enspace \hbox {{\bf#what}\ifnum#total=#bigones\else~#bigones\rlap{~+}\fi\hss}% \stoptexdefinition \starttexdefinition Bar #color#size#nobigones#fraction \ifcase#size\else - \hbox to 5em{\hss\ifcase#nobigones\else\llap{-~}\fi#size}% + \hbox to 7em{\hss\ifcase#nobigones\else\llap{-~}\fi#size}% \enspace \blackrule[color=bar:#color,width=#fraction\dimexpr 20em\relax,height=.8\strutht]% \fi @@ -214,7 +224,7 @@ \stoptexdefinition \starttexdefinition StopUp - \par\nointerlineskip\blackrule[height=1pt,width=5em,depth=0pt,color=darkgray] + \par\nointerlineskip\blackrule[height=1pt,width=7em,depth=0pt,color=darkgray] \par\tttf\strut\UpName\par \egroup \ifnum\UpCounter=17 @@ -259,9 +269,9 @@ {The size of (core) files used in ConTeXt (- : large data files excluded; + : large data files included; comment and spaces removed)} {1}{size} \Show - {The relative number of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).} + {The relative number of files used in ConTeXt (tex, mkii, mkiv, mkvi, mkxl, mklx, lua).} {2}{number} \Show - {The relative size of files used in ConTeXt (tex, mkii, mkiv, mkvi, lua).} + {The relative size of files used in ConTeXt (tex, mkii, mkiv, mkvi, mkxl, mklx, lua).} {2}{size} \stoptext diff --git a/tex/context/modules/mkiv/s-inf-03.mkiv b/tex/context/modules/mkiv/s-inf-03.mkiv index d2acb7341..8bd7b3699 100644 --- a/tex/context/modules/mkiv/s-inf-03.mkiv +++ b/tex/context/modules/mkiv/s-inf-03.mkiv @@ -58,11 +58,18 @@ \quad\pagenumber\quad \rlap{\goto{\hbox to 5cm{next\hss}}[nextpage]}] +\ifcase\contextlmtxmode + \setupinteraction + [title={ConTeXt MkIV}] +\else + \setupinteraction + [title={ConTeXt LMTX}] +\fi + \setupinteraction [state=start, style=, color=, - title={ConTeXt MkIV}, subtitle={Lua modules and functions}, author={Hans Hagen - automatically generated}, contrastcolor=] @@ -128,7 +135,7 @@ end \stopnarrower \vfill \vfill - \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\ttbf\white\ConTeXt\ MkIV} + \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\ttbf\white\ConTeXt\ \ifcase\contextlmtxmode MkIV\else LMTX\fi} \par % \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\white \strut Lua infrastructure \emdash\ \currentdate} \vfill diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 3cddb3944..0884d743b 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 : 12/31/19 11:28:43 +-- merge date : 01/09/20 11:17:13 do -- begin closure to overcome local limits and interference |