diff options
author | Kim Alvefur <zash@zash.se> | 2021-11-12 11:43:24 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-11-12 11:43:24 +0100 |
commit | c9479cbb698191e25f781ed6222fea6e9056a6a1 (patch) | |
tree | 79e2cbaef21b1456b81f13b76b63d0cc21b4801d /util/human | |
parent | 35589d345eb9dd045f8a1bb46c91fbaab2b5e73f (diff) | |
download | prosody-c9479cbb698191e25f781ed6222fea6e9056a6a1.tar.gz prosody-c9479cbb698191e25f781ed6222fea6e9056a6a1.zip |
util.human.io: Pass nil to cell mapper to signal missing value
Seems more like conventional Lua than passing an empty string to signal
lack of value.
Diffstat (limited to 'util/human')
-rw-r--r-- | util/human/io.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/util/human/io.lua b/util/human/io.lua index a38ab5dd..a175f5af 100644 --- a/util/human/io.lua +++ b/util/human/io.lua @@ -131,7 +131,15 @@ local function new_table(col_specs, max_width) local output = {}; for i, column in ipairs(col_specs) do local width = widths[i]; - local v = (not titles and column.mapper or tostring)(row[not titles and column.key or i] or "", row); + local v = row[not titles and column.key or i]; + if not titles and column.mapper then + v = column.mapper(v, row); + end + if v == nil then + v = ""; + else + v = tostring(v); + end if #v < width then if column.align == "right" then v = padleft(v, width); |