From db7d99359d62b05a1f6e2c551106b7bf26764889 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Mon, 18 Nov 2013 21:04:19 +0100 Subject: 3.3.0.3 -> 3.3.0.5 --- scripts/functions_tools.lua | 162 ++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 81 deletions(-) (limited to 'scripts/functions_tools.lua') diff --git a/scripts/functions_tools.lua b/scripts/functions_tools.lua index 592e7bc..b83fe58 100644 --- a/scripts/functions_tools.lua +++ b/scripts/functions_tools.lua @@ -1,8 +1,8 @@ -- SLIMax Mgr Lua Script v1.4 -- PART OF SLIMAX Manager pkg -- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved. --- CREDITS: first release - Zappadoc --- updated - Desty 2013-04-26 +-- CREDITS: first release - Zappadoc +-- updated - Desty 2013-04-26 -- =============================== -- left and right functions tools @@ -27,16 +27,16 @@ function AddFuncName(path, func) idx = 0 idx = GetFuncIndex(path, func) if idx < 0 then - print("BAD ERROR occurred!") - return idx --returns errorcode -1 or -2 + print("BAD ERROR occurred!") + return idx --returns errorcode -1 or -2 elseif idx > 0 then - return idx -- OK, return index + return idx -- OK, return index end idx = GetNewFuncIndex(path) if idx < 1 then - print("BAD ERROR occurred!") - return -1 + print("BAD ERROR occurred!") + return -1 end file,err = io.open(path,"r") @@ -48,18 +48,18 @@ function AddFuncName(path, func) local t2 = {} --functionsTable i= 1 for line in file:lines() do - if line == nil then break end - -- Seperate Index from function name - a = string.find(line, '.', 1, true) - if a then - b = string.sub(line, a+1) - c = string.sub(line, 1, a-1) - d=(c + 0) - -- check for EXACT MATCH of the function name - if b == func then isOK = true end - table.insert(t1, d) - t2[d]= line - end + if line == nil then break end + -- Seperate Index from function name + a = string.find(line, '.', 1, true) + if a then + b = string.sub(line, a+1) + c = string.sub(line, 1, a-1) + d=(c + 0) + -- check for EXACT MATCH of the function name + if b == func then isOK = true end + table.insert(t1, d) + t2[d]= line + end end table.insert(t1, idx) t2[idx]= funcStr @@ -67,22 +67,22 @@ function AddFuncName(path, func) file:close() if not isOK then - -- write mode - file, err = io.open(path,"w+") - if err then return -2 end - - --sort IndexTable - table.sort(t1) - - -- Write All functions in order of IndexTable - for i = 1, #t1, 1 do - a = t1[i] - b = t2[a] - --print(" a: "..a.." b: "..b) - file:write(b) - file:write("\n") - end - file:close() + -- write mode + file, err = io.open(path,"w+") + if err then return -2 end + + --sort IndexTable + table.sort(t1) + + -- Write All functions in order of IndexTable + for i = 1, #t1, 1 do + a = t1[i] + b = t2[a] + --print(" a: "..a.." b: "..b) + file:write(b) + file:write("\n") + end + file:close() end return idx @@ -92,7 +92,7 @@ end -- Remove a FunctionName --- Returns 1 if success +-- Returns 1 if success -- Returns -1 if Error Reading File -- Returns -2 if Error writing File @@ -111,21 +111,21 @@ function RemoveFuncName(path, func) t = { } i=1 for line in file:lines() do - if line == nil then break end - - -- Seperate Index from function name - a = string.find(line, '.', 1, true) - -- Empty Lines will be deleted - if a then - b = string.sub(line, a+1) - c = string.sub(line, 1, a-1) - d = (c + 0) - -- check for an EXACT MATCH of the function name - if b ~= func or d < 100 then - t[i] = line - i= i + 1 - end - end + if line == nil then break end + + -- Seperate Index from function name + a = string.find(line, '.', 1, true) + -- Empty Lines will be deleted + if a then + b = string.sub(line, a+1) + c = string.sub(line, 1, a-1) + d = (c + 0) + -- check for an EXACT MATCH of the function name + if b ~= func or d < 100 then + t[i] = line + i= i + 1 + end + end end file:close() @@ -159,18 +159,18 @@ function GetFuncIndex(path, func) if err then return -1 end for line in file:lines() do - if line == nil then break end - -- Seperate Index from function name - a = string.find(line, '.', 1, true) - if a then - b = string.sub( line, a+1) - -- check for an EXACT MATCH of the function name - if b == func then - c = string.sub( line,1, a-1) - d = (c + 0) - return d - end - end + if line == nil then break end + -- Seperate Index from function name + a = string.find(line, '.', 1, true) + if a then + b = string.sub( line, a+1) + -- check for an EXACT MATCH of the function name + if b == func then + c = string.sub( line,1, a-1) + d = (c + 0) + return d + end + end end return 0 @@ -196,18 +196,18 @@ function GetNewFuncIndex(path) if err then return -1 end for line in file:lines() do - if line == nil then break end - -- Seperate Index from function name - a = string.find(line, '.', 1, true) - if a then - b = string.sub( line,1, a-1) - -- string to num conversion - c = (b + 0) - -- store if it's greater - if c > idx then - table.insert(t, c) - end - end + if line == nil then break end + -- Seperate Index from function name + a = string.find(line, '.', 1, true) + if a then + b = string.sub( line,1, a-1) + -- string to num conversion + c = (b + 0) + -- store if it's greater + if c > idx then + table.insert(t, c) + end + end end file:close() @@ -218,14 +218,14 @@ function GetNewFuncIndex(path) idx = 0 local n = #t-1 for i = 1, n, 1 do - if t[i] < (t[i+1]-1) then - if idx == 0 then --added this Iteration - idx = t[i]+1 --to start at the lowest gap - end - end + if t[i] < (t[i+1]-1) then + if idx == 0 then --added this Iteration + idx = t[i]+1 --to start at the lowest gap + end + end end if idx == 0 then - idx = t[n+1]+1 + idx = t[n+1]+1 end return idx -- cgit v1.2.3