summaryrefslogtreecommitdiff
path: root/src/fontloader/misc/fontloader-l-table.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-08-29 08:24:21 +0200
committerGitHub <noreply@github.com>2016-08-29 08:24:21 +0200
commit692704c12ac6f952080aad16df123400a0c82c0e (patch)
tree96fe4de504dcc6f2472adab2abf8a259aa844b4b /src/fontloader/misc/fontloader-l-table.lua
parenta25067d7f3095cc3a3a28994e48ba1e02bdd3045 (diff)
parent50476780411fb84f1f4d0dcb7cd865c1eba4141b (diff)
downloadluaotfload-692704c12ac6f952080aad16df123400a0c82c0e.tar.gz
Merge pull request #378 from phi-gamma/master
[fontloader] sync with Context as of 2016-08-29
Diffstat (limited to 'src/fontloader/misc/fontloader-l-table.lua')
-rw-r--r--src/fontloader/misc/fontloader-l-table.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/fontloader/misc/fontloader-l-table.lua b/src/fontloader/misc/fontloader-l-table.lua
index d1e0592..498f518 100644
--- a/src/fontloader/misc/fontloader-l-table.lua
+++ b/src/fontloader/misc/fontloader-l-table.lua
@@ -478,7 +478,7 @@ function table.fromhash(t)
return hsh
end
-local noquotes, hexify, handle, compact, inline, functions
+local noquotes, hexify, handle, compact, inline, functions, metacheck
local reserved = table.tohash { -- intercept a language inconvenience: no reserved words as key
'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'if',
@@ -608,7 +608,8 @@ local function do_serialize(root,name,depth,level,indexed)
if compact then
last = #root
for k=1,last do
- if root[k] == nil then
+ -- if root[k] == nil then
+ if rawget(root,k) == nil then
last = k - 1
break
end
@@ -817,6 +818,7 @@ local function serialize(_handle,root,name,specification) -- handle wins
functions = specification.functions
compact = specification.compact
inline = specification.inline and compact
+ metacheck = specification.metacheck
if functions == nil then
functions = true
end
@@ -826,6 +828,9 @@ local function serialize(_handle,root,name,specification) -- handle wins
if inline == nil then
inline = compact
end
+ if metacheck == nil then
+ metacheck = true
+ end
else
noquotes = false
hexify = false
@@ -833,6 +838,7 @@ local function serialize(_handle,root,name,specification) -- handle wins
compact = true
inline = true
functions = true
+ metacheck = true
end
if tname == "string" then
if name == "return" then
@@ -857,8 +863,9 @@ local function serialize(_handle,root,name,specification) -- handle wins
end
if root then
-- The dummy access will initialize a table that has a delayed initialization
- -- using a metatable. (maybe explicitly test for metatable)
- if getmetatable(root) then -- todo: make this an option, maybe even per subtable
+ -- using a metatable. (maybe explicitly test for metatable). This can crash on
+ -- metatables that check the index against a number.
+ if metacheck and getmetatable(root) then
local dummy = root._w_h_a_t_e_v_e_r_
root._w_h_a_t_e_v_e_r_ = nil
end