Software /
code /
prosody
Comparison
util/format.lua @ 11644:fc1b8fe94d04
util.format: Change formatting of nil values to avoid looking like XML
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 29 Jun 2021 16:18:31 +0200 |
parent | 11638:5f4a657136bc |
child | 11646:b6ea0148ad37 |
comparison
equal
deleted
inserted
replaced
11643:f534eeee1552 | 11644:fc1b8fe94d04 |
---|---|
53 local arg = args[i]; | 53 local arg = args[i]; |
54 | 54 |
55 local option = spec:sub(-1); | 55 local option = spec:sub(-1); |
56 if arg == nil then | 56 if arg == nil then |
57 args[i] = "nil"; | 57 args[i] = "nil"; |
58 spec = "<%s>"; | 58 spec = "(%s)"; |
59 elseif option == "q" then | 59 elseif option == "q" then |
60 args[i] = dump(arg); | 60 args[i] = dump(arg); |
61 spec = "%s"; | 61 spec = "%s"; |
62 elseif option == "s" then | 62 elseif option == "s" then |
63 args[i] = tostring(arg):gsub("[%z\1-31\127]", control_symbols); | 63 args[i] = tostring(arg):gsub("[%z\1-31\127]", control_symbols); |
75 -- process extra args | 75 -- process extra args |
76 while i < args_length do | 76 while i < args_length do |
77 i = i + 1; | 77 i = i + 1; |
78 local arg = args[i]; | 78 local arg = args[i]; |
79 if arg == nil then | 79 if arg == nil then |
80 args[i] = "<nil>"; | 80 args[i] = "(nil)"; |
81 else | 81 else |
82 args[i] = tostring(arg); | 82 args[i] = tostring(arg); |
83 end | 83 end |
84 formatstring = formatstring .. " [%s]" | 84 formatstring = formatstring .. " [%s]" |
85 end | 85 end |