diff options
author | Steven Barth <steven@midlink.org> | 2008-04-02 10:10:32 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-04-02 10:10:32 +0000 |
commit | f2fc9438a21005e7da824f091f8213d46e426cf2 (patch) | |
tree | ad23657df964a98e115051b262242f16b6748aa4 /src/ffluci/util.lua | |
parent | 2f99795df6efd159f5ecd8b52b4846a6bf50b94c (diff) |
* Updated INSTALL file
Diffstat (limited to 'src/ffluci/util.lua')
-rw-r--r-- | src/ffluci/util.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ffluci/util.lua b/src/ffluci/util.lua index 54ee071ef7..a33d141e60 100644 --- a/src/ffluci/util.lua +++ b/src/ffluci/util.lua @@ -145,9 +145,10 @@ function sessionid() end --- Splits a string into an array (Taken from lua-users.org) -function split(str, pat) +-- Splits a string into an array (Adapted from lua-users.org) +function split(str, pat, max) pat = pat or "\n" + max = max or -1 local t = {} local fpat = "(.-)" .. pat @@ -155,10 +156,14 @@ function split(str, pat) local s, e, cap = str:find(fpat, 1) while s do + max = max - 1 if s ~= 1 or cap ~= "" then table.insert(t,cap) end last_end = e+1 + if max == 0 then + break + end s, e, cap = str:find(fpat, last_end) end @@ -170,6 +175,10 @@ function split(str, pat) return t end +-- Removes whitespace from beginning and end of a string +function trim (string) + return string:gsub("^%s*(.-)%s*$", "%1") +end -- Updates given table with new values function update(t, updates) |