Merge 0.10->trunk
authorMatthew Wild <mwild1@gmail.com>
Thu, 10 Mar 2016 17:55:40 +0000 (17:55 +0000)
committerMatthew Wild <mwild1@gmail.com>
Thu, 10 Mar 2016 17:55:40 +0000 (17:55 +0000)
net/websocket/frames.lua
util/datetime.lua
util/iterators.lua
util/json.lua
util/prosodyctl.lua
util/rfc6724.lua

index 737f46bbffedb2e7aa0f9d077eda720f7106a8fe..5fe96d4564b9fa590244cc5c6267d2f682de3e82 100644 (file)
@@ -7,7 +7,6 @@
 --
 
 local softreq = require "util.dependencies".softreq;
-local log = require "util.logger".init "websocket.frames";
 local random_bytes = require "util.random".bytes;
 
 local bit = assert(softreq"bit" or softreq"bit32",
index 27f28ace7eff560c5b3c7efc1caa0bbc880809e8..abb4e867b2aaa51ef2c254a963dcdc019ac69310 100644 (file)
@@ -12,7 +12,6 @@
 local os_date = os.date;
 local os_time = os.time;
 local os_difftime = os.difftime;
-local error = error;
 local tonumber = tonumber;
 
 local _ENV = nil;
index 868ba786a6ba7cfceb886d29e1ef7341d91eaccd..d453a6946007ec618c07399c283bcc4368c1c0e8 100644 (file)
@@ -29,10 +29,10 @@ function it.reverse(f, s, var)
 
        -- Then return our reverse one
        local i,max = 0, #results;
-       return function (results)
+       return function (_results)
                        if i<max then
                                i = i + 1;
-                               return unpack(results[i]);
+                               return unpack(_results[i]);
                        end
                end, results;
 end
@@ -48,8 +48,8 @@ end
 -- Iterate only over values in a table
 function it.values(t)
        local key, val;
-       return function (t)
-               key, val = next(t, key);
+       return function (_t)
+               key, val = next(_t, key);
                return val;
        end, t;
 end
@@ -87,18 +87,18 @@ end
 -- Return the first n items an iterator returns
 function it.head(n, f, s, var)
        local c = 0;
-       return function (s, var)
+       return function (_s, _var)
                if c >= n then
                        return nil;
                end
                c = c + 1;
-               return f(s, var);
-       end, s;
+               return f(_s, _var);
+       end, s, var;
 end
 
 -- Skip the first n items an iterator returns
 function it.skip(n, f, s, var)
-       for i=1,n do
+       for _ = 1, n do
                var = f(s, var);
        end
        return f, s, var;
@@ -132,9 +132,9 @@ function it.filter(filter, f, s, var)
                local filter_value = filter;
                function filter(x) return x ~= filter_value; end
        end
-       return function (s, var)
+       return function (_s, _var)
                local ret;
-               repeat ret = pack(f(s, var));
+               repeat ret = pack(f(_s, _var));
                        var = ret[1];
                until var == nil or filter(unpack(ret, 1, ret.n));
                return unpack(ret, 1, ret.n);
@@ -154,7 +154,7 @@ end
 
 -- Convert the values returned by an iterator to an array
 function it.to_array(f, s, var)
-       local t, var = {};
+       local t = {};
        while true do
                var = f(s, var);
                if var == nil then break; end
index 2c598446bab233d05825b7926bd21a7bd29d7b19..cba54e8e1b3c8b52f4d5f0d81f3e941437a08e71 100644 (file)
@@ -12,7 +12,6 @@ local s_char = string.char;
 local tostring, tonumber = tostring, tonumber;
 local pairs, ipairs = pairs, ipairs;
 local next = next;
-local error = error;
 local getmetatable, setmetatable = getmetatable, setmetatable;
 local print = print;
 
@@ -20,10 +19,10 @@ local has_array, array = pcall(require, "util.array");
 local array_mt = has_array and getmetatable(array()) or {};
 
 --module("json")
-local json = {};
+local module = {};
 
 local null = setmetatable({}, { __tostring = function() return "null"; end; });
-json.null = null;
+module.null = null;
 
 local escapes = {
        ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b",
@@ -70,7 +69,7 @@ end
 function arraysave(o, buffer)
        t_insert(buffer, "[");
        if next(o) then
-               for i,v in ipairs(o) do
+               for _, v in ipairs(o) do
                        simplesave(v, buffer);
                        t_insert(buffer, ",");
                end
@@ -165,17 +164,17 @@ function simplesave(o, buffer)
        end
 end
 
-function json.encode(obj)
+function module.encode(obj)
        local t = {};
        simplesave(obj, t);
        return t_concat(t);
 end
-function json.encode_ordered(obj)
+function module.encode_ordered(obj)
        local t = { ordered = true };
        simplesave(obj, t);
        return t_concat(t);
 end
-function json.encode_array(obj)
+function module.encode_array(obj)
        local t = {};
        arraysave(obj, t);
        return t_concat(t);
@@ -191,7 +190,7 @@ local function _fixobject(obj)
        local __array = obj.__array;
        if __array then
                obj.__array = nil;
-               for i,v in ipairs(__array) do
+               for _, v in ipairs(__array) do
                        t_insert(obj, v);
                end
        end
@@ -199,7 +198,7 @@ local function _fixobject(obj)
        if __hash then
                obj.__hash = nil;
                local k;
-               for i,v in ipairs(__hash) do
+               for _, v in ipairs(__hash) do
                        if k ~= nil then
                                obj[k] = v; k = nil;
                        else
@@ -344,7 +343,7 @@ local first_escape = {
        ["\\u" ] = "\\u";
 };
 
-function json.decode(json)
+function module.decode(json)
        json = json:gsub("\\.", first_escape) -- get rid of all escapes except \uXXXX, making string parsing much simpler
                --:gsub("[\r\n]", "\t"); -- \r\n\t are equivalent, we care about none of them, and none of them can be in strings
 
@@ -357,10 +356,10 @@ function json.decode(json)
        return val;
 end
 
-function json.test(object)
-       local encoded = json.encode(object);
-       local decoded = json.decode(encoded);
-       local recoded = json.encode(decoded);
+function module.test(object)
+       local encoded = module.encode(object);
+       local decoded = module.decode(encoded);
+       local recoded = module.encode(decoded);
        if encoded ~= recoded then
                print("FAILED");
                print("encoded:", encoded);
@@ -371,4 +370,4 @@ function json.test(object)
        return encoded == recoded;
 end
 
-return json;
+return module;
index f8f2864412d48bd83dfd60b69c806e9cb287bfc5..cde1cdd4ce7b839d07648835c2948eeaf25dbcd7 100644 (file)
@@ -22,7 +22,7 @@ local nodeprep, nameprep = stringprep.nodeprep, stringprep.nameprep;
 
 local io, os = io, os;
 local print = print;
-local tostring, tonumber = tostring, tonumber;
+local tonumber = tonumber;
 
 local CFG_SOURCEDIR = _G.CFG_SOURCEDIR;
 
@@ -149,7 +149,7 @@ local function adduser(params)
 end
 
 local function user_exists(params)
-       local user, host, password = nodeprep(params.user), nameprep(params.host), params.password;
+       local user, host = nodeprep(params.user), nameprep(params.host);
 
        storagemanager.initialize_host(host);
        local provider = prosody.hosts[host].users;
index c8aec631ae4af2478b0eb08b4ddaf5b3098d873e..81f78d55f764bb14c227231fe25f7bae4124108d 100644 (file)
@@ -10,7 +10,6 @@
 -- We can't hand this off to getaddrinfo, since it blocks
 
 local ip_commonPrefixLength = require"util.ip".commonPrefixLength
-local new_ip = require"util.ip".new_ip;
 
 local function commonPrefixLength(ipA, ipB)
        local len = ip_commonPrefixLength(ipA, ipB);