mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 07:34:07 +00:00
From Lua 5.2: Return nil for bad position in string.find().
Needs -DLUAJIT_ENABLE_LUA52COMPAT.
This commit is contained in:
parent
b66ab96a62
commit
0d7094f36e
@ -487,10 +487,16 @@ static int str_find_aux(lua_State *L, int find)
|
|||||||
const char *s = luaL_checklstring(L, 1, &l1);
|
const char *s = luaL_checklstring(L, 1, &l1);
|
||||||
const char *p = luaL_checklstring(L, 2, &l2);
|
const char *p = luaL_checklstring(L, 2, &l2);
|
||||||
ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
|
ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1;
|
||||||
if (init < 0)
|
if (init < 0) {
|
||||||
init = 0;
|
init = 0;
|
||||||
else if ((size_t)(init) > l1)
|
} else if ((size_t)(init) > l1) {
|
||||||
|
#if LJ_52
|
||||||
|
setnilV(L->top-1);
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
init = (ptrdiff_t)l1;
|
init = (ptrdiff_t)l1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (find && (lua_toboolean(L, 4) || /* explicit request? */
|
if (find && (lua_toboolean(L, 4) || /* explicit request? */
|
||||||
strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */
|
strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */
|
||||||
/* do a plain search */
|
/* do a plain search */
|
||||||
|
Loading…
Reference in New Issue
Block a user