Changeset de30ea9a40e3c6c47f37331e1c311513058f924d

Show
Ignore:
Timestamp:
01/26/12 16:13:49 (2 years ago)
Author:
Philip Maddox <pmaddox@circonus.com>
git-committer:
Philip Maddox <pmaddox@circonus.com> 1327594429 -0500
git-parent:

[4a0da0e513a734ae484e56cee0fdc99f321e3766]

git-author:
Philip Maddox <pmaddox@circonus.com> 1327594429 -0500
Message:

Moved split from smtp.lua into extras.lua, a new file for extra non-task-specific functions. Added extras.lua to the build.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules-lua/Makefile.in

    r4adb4fb rde30ea9  
    3030LUA=noit/timeval.lua \ 
    3131        noit/HttpClient.lua \ 
     32        noit/extras.lua \ 
    3233        noit/module/varnish.lua \ 
    3334        noit/module/smtp.lua \ 
  • src/modules-lua/noit/module/smtp.lua

    r4a0da0e rde30ea9  
    146146 
    147147    if phase == 'ehlo' and message ~= nil then 
    148       local fields = string.split(message, "\r\n") 
     148      local fields = noit.extras.split(message, "\r\n") 
    149149      if fields ~= nil then 
    150150        local response = "" 
     
    159159            if value ~= nil and value ~= "" then 
    160160              value = value:gsub("^%s*(.-)%s*$", "%1") 
    161               local subfields = string.split(value, "%s+", 1) 
     161              local subfields = noit.extras.split(value, "%s+", 1) 
    162162              if subfields ~= nil and subfields[1] ~= nil then 
    163163                local header = subfields[1] 
     
    243243end 
    244244 
    245 -- from http://www.wellho.net/resources/ex.php4?item=u108/split 
    246 -- modified to split up to 'max' times 
    247 function string:split(delimiter, max) 
    248   local result = { } 
    249   local from  = 1 
    250   local delim_from, delim_to = string.find( self, delimiter, from  ) 
    251   local nb = 0 
    252   if max == nil then 
    253     max = 0 
    254   end 
    255   while delim_from do 
    256     local insert_string = string.sub( self, from , delim_from-1 ) 
    257     nb = nb + 1 
    258     table.insert( result, insert_string ) 
    259     from  = delim_to + 1 
    260     delim_from, delim_to = string.find( self, delimiter, from  ) 
    261     if nb == max then 
    262       break 
    263     end 
    264   end 
    265   local last_res = string.sub (self, from) 
    266   if last_res ~= nil and last_res ~= "" then 
    267     table.insert( result, last_res ) 
    268   end 
    269   return result 
    270 end 
    271  
  • src/modules/lua.c

    r9d3260a rde30ea9  
    892892 
    893893  require(noit.timeval); 
     894  require(noit.extras); 
    894895 
    895896  lua_gc(L, LUA_GCRESTART, 0);