summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/util-pck.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2020-02-16 10:59:14 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2020-02-16 10:59:14 +0100
commit8e11d447440b44990432ac838953a8cde4ef914f (patch)
treef30b2ff2d8a10f1aff50e1522d968618a97f067c /tex/context/base/mkiv/util-pck.lua
parent43fc66771a0c9d27cc0b7fe7a69392ea313bd0ca (diff)
downloadcontext-8e11d447440b44990432ac838953a8cde4ef914f.tar.gz
2020-02-11 16:39:00
Diffstat (limited to 'tex/context/base/mkiv/util-pck.lua')
-rw-r--r--tex/context/base/mkiv/util-pck.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/tex/context/base/mkiv/util-pck.lua b/tex/context/base/mkiv/util-pck.lua
index b90853fb6..6af53f9eb 100644
--- a/tex/context/base/mkiv/util-pck.lua
+++ b/tex/context/base/mkiv/util-pck.lua
@@ -10,6 +10,7 @@ if not modules then modules = { } end modules ['util-pck'] = {
local next, tostring, type = next, tostring, type
local sort, concat = table.sort, table.concat
+local format = string.format
local sortedhashkeys, sortedkeys, tohash = table.sortedhashkeys, table.sortedkeys, table.tohash
utilities = utilities or { }
@@ -17,14 +18,17 @@ utilities.packers = utilities.packers or { }
local packers = utilities.packers
packers.version = 1.01
+local fmt_kv = JITSUPPORTED and "%s=%s" or "%s=%q"
+local fmt_kt = JITSUPPORTED and "%s={%s}" or "%s={%q}"
+
local function hashed(t)
local s, ns = { }, 0
for k, v in next, t do
ns = ns + 1
if type(v) == "table" then
- s[ns] = k .. "={" .. hashed(v) .. "}"
+ s[ns] = format(fmt_kt,k,hashed(v))
else
- s[ns] = k .. "=" .. tostring(v)
+ s[ns] = format(fmt_kv,k,v)
end
end
sort(s)
@@ -35,7 +39,7 @@ local function simplehashed(t)
local s, ns = { }, 0
for k, v in next, t do
ns = ns + 1
- s[ns] = k .. "=" .. v
+ s[ns] = format(fmt_kv,k,v)
end
sort(s)
return concat(s,",")