summaryrefslogtreecommitdiff
path: root/tex/context/base/core-dat.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/core-dat.lua')
-rw-r--r--tex/context/base/core-dat.lua60
1 files changed, 18 insertions, 42 deletions
diff --git a/tex/context/base/core-dat.lua b/tex/context/base/core-dat.lua
index 879ff6130..071a3fe0b 100644
--- a/tex/context/base/core-dat.lua
+++ b/tex/context/base/core-dat.lua
@@ -11,7 +11,7 @@ if not modules then modules = { } end modules ['core-dat'] = {
replaces the twopass data mechanism.</p>
--ldx]]--
-local tonumber, type = tonumber, type
+local tonumber = tonumber
local context, commands = context, commands
@@ -69,12 +69,7 @@ local function setdata(settings)
local tag = settings.tag
local data = settings.data
local list = tobesaved[name]
- if settings.convert and type(data) == "string" then
- data = settings_to_hash(data)
- end
- if type(data) ~= "table" then
- data = { data = settings.data }
- end
+ data = settings_to_hash(data) or { }
if not tag then
tag = #list + 1
else
@@ -114,30 +109,25 @@ end
function datasets.getdata(name,tag,key,default)
local t = collected[name]
- if t == nil then
- if trace_datasets then
- report_dataset("unknown: name %s",name)
- end
- elseif type(t) ~= "table" then
- return t
- else
+ if t then
t = t[tag] or t[tonumber(tag)]
- if not t then
- if trace_datasets then
- report_dataset("unknown: name %s, tag %s",name,tag)
+ if t then
+ if key then
+ return t[key] or default
+ else
+ return t
end
- elseif key then
- return t[key] or default
- else
- return t
+ elseif trace_datasets then
+ report_dataset("unknown: name %s, tag %s",name,tag)
end
+ elseif trace_datasets then
+ report_dataset("unknown: name %s",name)
end
return default
end
function commands.setdataset(settings)
- settings.convert = true
- local name, tag = setdata(settings)
+ local name, tag, data = setdata(settings)
if settings.delay ~= v_yes then
--
elseif type(tag) == "number" then
@@ -149,25 +139,11 @@ end
function commands.datasetvariable(name,tag,key)
local t = collected[name]
- if t == nil then
- if trace_datasets then
- report_dataset("unknown: name %s (not passed to tex)",name)
- end
- elseif type(t) ~= "table" then
- context(tostring(t))
- else
- t = t and (t[tag] or t[tonumber(tag)])
- if not t then
- if trace_datasets then
- report_dataset("unknown: name %s with tag %s (not passed to tex)",name,tag)
- end
- elseif type(t) ~= "table" then
- local s = t[key]
- if type(s) ~= "table" then
- context(tostring(s))
- elseif trace_datasets then
- report_dataset("table: name %s, tag %s (not passed to tex)",name,tag)
- end
+ t = t and (t[tag] or t[tonumber(tag)])
+ if t then
+ local s = t[key]
+ if s then
+ context(s)
end
end
end