commit 4aa9ad6514a98fd4e25015f29e04877e67d9772d
parent d76b1a0eefc51384c75ffc0b847c212ad98f20f8
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Fri, 14 Apr 2000 14:43:58 -0300
functions must return explicit `nil' on failure
Diffstat:
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lbuiltin.c b/lbuiltin.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbuiltin.c,v 1.103 2000/04/13 16:46:43 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.104 2000/04/13 18:08:18 roberto Exp roberto $
** Built-in functions
** See Copyright Notice in lua.h
*/
@@ -223,7 +223,7 @@ void luaB_newtag (lua_State *L) {
void luaB_copytagmethods (lua_State *L) {
lua_pushnumber(L, lua_copytagmethods(L, luaL_check_int(L, 1),
- luaL_check_int(L, 2)));
+ luaL_check_int(L, 2)));
}
void luaB_rawgettable (lua_State *L) {
@@ -296,7 +296,8 @@ void luaB_dostring (lua_State *L) {
lua_error(L, "`dostring' cannot run pre-compiled code");
if (lua_dobuffer(L, s, l, luaL_opt_string(L, 2, s)) == 0)
passresults(L);
- /* else return no value */
+ else
+ lua_pushnil(L);
}
@@ -304,7 +305,8 @@ void luaB_dofile (lua_State *L) {
const char *fname = luaL_opt_string(L, 1, NULL);
if (lua_dofile(L, fname) == 0)
passresults(L);
- /* else return no value */
+ else
+ lua_pushnil(L);
}
diff --git a/ldblib.c b/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.11 2000/03/03 14:58:26 roberto Exp roberto $
+** $Id: ldblib.c,v 1.12 2000/03/30 17:19:48 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -88,6 +88,7 @@ static void getlocal (lua_State *L) {
lua_pushstring(L, lvar.name);
lua_pushobject(L, lvar.value);
}
+ else lua_pushnil(L);
}
@@ -100,6 +101,7 @@ static void setlocal (lua_State *L) {
lvar.value = luaL_nonnullarg(L, 3);
if (lua_setlocal(L, &ar, &lvar))
lua_pushstring(L, lvar.name);
+ else lua_pushnil(L);
}