diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2016-07-08 07:50:22 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2016-07-08 07:50:22 +0200 |
commit | a05f75a09295414a7a230158c3db89b4f90668c7 (patch) | |
tree | 7f7575cdf83cd0cb068718563b14d56b4e5e537c /src | |
parent | 5488311b07aca41b6b5c6c80f8fcc3c304edc45b (diff) | |
download | luaotfload-a05f75a09295414a7a230158c3db89b4f90668c7.tar.gz |
[features] include feature spec validation
Diffstat (limited to 'src')
-rw-r--r-- | src/luaotfload-features.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/luaotfload-features.lua b/src/luaotfload-features.lua index 7404910..786f619 100644 --- a/src/luaotfload-features.lua +++ b/src/luaotfload-features.lua @@ -1334,6 +1334,42 @@ local noflags = { false, false, false, false } local tohash = table.tohash +local function validspecification(specification,name) + local dataset = specification.dataset + if dataset then + -- okay + elseif specification[1] then + dataset = specification + specification = { dataset = dataset } + else + dataset = { { data = specification.data } } + specification.data = nil + specification.dataset = dataset + end + local first = dataset[1] + if first then + first = first.data + end + if not first then + report_otf("invalid feature specification, no dataset") + return + end + if type(name) ~= "string" then + name = specification.name or first.name + end + if type(name) ~= "string" then + report_otf("invalid feature specification, no name") + return + end + local n = #dataset + if n > 0 then + for i=1,n do + setmetatableindex(dataset[i],specification) + end + return specification, name + end +end + local function addfeature(data,feature,specifications) -- todo: add some validator / check code so that we're more tolerant to |