mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 20:51:30 +00:00
Convert json.lua to native bitwise operators
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
-- Modified 02/27/2010 - v0.4 Added unicode handling (written by David Fifield). Renamed toJson
|
-- Modified 02/27/2010 - v0.4 Added unicode handling (written by David Fifield). Renamed toJson
|
||||||
-- and fromJson into generate() and parse(), implemented more proper numeric parsing and added some more error checking.
|
-- and fromJson into generate() and parse(), implemented more proper numeric parsing and added some more error checking.
|
||||||
|
|
||||||
local bit = require "bit";
|
|
||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
@@ -98,7 +97,7 @@ local function unicode16 (subject, position, hex)
|
|||||||
error(("Bad unicode escape \\u%s\\u%s (bad low surrogate)"):format(hex, lowhex))
|
error(("Bad unicode escape \\u%s\\u%s (bad low surrogate)"):format(hex, lowhex))
|
||||||
end
|
end
|
||||||
position = position+6 -- consume '\uXXXX'
|
position = position+6 -- consume '\uXXXX'
|
||||||
cp = 0x10000 + bit.band(cp, 0x3FF) * 0x400 + bit.band(cp2, 0x3FF)
|
cp = 0x10000 + (cp & 0x3FF) * 0x400 + (cp2 & 0x3FF)
|
||||||
return position, unicode.utf8_enc(cp);
|
return position, unicode.utf8_enc(cp);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user