diff options
author | Ted Trask <ttrask01@yahoo.com> | 2016-08-10 15:48:23 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2016-08-10 15:48:23 +0000 |
commit | ae59e7f08b35ec98f2358b0d9526fbf822a32f01 (patch) | |
tree | ddcda801b80a1dcd3bae7ec25bf158a91af8958e | |
parent | 4dd2e0a349a51321a71415721072e848f2650f2b (diff) | |
download | acf-lib-ae59e7f08b35ec98f2358b0d9526fbf822a32f01.tar.bz2 acf-lib-ae59e7f08b35ec98f2358b0d9526fbf822a32f01.tar.xz |
Remove trailing whitespace
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | date.lua | 46 | ||||
-rw-r--r-- | format.lua | 24 | ||||
-rw-r--r-- | fs.lua | 10 | ||||
-rw-r--r-- | html.lua | 66 | ||||
-rw-r--r-- | processinfo.lua | 8 | ||||
-rw-r--r-- | validator.lua | 20 |
7 files changed, 88 insertions, 88 deletions
@@ -8,7 +8,7 @@ APP_DIST=\ EXTRA_DIST=README Makefile -DISTFILES=$(APP_DIST) $(EXTRA_DIST) +DISTFILES=$(APP_DIST) $(EXTRA_DIST) TAR=tar @@ -1,4 +1,4 @@ ---date and time functions +--date and time functions local mymodule = {} @@ -11,9 +11,9 @@ fs = require("acf.fs") --print(os.date(date.format)) mymodule.formats = "%a %b %d %X %Z %Y" -mymodule.months ={ {"January","Jan"}, - {"February", "Feb"}, - {"March","Mar"}, +mymodule.months ={ {"January","Jan"}, + {"February", "Feb"}, + {"March","Mar"}, {"April", "Apr"}, {"May","May"}, {"June","Jun"}, @@ -25,10 +25,10 @@ mymodule.months ={ {"January","Jan"}, {"December","Dec"} } -mymodule.revmonths = {["january"] = 1, ["jan"] = 1, +mymodule.revmonths = {["january"] = 1, ["jan"] = 1, ["february"] = 2, ["feb"] = 2, - ["march"] = 3, ["mar"] = 3, - ["april"] = 4, ["apr"] = 4, + ["march"] = 3, ["mar"] = 3, + ["april"] = 4, ["apr"] = 4, ["may"] = 5, ["june"] = 6, ["jun"] = 6, ["july"] = 7, ["jul"] = 7, @@ -36,10 +36,10 @@ mymodule.revmonths = {["january"] = 1, ["jan"] = 1, ["september"] = 9, ["sep"] = 9, ["october"] = 10, ["oct"] = 10, ["november"] = 11, ["nov"] = 11, - ["december"] = 12, ["dec"] = 12 + ["december"] = 12, ["dec"] = 12 } -mymodule.dow = { {"Sunday","Sun"}, +mymodule.dow = { {"Sunday","Sun"}, {"Monday","Mon"}, {"Tuesday","Tue"}, {"Wednesday","Wed"}, @@ -47,7 +47,7 @@ mymodule.dow = { {"Sunday","Sun"}, {"Friday","Fri"}, {"Saturday","Sat"} } - + mymodule.revdow = { ["sunday"] = 1, ["sun"] = 2, ["monday"] = 2, ["mon"] = 2, ["tuesday"] = 3, ["tue"] = 3, @@ -57,7 +57,7 @@ mymodule.revdow = { ["sunday"] = 1, ["sun"] = 2, ["saturday"] = 7, ["sat"] =7 } --- + usually denotes right of PM and - means left. It seems that /etc/TZ needs these +-- + usually denotes right of PM and - means left. It seems that /etc/TZ needs these --reversed for alpine/busybox. difference in col 2 and 5 --this list is not full. May need some more added. No Africa or Asia --Abrr TZ,Real Offset, FullName, Location, What would be put in /etc/TZ(busybox needed offset) @@ -182,7 +182,7 @@ mymodule.timezones = { --give me a table --t = { {year=2007,month=1,day=2,hour=2}, {year=2006,month=1,day=5} } ---will return a table sorted by oldest <-> newest +--will return a table sorted by oldest <-> newest --to grab the largest and smallest a,b=g[1],g[table.maxn(g)] function mymodule.date_to_seconds (t) g = {} @@ -202,10 +202,10 @@ function mymodule.seconds_to_date (t) g = {} count = table.maxn(t) for i = 1,count do - g[#g+1] = os.date(mymodule.formats,t[i]) + g[#g+1] = os.date(mymodule.formats,t[i]) end - - return g + + return g end --Wed Nov 28 14:01:23 UTC 2007 @@ -224,7 +224,7 @@ function mymodule.string_to_table (str) year = temp[6] g["year"] = year temp2 = format.string_to_table(temp[4],":") - hour = temp2[1] + hour = temp2[1] g["hour"] = hour min = temp2[2] g["min"] = min @@ -244,8 +244,8 @@ mymodule.t_time = { field_names = {"years","days","hours","minutes","seconds"}, } function mymodule.date_diff (d1, d2) - g = {} - if d2 == nil then d2 = os.time() end + g = {} + if d2 == nil then d2 = os.time() end --first sum of seconds sum = math.abs(os.difftime(d1,d2)) --going to go through and get it smaller with each pass through the table @@ -255,7 +255,7 @@ function mymodule.date_diff (d1, d2) g[mymodule.t_time.field_names[a]] = hold sum = (sum - (hold*b)) end - + return g end @@ -307,7 +307,7 @@ end function mymodule.change_tz ( tz ) --give us something like CET-1, this is busy box offset need to fix. - + tz = string.gsub(tz, "%+", "%%+") tz = string.gsub(tz, "%-", "%%-") tz = "^" .. tz .. "$" @@ -316,14 +316,14 @@ function mymodule.change_tz ( tz ) c = string.match(mymodule.timezones[a][5], tz) if c ~= nil then result[#result +1] = c end end - - if table.maxn(result) == 1 then + + if table.maxn(result) == 1 then fs.write_file("/etc/TZ", result[1]) mess = "Success" else mess = "Too many matches." end - + return mess,mymodule.what_tz() end @@ -65,8 +65,8 @@ function mymodule.parse_lines ( input, comment ) for i,line in ipairs(input) do parse(line) end - end - + end + return lines end @@ -110,8 +110,8 @@ function mymodule.parse_linesandwords ( input, comment ) for i,line in ipairs(input) do parse(line) end - end - + end + return lines end @@ -162,12 +162,12 @@ function mymodule.search_for_lines (input, find) for i,line in ipairs(input) do findfn(line) end - end - + end + return lines end ---string format function to capitalize the beginging of each word. +--string format function to capitalize the beginging of each word. function mymodule.cap_begin_word ( str ) --first need to do the first word local data = string.gsub(str, "^%l", string.upper) @@ -186,7 +186,7 @@ function mymodule.string_to_table ( text, delimiter) local list = {} if text then -- this would result in endless loops - if string.find("", delimiter) then + if string.find("", delimiter) then -- delimiter matches empty string! for i=1,#text do list[#list + 1] = string.sub(text, i, i) @@ -225,7 +225,7 @@ mymodule.expand_bash_syntax_vars = function (str) local rval = ( deref(rvar) or "nil" ) str = string.gsub (str, w, mymodule.escapespecialcharacters(rval)) end - + return (str) end @@ -321,7 +321,7 @@ function mymodule.update_ini_file (file, search_section, search_name, value) if not file or not search_name or search_name == "" then return file, false end - + search_section = search_section or "" local new_conf_file = {} local section = "" @@ -437,7 +437,7 @@ function mymodule.parse_ini_file (file, search_section, search_name) return opts[search_section][search_name] elseif opts and search_section then return opts[search_section] - end + end return opts end @@ -484,7 +484,7 @@ function mymodule.set_ini_section (file, search_section, section_content) if (search_section == section) then l = l .. "\n" .. section_content end - end + end elseif (search_section == section) then l = nil end @@ -127,7 +127,7 @@ function mymodule.read_file ( path ) end end --- Returns an array with the contents of a file, +-- Returns an array with the contents of a file, -- or nil and the error message function mymodule.read_file_as_array ( path ) local file, error = io.open(path or "") @@ -135,14 +135,14 @@ function mymodule.read_file_as_array ( path ) return nil, error end local f = {} - for line in file:lines() do + for line in file:lines() do table.insert ( f , line ) --sometimes you will see it like f[#f+1] = line end file:close() return f end - + -- write a string to a file, will replace file contents function mymodule.write_file ( path, str ) path = path or "" @@ -174,7 +174,7 @@ function mymodule.find_files_as_array ( what, where, follow, t ) where = where or posix.getcwd() what = what or ".*" t = t or {} - + local link if follow and mymodule.is_link(where) then link = posix.readlink(where) @@ -209,7 +209,7 @@ end function mymodule.find ( what, where, follow ) local t = mymodule.find_files_as_array ( what, where, follow ) local idx = 0 - return function () + return function () idx = idx + 1 return t[idx] end @@ -1,4 +1,4 @@ ---[[ lowlevel html functions +--[[ lowlevel html functions Written for Alpine Configuration Framework (ACF) -- see www.alpinelinux.org Copyright (C) 2007 Nathan Angelacos Licensed under the terms of GPL2 @@ -22,7 +22,7 @@ mymodule.cookie.set = function ( name, value, path ) if path == nil then path = "/" end - return (string.format('Set-Cookie: %s=%s; path=%s; %s\n', mymodule.html_escape(tostring(name)), + return (string.format('Set-Cookie: %s=%s; path=%s; %s\n', mymodule.html_escape(tostring(name)), mymodule.html_escape(tostring(value)), mymodule.html_escape(path), mymodule.html_escape(expires))) end @@ -36,7 +36,7 @@ end -- escape unsafe html characters function mymodule.html_escape (text ) - text = text or "" + text = text or "" local str = string.gsub (text, "&", "&" ) str = string.gsub (str, "<", "<" ) str = string.gsub (str, ">", ">" ) @@ -51,19 +51,19 @@ function mymodule.url_encode ( text ) str = string.gsub (str, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") - return str + return str end --- return a name,value pair as a string. +-- return a name,value pair as a string. local nv_pair = function ( name, value) if ( name == nil ) then return ( value or "" ) end - + if ( type(value) == "boolean" ) then value = tostring(value) end - + if ( value == nil ) then return ( "" ) else @@ -81,7 +81,7 @@ local boolean_attribute = function ( name, value ) end --[[ - each of these functions take a table that has an associative array of + each of these functions take a table that has an associative array of the values we might care about: value -- this is the value in the form element, or the selected element @@ -107,14 +107,14 @@ generic_input = function ( field_type, v ) v.name = name return table.concat(ret) end - if ( field_type == nil ) then + if ( field_type == nil ) then return nil end - + local str = string.format ( '<input class="%s %s" type="%s" ', mymodule.html_escape(v.class), mymodule.html_escape(field_type), mymodule.html_escape(field_type) ) for i,k in ipairs ( { - "name", "size", "checked", "maxlength", + "name", "size", "checked", "maxlength", "value", "length", "id", "src", "align", "alt", "contenteditable", "tabindex", "accesskey", "onfocus", "onblur", "title" @@ -123,15 +123,15 @@ generic_input = function ( field_type, v ) end for i,k in ipairs ( { - "readonly", "disabled", + "readonly", "disabled", } ) do str = str .. boolean_attribute ( k, v[k] ) end return ( str .. ">" ) end - - + + --[[ Form functions ]]------------------------------------------------------ -- These expect something like a cfe to work (see mvc.lua) @@ -145,13 +145,13 @@ mymodule.form.longtext = function ( v ) local str = "<textarea" for i,k in ipairs ( { "name", "rows", "cols", - "class", "id", "tabindex", "accesskey", + "class", "id", "tabindex", "accesskey", "onfocus", "onblur", "title" } ) do str = str .. nv_pair ( k, v[k] ) end for i,k in ipairs ( { - "readonly", "disabled", + "readonly", "disabled", } ) do str = str .. boolean_attribute ( k, v[k] ) end @@ -174,7 +174,7 @@ function mymodule.form.submit ( v ) end -function mymodule.form.action (v) +function mymodule.form.action (v) return generic_input ("submit", v) end @@ -196,20 +196,20 @@ end -- v.option is an array of valid options (or an array of value, label) -- NOTE use of value and values (plural) function mymodule.form.select ( v ) - if ( v.name == nil ) then - return nil + if ( v.name == nil ) then + return nil end local str = "<select" for i,k in ipairs ( { - "name", "size", "tabindex", "accesskey", - "onfocus", "onblur", "onchange", "id", + "name", "size", "tabindex", "accesskey", + "onfocus", "onblur", "onchange", "id", "class", "title" } ) do str = str .. nv_pair ( k, v[k] ) end - + for i,k in ipairs ( { - "disabled", "multiple" + "disabled", "multiple" } ) do str = str .. boolean_attribute ( k, v[k] ) end @@ -252,26 +252,26 @@ function mymodule.form.checkbox ( v ) end --- NOTE: VALUE of a form is a table containing the form elements ... +-- NOTE: VALUE of a form is a table containing the form elements ... function mymodule.form.start ( v) - if ( v.action == nil ) then - return nil + if ( v.action == nil ) then + return nil end - + local method = v.method or "get" return ( string.format ( '<form %s%s%s>', - nv_pair ( "class", mymodule.html_escape(v.class) ), - nv_pair ( "method", mymodule.html_escape(v.method) ), + nv_pair ( "class", mymodule.html_escape(v.class) ), + nv_pair ( "method", mymodule.html_escape(v.method) ), nv_pair ( "action", mymodule.html_escape(v.action) ) ) ) end - + function mymodule.form.stop ( ) return ("</form>") end --- For "h1, h2, p," etc +-- For "h1, h2, p," etc -- WARNING - Text is printed verbatim - you may want to -- wrap the text in mymodule.html_escape function mymodule.entity (tag, text, class, id) @@ -282,9 +282,9 @@ function mymodule.entity (tag, text, class, id) nv_pair("id", id), mymodule.html_escape(text), mymodule.html_escape(tag)) ) end - -function mymodule.link ( v ) + +function mymodule.link ( v ) if ( v.value == nil ) then return nil end diff --git a/processinfo.lua b/processinfo.lua index a479cac..75b9672 100644 --- a/processinfo.lua +++ b/processinfo.lua @@ -33,7 +33,7 @@ function mymodule.process_autostart(servicename) end break end - end + end return result,errtxt end @@ -153,7 +153,7 @@ function mymodule.daemon_actions (process) end -- the following methods are available: --- /proc/<pid>/stat the comm field (2nd) field contains name but only up +-- /proc/<pid>/stat the comm field (2nd) field contains name but only up -- to 15 chars. does not resolve links -- -- /proc/<pid>/cmdline argv[0] contains the command. However if it is a script @@ -184,7 +184,7 @@ local function is_stat(path, name) p = string.gsub(p, "%).*", "") f:close() end - if p ~= nil then + if p ~= nil then if string.len(name) <= 15 and p == name then return true end @@ -199,7 +199,7 @@ local function is_cmdline(path, name) end local line = f:read() f:close() - if line == nil then + if line == nil then return false end local arg0 = string.gsub(line, string.char(0)..".*", "") diff --git a/validator.lua b/validator.lua index 4a7adb7..4f3db7d 100644 --- a/validator.lua +++ b/validator.lua @@ -37,7 +37,7 @@ function mymodule.is_ipv4(ipv4) -- %d+ one or more digits -- $ end of string nums = {ipv4:match ("^(%d+)%.(%d+)%.(%d+)%.(%d+)$")} - + -- check if all nums are filled if ( nums[1] == nil or nums[2] == nil or @@ -55,7 +55,7 @@ function mymodule.is_ipv4(ipv4) -- at least one number is too big return false, "Invalid Value" end - + return true end @@ -65,7 +65,7 @@ end function mymodule.is_partial_ipv4(ipv4) local retval = false; local nums = {}; - + -- Check to see if any invalid characters if not ipv4 or not ipv4:match("^[%d%.]+$") then return false, "Invalid Format" @@ -100,8 +100,8 @@ function mymodule.is_mac(mac) -- check for valid characters local step = 1; while (step <= 17) do - if (string.sub(tmpmac, step, step) ~= ":") and - (string.sub(tmpmac, step, step) < "0" or string.sub(tmpmac, step, step) > "9") and + if (string.sub(tmpmac, step, step) ~= ":") and + (string.sub(tmpmac, step, step) < "0" or string.sub(tmpmac, step, step) > "9") and (string.sub(tmpmac, step, step) < "A" or string.sub(tmpmac, step, step) > "F") then -- we have found an invalid character! return false, "Invalid Chars" @@ -122,7 +122,7 @@ function mymodule.is_mac(mac) step = 1; while (step <= 17) do if ((string.sub(tmpmac, step, step) == ":") and - ((step ~= 3) and (step ~= 6) and (step ~= 9) and (step ~= 12) and + ((step ~= 3) and (step ~= 6) and (step ~= 9) and (step ~= 12) and (step ~= 15))) then return false, "Invalid Value" end @@ -133,7 +133,7 @@ function mymodule.is_mac(mac) end -- --- This function checks if the given input +-- This function checks if the given input -- consists of number-chars between 0..9 only -- and eventually a leading '-' -- @@ -147,15 +147,15 @@ end -- --- This function checks if the given input +-- This function checks if the given input -- consists of number-chars between 0..9 only -- and if it is within a given range. -- function mymodule.is_integer_in_range(numstr, min, max) - return mymodule.is_integer(numstr) + return mymodule.is_integer(numstr) and tonumber(numstr) >= min and tonumber(numstr) <= max - + end -- |