Changeset

12501:042de4f0076e

Merge 0.12->trunk
author Kim Alvefur <zash@zash.se>
date Mon, 09 May 2022 22:40:45 +0200
parents 12498:c3e47a5dd30d (current diff) 12500:88e1b94105ae (diff)
children 12502:5862ddf71e3c
files
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/jsonpointer.lua	Sun May 08 15:21:35 2022 +0200
+++ b/util/jsonpointer.lua	Mon May 09 22:40:45 2022 +0200
@@ -1,3 +1,7 @@
+local m_type = math.type or function (n)
+	return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float";
+end;
+
 local function unescape_token(escaped_token)
 	local unescaped = escaped_token:gsub("~1", "/"):gsub("~0", "~")
 	return unescaped
@@ -15,7 +19,7 @@
 
 		if type(idx) == "string" then
 			new_ref = ref[token]
-		elseif math.type(idx) == "integer" then
+		elseif m_type(idx) == "integer" then
 			local i = tonumber(token)
 			if token == "-" then
 				i = #ref + 1
--- a/util/jsonschema.lua	Sun May 08 15:21:35 2022 +0200
+++ b/util/jsonschema.lua	Mon May 09 22:40:45 2022 +0200
@@ -1,3 +1,6 @@
+local m_type = math.type or function (n)
+	return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float";
+end;
 local json = require("util.json")
 local null = json.null;
 
@@ -17,7 +20,7 @@
 	elseif schema == "array" and type(data) == "table" then
 		return type(data) == "table" and (next(data) == nil or type((next(data, nil))) == "number")
 	elseif schema == "integer" then
-		return math.type(data) == schema
+		return m_type(data) == schema
 	elseif schema == "null" then
 		return data == null
 	else