1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-15 23:35:34 +00:00

[lua] foreachi replaced by ipairs. Refs #46

This commit is contained in:
Witold Filipczyk 2020-05-22 20:59:06 +02:00
parent 9e71d7f3c8
commit b3ae1caf8b
2 changed files with 26 additions and 27 deletions

View File

@ -69,10 +69,10 @@ end
function bm_sort_bookmarks ()
if not bm_auto_sort_bookmarks then return end
table.sort (bm_bookmarks, function (a, b) return a.category < b.category end)
foreachi (bm_bookmarks,
function (i, v)
table.sort (v, function (a, b) return a.name < b. name end)
end)
for i,v in ipairs(bm_bookmarks)
do
table.sort (v, function (a, b) return a.name < b. name end)
end
end

View File

@ -81,48 +81,47 @@ pre_format_html_hooks = {n=0}
function pre_format_html_hook (url, html)
local changed = nil
table.foreachi(pre_format_html_hooks,
function (i, fn)
local new,stop = fn(url,html)
for i,fn in ipairs(pre_format_html_hooks)
do
local new,stop = fn(url,html)
if new then html=new changed=1 end
return stop
end)
if new then html=new changed=1 end
end
return changed and html
return changed and html
end
goto_url_hooks = {n=0}
function goto_url_hook (url, current_url)
table.foreachi(goto_url_hooks,
function (i, fn)
local new,stop = fn(url, current_url)
for i,fn in ipairs(goto_url_hooks)
do
local new,stop = fn(url, current_url)
url = new
url = new
end
return stop
end)
return url
return url
end
follow_url_hooks = {n=0}
function follow_url_hook (url)
table.foreachi(follow_url_hooks,
function (i, fn)
local new,stop = fn(url)
for i,fn in ipairs(follow_url_hooks)
do
local new,stop = fn(url)
url = new
url = new
return stop
end)
end
return url
return url
end
quit_hooks = {n=0}
function quit_hook (url, html)
table.foreachi(quit_hooks, function (i, fn) return fn() end)
for i, fn in ipairs(quit_hooks)
do
fn()
end
end
----------------------------------------------------------------------