Comparison

util/json.lua @ 8382:e5d00bf4a4d5

util: Various minor changes to please [luacheck]
author Kim Alvefur <zash@zash.se>
date Fri, 10 Nov 2017 05:42:32 +0100
parent 7261:925f848c706d
child 8697:c60fdf148118
comparison
equal deleted inserted replaced
8381:7f6184474149 8382:e5d00bf4a4d5
25 module.null = null; 25 module.null = null;
26 26
27 local escapes = { 27 local escapes = {
28 ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", 28 ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b",
29 ["\f"] = "\\f", ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t"}; 29 ["\f"] = "\\f", ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t"};
30 local unescapes = {
31 ["\""] = "\"", ["\\"] = "\\", ["/"] = "/",
32 b = "\b", f = "\f", n = "\n", r = "\r", t = "\t"};
33 for i=0,31 do 30 for i=0,31 do
34 local ch = s_char(i); 31 local ch = s_char(i);
35 if not escapes[ch] then escapes[ch] = ("\\u%.4X"):format(i); end 32 if not escapes[ch] then escapes[ch] = ("\\u%.4X"):format(i); end
36 end 33 end
37 34
247 if b == 0x5d then return setmetatable(a, array_mt), index + 1; end -- "]" 244 if b == 0x5d then return setmetatable(a, array_mt), index + 1; end -- "]"
248 if b ~= 0x2c then return nil, "array eof"; end -- "," 245 if b ~= 0x2c then return nil, "array eof"; end -- ","
249 end 246 end
250 end 247 end
251 local _unescape_error; 248 local _unescape_error;
252 local function _unescape_surrogate_func(x) 249 local function _unescape_surrogate_func(x) -- luacheck: ignore
253 local lead, trail = tonumber(x:sub(3, 6), 16), tonumber(x:sub(9, 12), 16); 250 local lead, trail = tonumber(x:sub(3, 6), 16), tonumber(x:sub(9, 12), 16);
254 local codepoint = lead * 0x400 + trail - 0x35FDC00; 251 local codepoint = lead * 0x400 + trail - 0x35FDC00;
255 local a = codepoint % 64; 252 local a = codepoint % 64;
256 codepoint = (codepoint - a) / 64; 253 codepoint = (codepoint - a) / 64;
257 local b = codepoint % 64; 254 local b = codepoint % 64;