1
- -- MIT License - Copyright (c) 2019 Void (cryon.io)
1
+ -- MIT License - Copyright (c) 2021 V (cryon.io)
2
2
3
3
local WHITESPACE = " \t\n\r "
4
4
local PUNCTUATOR = " {}[],:"
@@ -169,7 +169,7 @@ function HjsonDecoder:new(strict, object_hook, object_pairs_hook)
169
169
goto scan_string_loop_start
170
170
elseif terminator ~= " \\ " then
171
171
if strict then
172
- decodeError (s , begin , " Invalid control character" .. ch )
172
+ decodeError (s , begin , " Invalid control character" .. terminator )
173
173
else
174
174
chunks = chunks .. terminator
175
175
goto scan_string_loop_start
@@ -292,7 +292,7 @@ function HjsonDecoder:new(strict, object_hook, object_pairs_hook)
292
292
local frac = nil
293
293
local exp = nil
294
294
295
- trimmed_range = trim (s :sub (begin , _end - 1 ))
295
+ local trimmed_range = trim (s :sub (begin , _end - 1 ))
296
296
if chf == " n" and trimmed_range == " null" then
297
297
return nil , _end
298
298
elseif chf == " t" and trimmed_range == " true" then
@@ -305,12 +305,12 @@ function HjsonDecoder:new(strict, object_hook, object_pairs_hook)
305
305
if integer then
306
306
frac = s :match (" ^(%.%d+)" , begin + # integer ) or " "
307
307
exp = s :match (" ^([eE][-+]?%d+)" , begin + # integer + # frac ) or " "
308
- ending = s :match (" ^([\t ]*)" , begin + # integer + # frac + # exp ) or " "
308
+ local ending = s :match (" ^([\t ]*)" , begin + # integer + # frac + # exp ) or " "
309
309
m = integer .. frac .. exp .. ending
310
310
end
311
311
end
312
312
if m and begin + # m == _end then
313
- res = tonumber (integer .. frac .. exp )
313
+ local res = tonumber (integer .. frac .. exp )
314
314
return res , _end
315
315
end
316
316
@@ -397,7 +397,7 @@ function HjsonDecoder:new(strict, object_hook, object_pairs_hook)
397
397
-- Trivial empty object
398
398
if not objectWithoutBraces and ch == " }" then
399
399
if type (object_pairs_hook ) == " function" then
400
- result = object_pairs_hook (pairs )
400
+ local result = object_pairs_hook (pairs )
401
401
return result , _end + 1
402
402
end
403
403
pairs = {}
@@ -440,15 +440,15 @@ function HjsonDecoder:new(strict, object_hook, object_pairs_hook)
440
440
ch , _end = getNext (s , _end )
441
441
end
442
442
if type (object_pairs_hook ) == " function" then
443
- result = object_pairs_hook (pairs )
443
+ local result = object_pairs_hook (pairs )
444
444
return result , _end
445
445
end
446
446
447
- pairs = dict (pairs )
447
+ local obj = dict (pairs )
448
448
if type (object_hook ) == " function" then
449
- pairs = object_hook (pairs )
449
+ obj = object_hook (obj )
450
450
end
451
- return pairs , _end
451
+ return obj , _end
452
452
end
453
453
454
454
local function parseArray (state , scanOnce )
0 commit comments