From b96b0b5abbf40cbdbed7952bf35a5a27ddf75928 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 16 Aug 2019 14:58:02 -0300 Subject: Added macro 'luaL_pushfail' The macro 'luaL_pushfail' documents all places in the standard libraries that return nil to signal some kind of failure. It is defined as 'lua_pushnil'. The manual also got a notation (@fail) to document those returns. The tests were changed to be agnostic regarding whether 'fail' is 'nil' or 'false'. --- lstrlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lstrlib.c') diff --git a/lstrlib.c b/lstrlib.c index 8c9e1a83..7f4a0184 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -744,7 +744,7 @@ static int str_find_aux (lua_State *L, int find) { const char *p = luaL_checklstring(L, 2, &lp); size_t init = posrelatI(luaL_optinteger(L, 3, 1), ls) - 1; if (init > ls) { /* start after string's end? */ - lua_pushnil(L); /* cannot find anything */ + luaL_pushfail(L); /* cannot find anything */ return 1; } /* explicit request or no special characters? */ @@ -779,7 +779,7 @@ static int str_find_aux (lua_State *L, int find) { } } while (s1++ < ms.src_end && !anchor); } - lua_pushnil(L); /* not found */ + luaL_pushfail(L); /* not found */ return 1; } -- cgit v1.2.3-55-g6feb