aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.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 /lbaselib.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 'lbaselib.c')
-rw-r--r--lbaselib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lbaselib.c b/lbaselib.c
index c68e6d38..747fd45a 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -106,7 +106,7 @@ static int luaB_tonumber (lua_State *L) {
106 return 1; 106 return 1;
107 } /* else not a number */ 107 } /* else not a number */
108 } /* else not a number */ 108 } /* else not a number */
109 lua_pushnil(L); /* not a number */ 109 luaL_pushfail(L); /* not a number */
110 return 1; 110 return 1;
111} 111}
112 112
@@ -308,9 +308,9 @@ static int load_aux (lua_State *L, int status, int envidx) {
308 return 1; 308 return 1;
309 } 309 }
310 else { /* error (message is on top of the stack) */ 310 else { /* error (message is on top of the stack) */
311 lua_pushnil(L); 311 luaL_pushfail(L);
312 lua_insert(L, -2); /* put before error message */ 312 lua_insert(L, -2); /* put before error message */
313 return 2; /* return nil plus error message */ 313 return 2; /* return fail plus error message */
314 } 314 }
315} 315}
316 316