Software / code / prosody
Comparison
util/format.lua @ 12983:4533c9b906b0
util.format: Tweak serialization of %q formatted entries
Improves serialization of function references especially, the built-in
default handling of that in util.serialization is not the most
informative. Now, along with the function metatable from util.startup,
the actual function can be found by filename and line number.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 26 Mar 2023 00:18:05 +0100 |
| parent | 12975:d10957394a3c |
| child | 12984:f08125a8be34 |
comparison
equal
deleted
inserted
replaced
| 12982:fc0109c59807 | 12983:4533c9b906b0 |
|---|---|
| 8 local tostring = tostring; | 8 local tostring = tostring; |
| 9 local unpack = table.unpack; | 9 local unpack = table.unpack; |
| 10 local pack = table.pack; | 10 local pack = table.pack; |
| 11 local valid_utf8 = require "prosody.util.encodings".utf8.valid; | 11 local valid_utf8 = require "prosody.util.encodings".utf8.valid; |
| 12 local type = type; | 12 local type = type; |
| 13 local dump = require "prosody.util.serialization".new("debug"); | 13 local dump = require"prosody.util.serialization".new({ |
| 14 preset = "compact"; | |
| 15 fallback = function(v, why) | |
| 16 return "_[[" .. (why or tostring(v)) .. "]] "; | |
| 17 end; | |
| 18 fatal = false; | |
| 19 maxdepth = 5; | |
| 20 }); | |
| 14 local num_type = math.type; | 21 local num_type = math.type; |
| 15 | 22 |
| 16 -- In Lua 5.3+ these formats throw an error if given a float | 23 -- In Lua 5.3+ these formats throw an error if given a float |
| 17 local expects_integer = { c = true, d = true, i = true, o = true, u = true, X = true, x = true, }; | 24 local expects_integer = { c = true, d = true, i = true, o = true, u = true, X = true, x = true, }; |
| 18 -- In Lua 5.2 these throw an error given a negative number | 25 -- In Lua 5.2 these throw an error given a negative number |