From a05f75a09295414a7a230158c3db89b4f90668c7 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 8 Jul 2016 07:50:22 +0200 Subject: [features] include feature spec validation --- src/luaotfload-features.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src') 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 -- cgit v1.2.3