Skip to content

Commit 25128b5

Browse files
committed
For the cat.
1 parent 31effcb commit 25128b5

File tree

4 files changed

+3
-48
lines changed

4 files changed

+3
-48
lines changed

resources/irc/logs.html

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,9 @@
44
</head>
55
<body>
66
<*
7-
-- Compatibility: Lua-5.1
8-
function Split(str, pat)
9-
local t = {} -- NOTE: use {n = 0} in Lua-5.0
10-
local fpat = "(.-)" .. pat
11-
local last_end = 1
12-
local s, e, cap = str:find(fpat, 1)
13-
while s do
14-
if s ~= 1 or cap ~= "" then
15-
table.insert(t,cap)
16-
end
17-
last_end = e+1
18-
s, e, cap = str:find(fpat, last_end)
19-
end
20-
if last_end <= #str then
21-
cap = str:sub(last_end)
22-
table.insert(t, cap)
23-
end
24-
return t
25-
end
26-
277
local file = fileOpen(":irc/irc.log",true)
288

29-
for i,line in pairs (Split(tostring(fileRead(file,fileGetSize(file))),"\n")) do
9+
for i,line in pairs (split(tostring(fileRead(file,fileGetSize(file))),10)) do
3010
httpWrite(tostring(line)..'<br>')
3111
end
3212

resources/irc/scripts/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ addEventHandler("onSockData",root,
118118
function (socket,data)
119119
for server,info in pairs (servers) do
120120
if info[1] == socket then
121-
for i,line in ipairs (Split(data,"\n")) do
121+
for i,line in ipairs (split(data,10)) do
122122
if line ~= "" then
123123
triggerEvent("onIRCRaw",server,line)
124124
end

resources/irc/scripts/handling.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ addEventHandler("onSockData",root,
2929
function (socket,data)
3030
for server,info in pairs (servers) do
3131
if info[1] == socket then
32-
for i,line in ipairs (Split(data,"\n")) do
32+
for i,line in ipairs (split(data,10)) do
3333
if line ~= "" then
3434
triggerEvent("onIRCRaw",server,line)
3535
end

resources/irc/scripts/utility.lua

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,6 @@
99
------------------------------------
1010
-- Utility
1111
------------------------------------
12-
-- function copied from: http://lua-users.org/wiki/StringRecipes
13-
function Split(str, delim, maxNb)
14-
-- Eliminate bad cases...
15-
if string.find(str, delim) == nil then
16-
return { str }
17-
end
18-
if maxNb == nil or maxNb < 1 then
19-
maxNb = 0 -- No limit
20-
end
21-
local result = {}
22-
local pat = "(.-)" .. delim .. "()"
23-
local nb = 0
24-
local lastPos
25-
for part, pos in string.gfind(str, pat) do
26-
nb = nb + 1
27-
result[nb] = part
28-
lastPos = pos
29-
if nb == maxNb then break end
30-
end
31-
-- Handle the last field
32-
if nb ~= maxNb then
33-
result[nb + 1] = string.sub(str, lastPos)
34-
end
35-
return result
36-
end
3712

3813
function getAdminMessage (time,author)
3914
outputServerLog("Time: "..time..", Author: "..author)

0 commit comments

Comments
 (0)