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'. --- lauxlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 014e7052..5a040ac6 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -249,7 +249,7 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { return 1; } else { - lua_pushnil(L); + luaL_pushfail(L); if (fname) lua_pushfstring(L, "%s: %s", fname, strerror(en)); else @@ -291,10 +291,10 @@ LUALIB_API int luaL_execresult (lua_State *L, int stat) { if (*what == 'e' && stat == 0) /* successful termination? */ lua_pushboolean(L, 1); else - lua_pushnil(L); + luaL_pushfail(L); lua_pushstring(L, what); lua_pushinteger(L, stat); - return 3; /* return true/nil,what,code */ + return 3; /* return true/fail,what,code */ } } -- cgit v1.2.3-55-g6feb