diff --git a/log.lua b/log.lua
index 8903e08..4e428d8 100644
--- a/log.lua
+++ b/log.lua
@@ -1,38 +1,38 @@
function log(stack_frame_index, obj)
- local info = debug.getinfo(stack_frame_index, 'Sl')
- local msg
- if type(obj) == 'string' then
- msg = obj
- else
- msg = json.encode(obj)
- end
- love.filesystem.append('log', info.short_src..':'..info.currentline..': '..msg..'\n')
+ local info = debug.getinfo(stack_frame_index, 'Sl')
+ local msg
+ if type(obj) == 'string' then
+ msg = obj
+ else
+ msg = json.encode(obj)
+ end
+ love.filesystem.append('log', info.short_src..':'..info.currentline..': '..msg..'\n')
end
-- for section delimiters we'll use specific Unicode box characters
function log_start(name, stack_frame_index)
- if stack_frame_index == nil then
- stack_frame_index = 3
- end
- -- I'd like to use the unicode character \u{250c} here, but it doesn't work
- -- in OpenBSD.
- log(stack_frame_index, '[ u250c ' .. name)
+ if stack_frame_index == nil then
+ stack_frame_index = 3
+ end
+ -- I'd like to use the unicode character \u{250c} here, but it doesn't work
+ -- in OpenBSD.
+ log(stack_frame_index, '[ u250c ' .. name)
end
function log_end(name, stack_frame_index)
- if stack_frame_index == nil then
- stack_frame_index = 3
- end
- -- I'd like to use the unicode character \u{2518} here, but it doesn't work
- -- in OpenBSD.
- log(stack_frame_index, '] u2518 ' .. name)
+ if stack_frame_index == nil then
+ stack_frame_index = 3
+ end
+ -- I'd like to use the unicode character \u{2518} here, but it doesn't work
+ -- in OpenBSD.
+ log(stack_frame_index, '] u2518 ' .. name)
end
function log_new(name, stack_frame_index)
- if stack_frame_index == nil then
- stack_frame_index = 4
- end
- log_end(name, stack_frame_index)
- log_start(name, stack_frame_index)
+ if stack_frame_index == nil then
+ stack_frame_index = 4
+ end
+ log_end(name, stack_frame_index)
+ log_start(name, stack_frame_index)
end
-- rendering graphical objects within sections/boxes
diff --git a/source_undo.lua b/source_undo.lua
index d91fecd..772e5da 100644
--- a/source_undo.lua
+++ b/source_undo.lua
@@ -84,12 +84,12 @@ end
-- https://stackoverflow.com/questions/640642/how-do-you-copy-a-lua-table-by-value/26367080#26367080
function deepcopy(obj, seen)
if type(obj) ~= 'table' then return obj end
- if seen and seen[obj] then return seen[obj] end
- local s = seen or {}
+ seen = seen or {}
+ if seen[obj] then return seen[obj] end
local result = setmetatable({}, getmetatable(obj))
- s[obj] = result
+ seen[obj] = result
for k,v in pairs(obj) do
- result[deepcopy(k, s)] = deepcopy(v, s)
+ result[deepcopy(k, seen)] = deepcopy(v, seen)
end
return result
end
diff --git a/undo.lua b/undo.lua
index fcfdb6a..4001fef 100644
--- a/undo.lua
+++ b/undo.lua
@@ -1,12 +1,12 @@
-- https://stackoverflow.com/questions/640642/how-do-you-copy-a-lua-table-by-value/26367080#26367080
function deepcopy(obj, seen)
if type(obj) ~= 'table' then return obj end
- if seen and seen[obj] then return seen[obj] end
- local s = seen or {}
+ seen = seen or {}
+ if seen[obj] then return seen[obj] end
local result = setmetatable({}, getmetatable(obj))
- s[obj] = result
+ seen[obj] = result
for k,v in pairs(obj) do
- result[deepcopy(k, s)] = deepcopy(v, s)
+ result[deepcopy(k, seen)] = deepcopy(v, seen)
end
return result
end
|