mirror of
https://github.com/kikito/inspect.lua.git
synced 2024-12-15 14:34:21 +00:00
renamed "unescape" functions to "escape"
These functions replace raw characters with escape sequences rather than the reverse.
This commit is contained in:
parent
6373d7748a
commit
a5291a2a2c
10
inspect.lua
10
inspect.lua
@ -42,10 +42,10 @@ local controlCharsTranslation = {
|
||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\\"] = "\\\\"
|
||||
}
|
||||
|
||||
local function unescapeChar(c) return controlCharsTranslation[c] end
|
||||
local function escapeChar(c) return controlCharsTranslation[c] end
|
||||
|
||||
local function unescape(str)
|
||||
local result, _ = string.gsub(str, "(%c)", unescapeChar)
|
||||
local function escape(str)
|
||||
local result = string.gsub(str, "(%c)", escapeChar)
|
||||
return result
|
||||
end
|
||||
|
||||
@ -222,7 +222,7 @@ function inspect.inspect(rootObject, options)
|
||||
puts('{')
|
||||
down(function()
|
||||
if to_string_result then
|
||||
puts(' -- ', unescape(to_string_result))
|
||||
puts(' -- ', escape(to_string_result))
|
||||
if length >= 1 then tabify() end -- tabify the array values
|
||||
end
|
||||
|
||||
@ -268,7 +268,7 @@ function inspect.inspect(rootObject, options)
|
||||
local tv = type(v)
|
||||
|
||||
if tv == 'string' then
|
||||
puts(smartQuote(unescape(v)))
|
||||
puts(smartQuote(escape(v)))
|
||||
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then
|
||||
puts(tostring(v))
|
||||
elseif tv == 'table' then
|
||||
|
Loading…
Reference in New Issue
Block a user