diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-06-25 15:40:51 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-06-25 15:40:51 +0200 |
commit | b2a2304cbb0c65040d7b118ac9b857d304e333e6 (patch) | |
tree | ed5212e37a91ec78c12d9f72ca1186a59c139b40 /tex/context/base/mkiv/lxml-tab.lua | |
parent | b2276ae7a04a9f9c35403e508670049d8c3e4b3e (diff) | |
download | context-b2a2304cbb0c65040d7b118ac9b857d304e333e6.tar.gz |
2016-06-25 14:42:00
Diffstat (limited to 'tex/context/base/mkiv/lxml-tab.lua')
-rw-r--r-- | tex/context/base/mkiv/lxml-tab.lua | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/tex/context/base/mkiv/lxml-tab.lua b/tex/context/base/mkiv/lxml-tab.lua index 3c386b7a3..209dec7f9 100644 --- a/tex/context/base/mkiv/lxml-tab.lua +++ b/tex/context/base/mkiv/lxml-tab.lua @@ -1243,17 +1243,15 @@ generic table copier. Since we know what we're dealing with we can speed up things a bit. The second argument is not to be used!</p> --ldx]]-- --- local function copy(old,tables) +-- local function copy(old) -- if old then --- if not tables then --- tables = { } --- end -- local new = { } --- if not tables[old] then --- tables[old] = new --- end -- for k,v in next, old do --- new[k] = (type(v) == "table" and (tables[v] or copy(v, tables))) or v +-- if type(v) == "table" then +-- new[k] = table.copy(v) +-- else +-- new[k] = v +-- end -- end -- local mt = getmetatable(old) -- if mt then @@ -1264,15 +1262,27 @@ can speed up things a bit. The second argument is not to be used!</p> -- return { } -- end -- end +-- +-- We need to prevent __p__ recursio, so: -local function copy(old) +local function copy(old,p) if old then local new = { } - for k,v in next, old do - if type(v) == "table" then - new[k] = table.copy(v) - else + for k, v in next, old do + local t = type(v) == "table" + if k == "at" then + local t = { } + for k, v in next, v do + t[k] = v + end + new[k] = t + elseif k == "dt" then + v.__p__ = nil + v = copy(v,new) new[k] = v + v.__p__ = p + else + new[k] = v -- so we also share entities, etc in root end end local mt = getmetatable(old) |