diff options
Diffstat (limited to 'lib/clod.lua')
-rw-r--r-- | lib/clod.lua | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/clod.lua b/lib/clod.lua index 4114fd6..8f9ec7f 100644 --- a/lib/clod.lua +++ b/lib/clod.lua @@ -293,7 +293,7 @@ function clod_mt:__index(key) end end -local function parse_config(conf, confname) +local function parse_config(conf, confname, migrate_lists) local ret = {} local settings = {} local last_entry = {lineno = 0} @@ -316,16 +316,28 @@ local function parse_config(conf, confname) end function parse_mt:__newindex(key, value) -- This is the equivalent of 'foo = "bar"' instead of 'foo "bar"' + if migrate_lists and type(value) == "table" then + for i = 1, #value do + self[key .. ".*"](value[i],1) + end + return + end if type(value) == "table" or type(value) == "function" then error("Clod does not support " .. type(value) .. "s as values") end return self[key](value, 1) end function parse_mt:__call(value, offset) + local key = assert(keys[self]) + if migrate_lists and type(value) == "table" then + for i = 1, #value do + self["*"](value[i],2) + end + return + end if type(value) == "table" or type(value) == "function" then error("Clod does not support " .. type(value) .. "s as values") end - local key = assert(keys[self]) local wild_prefix, last_key_element = key:match("^(.-)([^.]+)$") if last_key_element == "*" then -- Wild insert, so calculate a unique key to use |