aboutsummaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-16 14:58:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-16 14:58:02 -0300
commitb96b0b5abbf40cbdbed7952bf35a5a27ddf75928 (patch)
tree5d9d5463cb7d3424833abab20dd87bce1f4b240f /loadlib.c
parentca13be9af784b7288d3a07d9b5bccb329086e885 (diff)
downloadlua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.tar.gz
lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.tar.bz2
lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.zip
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'.
Diffstat (limited to 'loadlib.c')
-rw-r--r--loadlib.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/loadlib.c b/loadlib.c
index 9ef00278..d7a3fb23 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -408,10 +408,10 @@ static int ll_loadlib (lua_State *L) {
408 if (stat == 0) /* no errors? */ 408 if (stat == 0) /* no errors? */
409 return 1; /* return the loaded function */ 409 return 1; /* return the loaded function */
410 else { /* error; error message is on stack top */ 410 else { /* error; error message is on stack top */
411 lua_pushnil(L); 411 luaL_pushfail(L);
412 lua_insert(L, -2); 412 lua_insert(L, -2);
413 lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); 413 lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init");
414 return 3; /* return nil, error message, and where */ 414 return 3; /* return fail, error message, and where */
415 } 415 }
416} 416}
417 417
@@ -505,9 +505,9 @@ static int ll_searchpath (lua_State *L) {
505 luaL_optstring(L, 4, LUA_DIRSEP)); 505 luaL_optstring(L, 4, LUA_DIRSEP));
506 if (f != NULL) return 1; 506 if (f != NULL) return 1;
507 else { /* error message is on top of the stack */ 507 else { /* error message is on top of the stack */
508 lua_pushnil(L); 508 luaL_pushfail(L);
509 lua_insert(L, -2); 509 lua_insert(L, -2);
510 return 2; /* return nil + error message */ 510 return 2; /* return fail + error message */
511 } 511 }
512} 512}
513 513