summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/context/lua/mtxrun.lua53
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua53
-rw-r--r--scripts/context/stubs/unix/mtxrun53
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/data-tmp.lua6
-rw-r--r--tex/context/base/l-table.lua48
-rw-r--r--tex/context/base/lxml-lpt.lua5
-rw-r--r--tex/context/base/status-files.pdfbin23588 -> 23581 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin154910 -> 154910 bytes
-rw-r--r--tex/generic/context/luatex-basics-gen.lua2
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua52
14 files changed, 121 insertions, 159 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index e0fc8d823..9ee6ed0e4 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -1253,18 +1253,16 @@ end
-- replacing handle by a direct t[#t+1] = ... (plus test) is not much
-- faster (0.03 on 1.00 for zapfino.tma)
-local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might drop the _'s some day.
+local function serialize(_handle,root,name,specification) -- handle wins
local tname = type(name)
- if tname == "table" then
- noquotes = name.noquotes
- hexify = name.hexify
- handle = name.handle or print
- reduce = name.reduce or false
- functions = name.functions
- compact = name.compact
- inline = name.inline and compact
- name = name.name
- tname = type(name)
+ if type(specification) == "table" then
+ noquotes = specification.noquotes
+ hexify = specification.hexify
+ handle = _handle or specification.handle or print
+ reduce = specification.reduce or false
+ functions = specification.functions
+ compact = specification.compact
+ inline = specification.inline and compact
if functions == nil then
functions = true
end
@@ -1275,10 +1273,10 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might
inline = compact
end
else
- noquotes = _noquotes
- hexify = _hexify
+ noquotes = false
+ hexify = false
handle = _handle or print
- reduce = _reduce or false
+ reduce = false
compact = true
inline = true
functions = true
@@ -1318,19 +1316,17 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might
end
-function table.serialize(root,name,reduce,noquotes,hexify) -- can be faster if flush == false and t as argument
+function table.serialize(root,name,specification)
local t, n = { }, 0
local function flush(s)
n = n + 1
t[n] = s
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
return concat(t,"\n")
end
-function table.tohandle(handle,root,name,reduce,noquotes,hexify)
- serialize(root,name,handle,reduce,noquotes,hexify)
-end
+table.tohandle = serialize
-- sometimes tables are real use (zapfino extra pro is some 85M) in which
-- case a stepwise serialization is nice; actually, we could consider:
@@ -1343,7 +1339,7 @@ end
local maxtab = 2*1024
-function table.tofile(filename,root,name,reduce,noquotes,hexify)
+function table.tofile(filename,root,name,specification)
local f = io.open(filename,'w')
if f then
if maxtab > 1 then
@@ -1356,13 +1352,13 @@ function table.tofile(filename,root,name,reduce,noquotes,hexify)
t, n = { }, 0 -- we could recycle t if needed
end
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
f:write(concat(t,"\n"),"\n")
else
local function flush(s)
f:write(s,"\n")
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
end
f:close()
io.flush()
@@ -1428,8 +1424,6 @@ function table.unnest(t) -- bad name
return unnest(t)
end
-
-
local function are_equal(a,b,n,m) -- indexed
if a and b and #a == #b then
n = n or 1
@@ -8156,13 +8150,14 @@ xml.nodesettostring = nodesettostring
local lpath -- we have a harmless kind of circular reference
-local lshowoptions = { name = false, functions = false }
+local lshowoptions = { functions = false }
local function lshow(parsed)
if type(parsed) == "string" then
parsed = lpath(parsed)
end
- report_lpath("%s://%s => %s",parsed.protocol or xml.defaultprotocol,parsed.pattern,table.serialize(parsed,lshowoptions))
+ report_lpath("%s://%s => %s",parsed.protocol or xml.defaultprotocol,parsed.pattern,
+ table.serialize(parsed,false,lshowoptions))
end
xml.lshow = lshow
@@ -10729,7 +10724,7 @@ function caches.is_writable(filepath,filename)
return file.is_writable(tmaname)
end
-local saveoptions = { name = "return", reduce = true }
+local saveoptions = { reduce = true }
function caches.savedata(filepath,filename,data,raw)
local tmaname, tmcname = caches.setluanames(filepath,filename)
@@ -10739,9 +10734,9 @@ function caches.savedata(filepath,filename,data,raw)
end
data.cache_uuid = os.uuid()
if caches.direct then
- file.savedata(tmaname,table.serialize(data,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- table.tofile(tmaname,data,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index e0fc8d823..9ee6ed0e4 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -1253,18 +1253,16 @@ end
-- replacing handle by a direct t[#t+1] = ... (plus test) is not much
-- faster (0.03 on 1.00 for zapfino.tma)
-local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might drop the _'s some day.
+local function serialize(_handle,root,name,specification) -- handle wins
local tname = type(name)
- if tname == "table" then
- noquotes = name.noquotes
- hexify = name.hexify
- handle = name.handle or print
- reduce = name.reduce or false
- functions = name.functions
- compact = name.compact
- inline = name.inline and compact
- name = name.name
- tname = type(name)
+ if type(specification) == "table" then
+ noquotes = specification.noquotes
+ hexify = specification.hexify
+ handle = _handle or specification.handle or print
+ reduce = specification.reduce or false
+ functions = specification.functions
+ compact = specification.compact
+ inline = specification.inline and compact
if functions == nil then
functions = true
end
@@ -1275,10 +1273,10 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might
inline = compact
end
else
- noquotes = _noquotes
- hexify = _hexify
+ noquotes = false
+ hexify = false
handle = _handle or print
- reduce = _reduce or false
+ reduce = false
compact = true
inline = true
functions = true
@@ -1318,19 +1316,17 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might
end
-function table.serialize(root,name,reduce,noquotes,hexify) -- can be faster if flush == false and t as argument
+function table.serialize(root,name,specification)
local t, n = { }, 0
local function flush(s)
n = n + 1
t[n] = s
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
return concat(t,"\n")
end
-function table.tohandle(handle,root,name,reduce,noquotes,hexify)
- serialize(root,name,handle,reduce,noquotes,hexify)
-end
+table.tohandle = serialize
-- sometimes tables are real use (zapfino extra pro is some 85M) in which
-- case a stepwise serialization is nice; actually, we could consider:
@@ -1343,7 +1339,7 @@ end
local maxtab = 2*1024
-function table.tofile(filename,root,name,reduce,noquotes,hexify)
+function table.tofile(filename,root,name,specification)
local f = io.open(filename,'w')
if f then
if maxtab > 1 then
@@ -1356,13 +1352,13 @@ function table.tofile(filename,root,name,reduce,noquotes,hexify)
t, n = { }, 0 -- we could recycle t if needed
end
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
f:write(concat(t,"\n"),"\n")
else
local function flush(s)
f:write(s,"\n")
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
end
f:close()
io.flush()
@@ -1428,8 +1424,6 @@ function table.unnest(t) -- bad name
return unnest(t)
end
-
-
local function are_equal(a,b,n,m) -- indexed
if a and b and #a == #b then
n = n or 1
@@ -8156,13 +8150,14 @@ xml.nodesettostring = nodesettostring
local lpath -- we have a harmless kind of circular reference
-local lshowoptions = { name = false, functions = false }
+local lshowoptions = { functions = false }
local function lshow(parsed)
if type(parsed) == "string" then
parsed = lpath(parsed)
end
- report_lpath("%s://%s => %s",parsed.protocol or xml.defaultprotocol,parsed.pattern,table.serialize(parsed,lshowoptions))
+ report_lpath("%s://%s => %s",parsed.protocol or xml.defaultprotocol,parsed.pattern,
+ table.serialize(parsed,false,lshowoptions))
end
xml.lshow = lshow
@@ -10729,7 +10724,7 @@ function caches.is_writable(filepath,filename)
return file.is_writable(tmaname)
end
-local saveoptions = { name = "return", reduce = true }
+local saveoptions = { reduce = true }
function caches.savedata(filepath,filename,data,raw)
local tmaname, tmcname = caches.setluanames(filepath,filename)
@@ -10739,9 +10734,9 @@ function caches.savedata(filepath,filename,data,raw)
end
data.cache_uuid = os.uuid()
if caches.direct then
- file.savedata(tmaname,table.serialize(data,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- table.tofile(tmaname,data,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index e0fc8d823..9ee6ed0e4 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -1253,18 +1253,16 @@ end
-- replacing handle by a direct t[#t+1] = ... (plus test) is not much
-- faster (0.03 on 1.00 for zapfino.tma)
-local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might drop the _'s some day.
+local function serialize(_handle,root,name,specification) -- handle wins
local tname = type(name)
- if tname == "table" then
- noquotes = name.noquotes
- hexify = name.hexify
- handle = name.handle or print
- reduce = name.reduce or false
- functions = name.functions
- compact = name.compact
- inline = name.inline and compact
- name = name.name
- tname = type(name)
+ if type(specification) == "table" then
+ noquotes = specification.noquotes
+ hexify = specification.hexify
+ handle = _handle or specification.handle or print
+ reduce = specification.reduce or false
+ functions = specification.functions
+ compact = specification.compact
+ inline = specification.inline and compact
if functions == nil then
functions = true
end
@@ -1275,10 +1273,10 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might
inline = compact
end
else
- noquotes = _noquotes
- hexify = _hexify
+ noquotes = false
+ hexify = false
handle = _handle or print
- reduce = _reduce or false
+ reduce = false
compact = true
inline = true
functions = true
@@ -1318,19 +1316,17 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might
end
-function table.serialize(root,name,reduce,noquotes,hexify) -- can be faster if flush == false and t as argument
+function table.serialize(root,name,specification)
local t, n = { }, 0
local function flush(s)
n = n + 1
t[n] = s
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
return concat(t,"\n")
end
-function table.tohandle(handle,root,name,reduce,noquotes,hexify)
- serialize(root,name,handle,reduce,noquotes,hexify)
-end
+table.tohandle = serialize
-- sometimes tables are real use (zapfino extra pro is some 85M) in which
-- case a stepwise serialization is nice; actually, we could consider:
@@ -1343,7 +1339,7 @@ end
local maxtab = 2*1024
-function table.tofile(filename,root,name,reduce,noquotes,hexify)
+function table.tofile(filename,root,name,specification)
local f = io.open(filename,'w')
if f then
if maxtab > 1 then
@@ -1356,13 +1352,13 @@ function table.tofile(filename,root,name,reduce,noquotes,hexify)
t, n = { }, 0 -- we could recycle t if needed
end
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
f:write(concat(t,"\n"),"\n")
else
local function flush(s)
f:write(s,"\n")
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
end
f:close()
io.flush()
@@ -1428,8 +1424,6 @@ function table.unnest(t) -- bad name
return unnest(t)
end
-
-
local function are_equal(a,b,n,m) -- indexed
if a and b and #a == #b then
n = n or 1
@@ -8156,13 +8150,14 @@ xml.nodesettostring = nodesettostring
local lpath -- we have a harmless kind of circular reference
-local lshowoptions = { name = false, functions = false }
+local lshowoptions = { functions = false }
local function lshow(parsed)
if type(parsed) == "string" then
parsed = lpath(parsed)
end
- report_lpath("%s://%s => %s",parsed.protocol or xml.defaultprotocol,parsed.pattern,table.serialize(parsed,lshowoptions))
+ report_lpath("%s://%s => %s",parsed.protocol or xml.defaultprotocol,parsed.pattern,
+ table.serialize(parsed,false,lshowoptions))
end
xml.lshow = lshow
@@ -10729,7 +10724,7 @@ function caches.is_writable(filepath,filename)
return file.is_writable(tmaname)
end
-local saveoptions = { name = "return", reduce = true }
+local saveoptions = { reduce = true }
function caches.savedata(filepath,filename,data,raw)
local tmaname, tmcname = caches.setluanames(filepath,filename)
@@ -10739,9 +10734,9 @@ function caches.savedata(filepath,filename,data,raw)
end
data.cache_uuid = os.uuid()
if caches.direct then
- file.savedata(tmaname,table.serialize(data,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- table.tofile(tmaname,data,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 6d4d27f53..7c6708b07 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.04.11 16:45}
+\newcontextversion{2011.04.11 18:55}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index cbf10277a..952be95dc 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.04.11 16:45}
+\newcontextversion{2011.04.11 18:55}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 3223fea70..78ab41d79 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.04.11 16:45}
+\edef\contextversion{2011.04.11 18:55}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 64e2b5e28..4028bc61b 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.04.11 16:45}
+\edef\contextversion{2011.04.11 18:55}
%D For those who want to use this:
diff --git a/tex/context/base/data-tmp.lua b/tex/context/base/data-tmp.lua
index 10cbe4486..55986d727 100644
--- a/tex/context/base/data-tmp.lua
+++ b/tex/context/base/data-tmp.lua
@@ -290,7 +290,7 @@ function caches.is_writable(filepath,filename)
return file.is_writable(tmaname)
end
-local saveoptions = { name = "return", reduce = true }
+local saveoptions = { reduce = true }
function caches.savedata(filepath,filename,data,raw)
local tmaname, tmcname = caches.setluanames(filepath,filename)
@@ -300,9 +300,9 @@ function caches.savedata(filepath,filename,data,raw)
end
data.cache_uuid = os.uuid()
if caches.direct then
- file.savedata(tmaname,table.serialize(data,saveoptions))
+ file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
- table.tofile(tmaname,data,saveoptions)
+ table.tofile(tmaname,data,true,saveoptions)
end
utilities.lua.compile(tmaname,tmcname)
end
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua
index 9de3c5502..b1a5cc4cc 100644
--- a/tex/context/base/l-table.lua
+++ b/tex/context/base/l-table.lua
@@ -591,18 +591,16 @@ end
-- replacing handle by a direct t[#t+1] = ... (plus test) is not much
-- faster (0.03 on 1.00 for zapfino.tma)
-local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might drop the _'s some day.
+local function serialize(_handle,root,name,specification) -- handle wins
local tname = type(name)
- if tname == "table" then
- noquotes = name.noquotes
- hexify = name.hexify
- handle = name.handle or print
- reduce = name.reduce or false
- functions = name.functions
- compact = name.compact
- inline = name.inline and compact
- name = name.name
- tname = type(name)
+ if type(specification) == "table" then
+ noquotes = specification.noquotes
+ hexify = specification.hexify
+ handle = _handle or specification.handle or print
+ reduce = specification.reduce or false
+ functions = specification.functions
+ compact = specification.compact
+ inline = specification.inline and compact
if functions == nil then
functions = true
end
@@ -613,10 +611,10 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might
inline = compact
end
else
- noquotes = _noquotes
- hexify = _hexify
+ noquotes = false
+ hexify = false
handle = _handle or print
- reduce = _reduce or false
+ reduce = false
compact = true
inline = true
functions = true
@@ -664,19 +662,17 @@ end
--~ 'return' : return { }
--~ number : [number] = { }
-function table.serialize(root,name,reduce,noquotes,hexify) -- can be faster if flush == false and t as argument
+function table.serialize(root,name,specification)
local t, n = { }, 0
local function flush(s)
n = n + 1
t[n] = s
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
return concat(t,"\n")
end
-function table.tohandle(handle,root,name,reduce,noquotes,hexify)
- serialize(root,name,handle,reduce,noquotes,hexify)
-end
+table.tohandle = serialize
-- sometimes tables are real use (zapfino extra pro is some 85M) in which
-- case a stepwise serialization is nice; actually, we could consider:
@@ -689,7 +685,7 @@ end
local maxtab = 2*1024
-function table.tofile(filename,root,name,reduce,noquotes,hexify)
+function table.tofile(filename,root,name,specification)
local f = io.open(filename,'w')
if f then
if maxtab > 1 then
@@ -702,13 +698,13 @@ function table.tofile(filename,root,name,reduce,noquotes,hexify)
t, n = { }, 0 -- we could recycle t if needed
end
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
f:write(concat(t,"\n"),"\n")
else
local function flush(s)
f:write(s,"\n")
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
end
f:close()
io.flush()
@@ -774,14 +770,6 @@ function table.unnest(t) -- bad name
return unnest(t)
end
---~ function table.unnest(t) -- for old times sake, undocumented (only in mk)
---~ return flattened(t,1)
---~ end
-
---~ function table.are_equal(a,b)
---~ return table.serialize(a) == table.serialize(b)
---~ end
-
local function are_equal(a,b,n,m) -- indexed
if a and b and #a == #b then
n = n or 1
diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua
index 3384f80ee..db8958c14 100644
--- a/tex/context/base/lxml-lpt.lua
+++ b/tex/context/base/lxml-lpt.lua
@@ -823,13 +823,14 @@ xml.nodesettostring = nodesettostring
local lpath -- we have a harmless kind of circular reference
-local lshowoptions = { name = false, functions = false }
+local lshowoptions = { functions = false }
local function lshow(parsed)
if type(parsed) == "string" then
parsed = lpath(parsed)
end
- report_lpath("%s://%s => %s",parsed.protocol or xml.defaultprotocol,parsed.pattern,table.serialize(parsed,lshowoptions))
+ report_lpath("%s://%s => %s",parsed.protocol or xml.defaultprotocol,parsed.pattern,
+ table.serialize(parsed,false,lshowoptions))
end
xml.lshow = lshow
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index d15ff4264..1020d10ae 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 5e11911be..98d73a459 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/generic/context/luatex-basics-gen.lua b/tex/generic/context/luatex-basics-gen.lua
index ad12daa4e..602601d5c 100644
--- a/tex/generic/context/luatex-basics-gen.lua
+++ b/tex/generic/context/luatex-basics-gen.lua
@@ -215,7 +215,7 @@ function caches.savedata(path,name,data)
local fullname = makefullname(path,name)
if fullname then
texio.write(string.format("(save: %s)",fullname))
- table.tofile(fullname,data,'return',false,true,false)
+ table.tofile(fullname,data,true,{ reduce = true })
end
end
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 3c6391e92..c12ed28e3 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 04/11/11 16:45:23
+-- merge date : 04/11/11 18:55:38
do -- begin closure to overcome local limits and interference
@@ -1364,18 +1364,16 @@ end
-- replacing handle by a direct t[#t+1] = ... (plus test) is not much
-- faster (0.03 on 1.00 for zapfino.tma)
-local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might drop the _'s some day.
+local function serialize(_handle,root,name,specification) -- handle wins
local tname = type(name)
- if tname == "table" then
- noquotes = name.noquotes
- hexify = name.hexify
- handle = name.handle or print
- reduce = name.reduce or false
- functions = name.functions
- compact = name.compact
- inline = name.inline and compact
- name = name.name
- tname = type(name)
+ if type(specification) == "table" then
+ noquotes = specification.noquotes
+ hexify = specification.hexify
+ handle = _handle or specification.handle or print
+ reduce = specification.reduce or false
+ functions = specification.functions
+ compact = specification.compact
+ inline = specification.inline and compact
if functions == nil then
functions = true
end
@@ -1386,10 +1384,10 @@ local function serialize(root,name,_handle,_reduce,_noquotes,_hexify) -- I might
inline = compact
end
else
- noquotes = _noquotes
- hexify = _hexify
+ noquotes = false
+ hexify = false
handle = _handle or print
- reduce = _reduce or false
+ reduce = false
compact = true
inline = true
functions = true
@@ -1437,19 +1435,17 @@ end
--~ 'return' : return { }
--~ number : [number] = { }
-function table.serialize(root,name,reduce,noquotes,hexify) -- can be faster if flush == false and t as argument
+function table.serialize(root,name,specification)
local t, n = { }, 0
local function flush(s)
n = n + 1
t[n] = s
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
return concat(t,"\n")
end
-function table.tohandle(handle,root,name,reduce,noquotes,hexify)
- serialize(root,name,handle,reduce,noquotes,hexify)
-end
+table.tohandle = serialize
-- sometimes tables are real use (zapfino extra pro is some 85M) in which
-- case a stepwise serialization is nice; actually, we could consider:
@@ -1462,7 +1458,7 @@ end
local maxtab = 2*1024
-function table.tofile(filename,root,name,reduce,noquotes,hexify)
+function table.tofile(filename,root,name,specification)
local f = io.open(filename,'w')
if f then
if maxtab > 1 then
@@ -1475,13 +1471,13 @@ function table.tofile(filename,root,name,reduce,noquotes,hexify)
t, n = { }, 0 -- we could recycle t if needed
end
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
f:write(concat(t,"\n"),"\n")
else
local function flush(s)
f:write(s,"\n")
end
- serialize(root,name,flush,reduce,noquotes,hexify)
+ serialize(flush,root,name,specification)
end
f:close()
io.flush()
@@ -1547,14 +1543,6 @@ function table.unnest(t) -- bad name
return unnest(t)
end
---~ function table.unnest(t) -- for old times sake, undocumented (only in mk)
---~ return flattened(t,1)
---~ end
-
---~ function table.are_equal(a,b)
---~ return table.serialize(a) == table.serialize(b)
---~ end
-
local function are_equal(a,b,n,m) -- indexed
if a and b and #a == #b then
n = n or 1
@@ -2599,7 +2587,7 @@ function caches.savedata(path,name,data)
local fullname = makefullname(path,name)
if fullname then
texio.write(string.format("(save: %s)",fullname))
- table.tofile(fullname,data,'return',false,true,false)
+ table.tofile(fullname,data,true,{ reduce = true })
end
end