Changeset f365f5006a76043da0acd0ad09ecb7fd98f0d740

Show
Ignore:
Timestamp:
08/15/10 21:40:17 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1281908417 +0000
git-parent:

[a972c1d22e20ad5691ec02d6d77117dc1a59b6a9]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1281908417 +0000
Message:

provide an options set as a second parameter, refs #306

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/lua_noit.c

    raa4df66 rf365f50  
    12111211  int i, cnt, ovector[30]; 
    12121212  size_t inlen; 
     1213  struct pcre_extra e = { 0 }; 
    12131214 
    12141215  pgi = (struct pcre_global_info *)lua_touserdata(L, lua_upvalueindex(1)); 
     
    12181219    return 1; 
    12191220  } 
     1221  if(lua_gettop(L) > 1) { 
     1222    if(!lua_istable(L, 2)) { 
     1223      noitL(noit_error, "pcre match called with second argument that is not a table\n"); 
     1224    } 
     1225    else { 
     1226      lua_pushstring(L, "limit"); 
     1227      lua_gettable(L, -2); 
     1228      if(lua_isnumber(L, -1)) { 
     1229        e.flags |= PCRE_EXTRA_MATCH_LIMIT; 
     1230        e.match_limit = (int)lua_tonumber(L, -1); 
     1231      } 
     1232      lua_pop(L, 1); 
     1233      lua_pushstring(L, "limit_recurse"); 
     1234      lua_gettable(L, -2); 
     1235      if(lua_isnumber(L, -1)) { 
     1236        e.flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION; 
     1237        e.match_limit_recursion = (int)lua_tonumber(L, -1); 
     1238      } 
     1239      lua_pop(L, 1); 
     1240    } 
     1241  } 
    12201242  if (pgi->offset >= inlen) { 
    12211243    lua_pushboolean(L,0); 
    12221244    return 1; 
    12231245  } 
    1224   cnt = pcre_exec(pgi->re, NULL, subject + pgi->offset, 
     1246  cnt = pcre_exec(pgi->re, &e, subject + pgi->offset, 
    12251247                  inlen - pgi->offset, 0, 0, 
    12261248                  ovector, sizeof(ovector)/sizeof(*ovector));