From d9decd5a0dd0abbe7842da4400e665d96d6b8f9b Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Tue, 15 Apr 2014 22:59:21 +0300 Subject: use 'unpack' function from 'table' module --- aconf/error.lua | 8 ++++---- aconf/loader.lua | 2 +- aconf/modules/network.lua | 2 +- aconf/object.lua | 4 ++-- aconf/path.lua | 6 +++--- aconf/persistence/backends/augeas.lua | 10 ++++++---- aconf/persistence/backends/files.lua | 6 +++--- aconf/persistence/backends/json.lua | 4 ++-- aconf/persistence/backends/service.lua | 2 +- aconf/persistence/backends/volatile.lua | 2 +- aconf/persistence/defer.lua | 2 +- aconf/persistence/init.lua | 2 +- aconf/transaction/base.lua | 4 ++-- aconf/transaction/init.lua | 2 +- 14 files changed, 29 insertions(+), 27 deletions(-) diff --git a/aconf/error.lua b/aconf/error.lua index 165bb46..9a288c7 100644 --- a/aconf/error.lua +++ b/aconf/error.lua @@ -47,7 +47,7 @@ function M.ErrorDict:collect(func, ...) local arg = {...} local success, res = pack( xpcall( - function() return func(unpack(arg)) end, + function() return func(table.unpack(arg)) end, function(err) local _, _, data = err:find('.-: (.+)') local success, res = pcall(json.decode, data) @@ -57,7 +57,7 @@ function M.ErrorDict:collect(func, ...) ) ) - if success then return unpack(res) end + if success then return table.unpack(res) end if type(res) == 'table' then for label, errors in pairs(res) do @@ -78,7 +78,7 @@ end function M.relabel(label, ...) local err = M.ErrorDict() local res = {err:collect(...)} - if err:success() then return unpack(res) end + if err:success() then return table.unpack(res) end elist = ErrorList(label) for lbl, el in pairs(err.errors) do @@ -90,7 +90,7 @@ end function M.call(...) local err = M.ErrorDict() local res = {err:collect(...)} - if err:success() then return true, unpack(res) end + if err:success() then return true, table.unpack(res) end if err.errors.system then error(err.errors.system[1]) end return false, err.errors end diff --git a/aconf/loader.lua b/aconf/loader.lua index 8c58adc..c6f8c63 100644 --- a/aconf/loader.lua +++ b/aconf/loader.lua @@ -11,7 +11,7 @@ local stringy = require('stringy') return function(subdir) local comps = pth.split('aconf/'..subdir) local res = {} - for _, modfile in ipairs(posix.dir(pth.join(unpack(comps)))) do + for _, modfile in ipairs(posix.dir(pth.join(table.unpack(comps)))) do if stringy.endswith(modfile, '.lua') then local name = modfile:sub(1, -5) res[name] = require(table.concat(comps, '.')..'.'..name) diff --git a/aconf/modules/network.lua b/aconf/modules/network.lua index 80ef079..34b4064 100644 --- a/aconf/modules/network.lua +++ b/aconf/modules/network.lua @@ -128,7 +128,7 @@ Interface.class = M.String{ {saddr, 'bridge'}, {'/files/proc/net/vlan', name} } do - if txn:get(M.path.join(unpack(addr))) then + if txn:get(M.path.join(table.unpack(addr))) then return 'logical' end end diff --git a/aconf/object.lua b/aconf/object.lua index 64fbb9c..a81fbf8 100644 --- a/aconf/object.lua +++ b/aconf/object.lua @@ -1,5 +1,5 @@ --[[ -Copyright (c) 2012-2013 Kaarle Ritvanen +Copyright (c) 2012-2014 Kaarle Ritvanen See LICENSE file for license details --]] @@ -43,7 +43,7 @@ function M.super(obj, cls) return function(...) local arg = {...} arg[1] = obj - return v(unpack(arg)) + return v(table.unpack(arg)) end end diff --git a/aconf/path.lua b/aconf/path.lua index 8f0bd14..e13f17c 100644 --- a/aconf/path.lua +++ b/aconf/path.lua @@ -33,7 +33,7 @@ function M.rawjoin(p1, p2, ...) end function M.join(parent, ...) - return M.rawjoin(parent, unpack(map(M.escape, {...}))) + return M.rawjoin(parent, table.unpack(map(M.escape, {...}))) end @@ -100,14 +100,14 @@ function M.to_absolute(path, base) i = i - 1 else i = i + 1 end end - return M.join('/', unpack(comps)) + return M.join('/', table.unpack(comps)) end function M.parent(path) local comps = M.split(path) table.remove(comps) - return M.join('/', unpack(comps)) + return M.join('/', table.unpack(comps)) end function M.name(path) diff --git a/aconf/persistence/backends/augeas.lua b/aconf/persistence/backends/augeas.lua index a448e65..7ffccb9 100644 --- a/aconf/persistence/backends/augeas.lua +++ b/aconf/persistence/backends/augeas.lua @@ -161,7 +161,7 @@ function backend:set(mods) local gc = {} for _, mod in ipairs(mods) do - local path, value = unpack(mod) + local path, value = table.unpack(mod) local function insert(path, new) local apath, mode, keys = conv_path(path) @@ -173,7 +173,7 @@ function backend:set(mods) local ppath, pmode = conv_path(parent) if pmode then - gc[pth.join(unpack(array_without_last(parent)))] = false + gc[pth.join(table.unpack(array_without_last(parent)))] = false end if pmode == '#' then @@ -239,7 +239,7 @@ function backend:set(mods) self.aug:set(apath, value ~= nil and tostr(value) or nil) end - util.setdefault(gc, pth.join(unpack(path)), true) + util.setdefault(gc, pth.join(table.unpack(path)), true) end for path, _ in pairs(gc) do @@ -255,7 +255,9 @@ function backend:set(mods) break end - if gc[pth.join(unpack(p))] ~= false then self.aug:rm(conv_path(p)) end + if gc[pth.join(table.unpack(p))] ~= false then + self.aug:rm(conv_path(p)) + end p[#p] = nil end end diff --git a/aconf/persistence/backends/files.lua b/aconf/persistence/backends/files.lua index e19763d..1c78c80 100644 --- a/aconf/persistence/backends/files.lua +++ b/aconf/persistence/backends/files.lua @@ -29,7 +29,7 @@ local backend = require('aconf.object').class() function backend:init() self.cache = {} end function backend:get(path, top) - local name = pth.join('/', unpack(path)) + local name = pth.join('/', table.unpack(path)) if not self.cache[name] then local t = posix.stat(name, 'type') @@ -68,8 +68,8 @@ end function backend:set(mods) for _, mod in pairs(mods) do - local path, value = unpack(mod) - local name = pth.join('/', unpack(path)) + local path, value = table.unpack(mod) + local name = pth.join('/', table.unpack(path)) if value == nil then print('DEL', name) diff --git a/aconf/persistence/backends/json.lua b/aconf/persistence/backends/json.lua index 607315a..bdf2715 100644 --- a/aconf/persistence/backends/json.lua +++ b/aconf/persistence/backends/json.lua @@ -26,7 +26,7 @@ function backend:split_path(path) local res while #fpath > 0 do - local fp = pth.join('/', unpack(fpath)) + local fp = pth.join('/', table.unpack(fpath)) if self.cache[fp] then return fp, jpath end table.insert(jpath, 1, fpath[#fpath]) table.remove(fpath) @@ -62,7 +62,7 @@ function backend:set(mods) local dirty = {} for _, mod in ipairs(mods) do - local path, value = unpack(mod) + local path, value = table.unpack(mod) local fpath, jpath = self:split_path(path) self.cache[fpath]:_set(jpath, value) dirty[fpath] = true diff --git a/aconf/persistence/backends/service.lua b/aconf/persistence/backends/service.lua index 4569ce8..bd52d31 100644 --- a/aconf/persistence/backends/service.lua +++ b/aconf/persistence/backends/service.lua @@ -19,7 +19,7 @@ end function backend:set(mods) for _, mod in ipairs(mods) do - local path, value = unpack(mod) + local path, value = table.unpack(mod) assert(#path == 2 and path[2] == 'enabled') local name = path[1] diff --git a/aconf/persistence/backends/volatile.lua b/aconf/persistence/backends/volatile.lua index 7016a9b..1a05b1b 100644 --- a/aconf/persistence/backends/volatile.lua +++ b/aconf/persistence/backends/volatile.lua @@ -39,7 +39,7 @@ function backend:_set(path, value) end function backend:set(mods) - for _, mod in ipairs(mods) do self:_set(unpack(mod)) end + for _, mod in ipairs(mods) do self:_set(table.unpack(mod)) end end diff --git a/aconf/persistence/defer.lua b/aconf/persistence/defer.lua index 5db5a21..cfa8e8b 100644 --- a/aconf/persistence/defer.lua +++ b/aconf/persistence/defer.lua @@ -28,7 +28,7 @@ function DeferringCommitter:_set_multiple(mods) self.committed = false for _, mod in ipairs(mods) do - local path, value = unpack(mod) + local path, value = table.unpack(mod) while path > '/' do if self.defer_paths[path] then return end path = pth.parent(path) diff --git a/aconf/persistence/init.lua b/aconf/persistence/init.lua index bcc1f0e..d95da2d 100644 --- a/aconf/persistence/init.lua +++ b/aconf/persistence/init.lua @@ -88,7 +88,7 @@ function DataStore:_set_multiple(mods) local trigger = {} for _, mod in ipairs(mods) do - local path, value = unpack(mod) + local path, value = table.unpack(mod) local tp = path while not trigger[tp] do diff --git a/aconf/transaction/base.lua b/aconf/transaction/base.lua index 9df0bc2..2bdc963 100644 --- a/aconf/transaction/base.lua +++ b/aconf/transaction/base.lua @@ -47,7 +47,7 @@ function M.TransactionBackend:set_multiple(mods) local function tostr(s) return s ~= nil and tostring(s) or nil end for _, mod in ipairs(mods) do - local path, value = unpack(mod) + local path, value = table.unpack(mod) if type(value) == 'table' or type( self:get(path) @@ -128,7 +128,7 @@ function M.Transaction:_set_multiple(mods) end for _, mod in ipairs(mods) do - local path, value = unpack(mod) + local path, value = table.unpack(mod) local ppath = pth.parent(path) local parent = self:get(ppath) diff --git a/aconf/transaction/init.lua b/aconf/transaction/init.lua index d4c79fe..faa5d7e 100644 --- a/aconf/transaction/init.lua +++ b/aconf/transaction/init.lua @@ -46,7 +46,7 @@ end function ModelTransaction:set_multiple(mods) super(self, ModelTransaction):set_multiple(mods) for _, mod in ipairs(mods) do - local addr, value = unpack(mod) + local addr, value = table.unpack(mod) if value == nil then for _, val in ipairs{self.validable, self.commit_val} do local done -- cgit v1.2.3