return (-1);
}
+ else if (G_UNLIKELY (srchlen == 0)) {
+ return 0;
+ }
return rspamd_substring_search_common (in, inlen, srch, srchlen,
rspamd_substring_cmp_func);
init = relative_pos_start (lua_tointeger (L, 3), t->len);
}
+ init --;
+
if (init > t->len) {
return luaL_error (L, "invalid arguments to find: init too large");
}
- goffset pos = rspamd_substring_search (t->start + init - 1,
- t->len - (init - 1),
+ goffset pos = rspamd_substring_search (t->start + init,
+ t->len - init,
pat, patlen);
if (pos == -1) {
{{'foobarfoo', 'rfoo'}, {6, 9}},
{{'foo', 'bar'}, nil},
{{'x', 'xxxx'}, nil},
+ {{'', ''}, {1, 0}},
+ {{'', '_'}, nil},
+ {{'x', ''}, {1, 0}},
}
for _, case in ipairs(cases) do