From 865b5da32dfab508db87744c7542a59c192dd459 Mon Sep 17 00:00:00 2001 From: Marius Date: Tue, 19 Apr 2011 17:40:15 +0300 Subject: beta 2011.04.19 16:38 --- scripts/context/lua/mtxrun.lua | 33 +++++++++++++++++++++++++++++---- scripts/context/stubs/mswin/mtxrun.lua | 33 +++++++++++++++++++++++++++++---- scripts/context/stubs/unix/mtxrun | 33 +++++++++++++++++++++++++++++---- 3 files changed, 87 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 9ce73a168..72f105d07 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -1304,9 +1304,11 @@ 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. - local dummy = root._w_h_a_t_e_v_e_r_ - root._w_h_a_t_e_v_e_r_ = nil + -- using a metatable. (maybe explicitly test for metatable) + if getmetatable(root) then -- todo: make this an option, maybe even per subtable + local dummy = root._w_h_a_t_e_v_e_r_ + root._w_h_a_t_e_v_e_r_ = nil + end -- Let's forget about empty tables. if next(root) then do_serialize(root,name,"",0) @@ -9285,6 +9287,8 @@ if not modules then modules = { } end modules ['lxml-xml'] = { license = "see context related readme files" } +local concat = string.concat + local xml = xml local finalizers = xml.finalizers.xml @@ -9399,7 +9403,7 @@ local function texts(collected) if collected then local t, n = { }, 0 for c=1,#collected do - local e = collection[c] + local e = collected[c] if e and e.dt then n = n + 1 t[n] = e.dt @@ -9577,6 +9581,27 @@ end xml.table = totable finalizers.table = totable +local function textonly(e,t) + if e then + local edt = e.dt + if edt then + for i=1,#edt do + local e = edt[i] + if type(e) == "table" then + textonly(e,t) + else + t[#t+1] = e + end + end + end + end + return t +end + +function xml.textonly(e) -- no pattern + return concat(textonly(e,{})) +end + end -- of closure diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 9ce73a168..72f105d07 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -1304,9 +1304,11 @@ 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. - local dummy = root._w_h_a_t_e_v_e_r_ - root._w_h_a_t_e_v_e_r_ = nil + -- using a metatable. (maybe explicitly test for metatable) + if getmetatable(root) then -- todo: make this an option, maybe even per subtable + local dummy = root._w_h_a_t_e_v_e_r_ + root._w_h_a_t_e_v_e_r_ = nil + end -- Let's forget about empty tables. if next(root) then do_serialize(root,name,"",0) @@ -9285,6 +9287,8 @@ if not modules then modules = { } end modules ['lxml-xml'] = { license = "see context related readme files" } +local concat = string.concat + local xml = xml local finalizers = xml.finalizers.xml @@ -9399,7 +9403,7 @@ local function texts(collected) if collected then local t, n = { }, 0 for c=1,#collected do - local e = collection[c] + local e = collected[c] if e and e.dt then n = n + 1 t[n] = e.dt @@ -9577,6 +9581,27 @@ end xml.table = totable finalizers.table = totable +local function textonly(e,t) + if e then + local edt = e.dt + if edt then + for i=1,#edt do + local e = edt[i] + if type(e) == "table" then + textonly(e,t) + else + t[#t+1] = e + end + end + end + end + return t +end + +function xml.textonly(e) -- no pattern + return concat(textonly(e,{})) +end + end -- of closure diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 9ce73a168..72f105d07 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -1304,9 +1304,11 @@ 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. - local dummy = root._w_h_a_t_e_v_e_r_ - root._w_h_a_t_e_v_e_r_ = nil + -- using a metatable. (maybe explicitly test for metatable) + if getmetatable(root) then -- todo: make this an option, maybe even per subtable + local dummy = root._w_h_a_t_e_v_e_r_ + root._w_h_a_t_e_v_e_r_ = nil + end -- Let's forget about empty tables. if next(root) then do_serialize(root,name,"",0) @@ -9285,6 +9287,8 @@ if not modules then modules = { } end modules ['lxml-xml'] = { license = "see context related readme files" } +local concat = string.concat + local xml = xml local finalizers = xml.finalizers.xml @@ -9399,7 +9403,7 @@ local function texts(collected) if collected then local t, n = { }, 0 for c=1,#collected do - local e = collection[c] + local e = collected[c] if e and e.dt then n = n + 1 t[n] = e.dt @@ -9577,6 +9581,27 @@ end xml.table = totable finalizers.table = totable +local function textonly(e,t) + if e then + local edt = e.dt + if edt then + for i=1,#edt do + local e = edt[i] + if type(e) == "table" then + textonly(e,t) + else + t[#t+1] = e + end + end + end + end + return t +end + +function xml.textonly(e) -- no pattern + return concat(textonly(e,{})) +end + end -- of closure -- cgit v1.2.3