summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2011-04-19 16:38:00 +0200
committerHans Hagen <pragma@wxs.nl>2011-04-19 16:38:00 +0200
commit690c595285ba89968a8af887cf2a074ebc943402 (patch)
treeb9d823867647ca9fc8303bb7e940c78c6ceb39c9 /scripts
parent6383acb525bc719bf958b490b97e87a8fccac44c (diff)
downloadcontext-690c595285ba89968a8af887cf2a074ebc943402.tar.gz
beta 2011.04.19 16:38
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtxrun.lua33
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua33
-rwxr-xr-xscripts/context/stubs/unix/mtxrun33
3 files changed, 87 insertions, 12 deletions
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 100755
--- 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