Mercurial > prosody-hg
comparison util/jsonschema.lua @ 13163:f43d04653bcf
util.jsonschema: Silence Teal warnings about utf8 library
Teal worries that we redefine the global.
Also that the fallback was missing type information.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 17 Jun 2023 17:17:44 +0200 |
| parents | 6140aa67c618 |
| children | 1aa83a5667f9 |
comparison
equal
deleted
inserted
replaced
| 13162:6140aa67c618 | 13163:f43d04653bcf |
|---|---|
| 2 | 2 |
| 3 local m_type = function(n) | 3 local m_type = function(n) |
| 4 return type(n) == "number" and n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; | 4 return type(n) == "number" and n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; |
| 5 end; | 5 end; |
| 6 | 6 |
| 7 local utf8 = rawget(_G, "utf8") or require("prosody.util.encodings").utf8; | 7 local utf8_enc = rawget(_G, "utf8") or require("prosody.util.encodings").utf8; |
| 8 local utf8_len = utf8.len or function(s) | 8 local utf8_len = utf8_enc.len or function(s) |
| 9 local _, count = s:gsub("[%z\001-\127\194-\253][\128-\191]*", ""); | 9 local _, count = s:gsub("[%z\001-\127\194-\253][\128-\191]*", ""); |
| 10 return count | 10 return count |
| 11 end; | 11 end; |
| 12 local json = require("prosody.util.json") | 12 local json = require("prosody.util.json") |
| 13 local null = json.null; | 13 local null = json.null; |
