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'.
This commit is contained in:
Roberto Ierusalimschy
2019-08-16 14:58:02 -03:00
parent ca13be9af7
commit b96b0b5abb
20 changed files with 176 additions and 154 deletions

View File

@@ -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 */
}
}