mirror of
https://github.com/kikito/inspect.lua.git
synced 2024-12-15 14:34:21 +00:00
Renaming of variables and spacing
This commit is contained in:
parent
bdf85c8f90
commit
dca60a2beb
24
inspect.lua
24
inspect.lua
@ -42,24 +42,24 @@ local function smartQuote(str)
|
|||||||
return '"' .. str:gsub('"', '\\"') .. '"'
|
return '"' .. str:gsub('"', '\\"') .. '"'
|
||||||
end
|
end
|
||||||
|
|
||||||
local controlCharsTranslation = {
|
-- \a => '\\a', \0 => '\\0', 31 => '\31'
|
||||||
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
|
local shortControlCharEscapes = {
|
||||||
|
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
|
||||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v"
|
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v"
|
||||||
}
|
}
|
||||||
|
local longControlCharEscapes = {} -- \a => nil, \0 => \000, 31 => \031
|
||||||
local controlCharsTranslationBeforeDigit = {}
|
|
||||||
|
|
||||||
for i=0, 31 do
|
for i=0, 31 do
|
||||||
local ch = string.char(i)
|
local ch = string.char(i)
|
||||||
if not controlCharsTranslation[ch] then
|
if not shortControlCharEscapes[ch] then
|
||||||
controlCharsTranslation[ch] = "\\"..i
|
shortControlCharEscapes[ch] = "\\"..i
|
||||||
controlCharsTranslationBeforeDigit[ch] = string.format("\\%03d",i)
|
longControlCharEscapes[ch] = string.format("\\%03d", i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function escape(str)
|
local function escape(str)
|
||||||
local result = str:gsub("\\", "\\\\"):gsub("(%c)%f[0-9]", controlCharsTranslationBeforeDigit):gsub("(%c)", controlCharsTranslation)
|
return (str:gsub("\\", "\\\\")
|
||||||
return result
|
:gsub("(%c)%f[0-9]", longControlCharEscapes)
|
||||||
|
:gsub("%c", shortControlCharEscapes))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function isIdentifier(str)
|
local function isIdentifier(str)
|
||||||
|
Loading…
Reference in New Issue
Block a user