-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathutil.lua
64 lines (55 loc) · 1.21 KB
/
util.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
return function(utf8)
function utf8.util.copy(obj, deep)
if type(obj) == 'table' then
local result = {}
if deep then
for k,v in pairs(obj) do
result[k] = utf8.util.copy(v, true)
end
else
for k,v in pairs(obj) do
result[k] = v
end
end
return result
else
return obj
end
end
local function dump(val, tab)
tab = tab or ''
if type(val) == 'table' then
utf8.config.logger('{\n')
for k,v in pairs(val) do
utf8.config.logger(tab .. tostring(k) .. " = ")
dump(v, tab .. '\t')
utf8.config.logger("\n")
end
utf8.config.logger(tab .. '}\n')
else
utf8.config.logger(tostring(val))
end
end
function utf8.util.debug(...)
local t = {...}
for _, v in ipairs(t) do
if type(v) == "table" and not (getmetatable(v) or {}).__tostring then
dump(v, '\t')
else
utf8.config.logger(tostring(v), " ")
end
end
utf8.config.logger('\n')
end
function utf8.debug(...)
if utf8.config.debug then
utf8.config.debug(...)
end
end
function utf8.util.next(str, bs)
local nbs1 = utf8.next(str, bs)
local nbs2 = utf8.next(str, nbs1)
return utf8.raw.sub(str, nbs1, nbs2 - 1), nbs1
end
return utf8.util
end