From 58291a2a489e77f69e1234ea9a6217244ae0de5f Mon Sep 17 00:00:00 2001 From: Hanlei Qin Date: Tue, 29 Oct 2019 15:29:28 +0800 Subject: [PATCH] restore some styles as before. --- lualib/skynet/db/mysql.lua | 57 +++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/lualib/skynet/db/mysql.lua b/lualib/skynet/db/mysql.lua index 1a7240b6..f63963ea 100644 --- a/lualib/skynet/db/mysql.lua +++ b/lualib/skynet/db/mysql.lua @@ -102,13 +102,10 @@ local function _from_cstring(data, i) end local function _dumphex(bytes) - return strgsub( - bytes, - ".", + return strgsub(bytes, ".", function(x) return strformat("%02x ", strbyte(x)) - end - ) + end) end local function _compute_token(password, scramble) @@ -123,9 +120,7 @@ local function _compute_token(password, scramble) local stage3 = sha1(scramble .. stage2) local i = 0 - return strgsub( - stage3, - ".", + return strgsub(stage3, ".", function(x) i = i + 1 -- ~ is xor in lua 5.3 @@ -258,7 +253,7 @@ local function _parse_err_packet(packet) local errno, pos = _get_byte2(packet, 2) local marker = sub(packet, pos, pos) local sqlstate - if marker == "#" then + if marker == '#' then -- with sqlstate pos = pos + 1 sqlstate = sub(packet, pos, pos + 5 - 1) @@ -413,9 +408,7 @@ local function _mysql_login(self, user, password, database, on_connect) local scramble = scramble1 .. scramble_part2 local token = _compute_token(password, scramble) local client_flags = 260047 - local req = - strpack( - "