From 508076688bcdacc338450448fa43a229b7023c74 Mon Sep 17 00:00:00 2001 From: Tom van Dijck Date: Wed, 10 May 2017 10:21:44 -0700 Subject: [PATCH] Fix empty rules. --- src/base/rule.lua | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/base/rule.lua b/src/base/rule.lua index b1ad1add..345b1d30 100644 --- a/src/base/rule.lua +++ b/src/base/rule.lua @@ -120,14 +120,22 @@ function rule.getPropertyString(self, prop, value) -- list? if type(value) == "table" then - local sep = prop.separator or " " - return table.concat(value, sep) + if #value > 0 then + local sep = prop.separator or " " + return table.concat(value, sep) + else + return nil + end end -- enum? if prop.values then local i = table.indexof(prop.values, value) - return tostring(i) + if i ~= nil then + return tostring(i) + else + return nil + end end -- primitive @@ -159,13 +167,21 @@ -- list? if type(value) == "table" then - return prop.switch .. table.concat(value, " " .. prop.switch) + if #value > 0 then + return prop.switch .. table.concat(value, " " .. prop.switch) + else + return nil + end end -- enum? if prop.values then local i = table.indexof(prop.values, value) - return prop.switch .. tostring(i) + if i ~= nil then + return prop.switch .. tostring(i) + else + return nil + end end -- primitive