diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-04-14 14:44:20 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-04-14 14:44:20 -0300 |
commit | 4aa9ad6514a98fd4e25015f29e04877e67d9772d (patch) | |
tree | 1c4f47aef895ef6abf837e190204eb353b18be11 | |
parent | d76b1a0eefc51384c75ffc0b847c212ad98f20f8 (diff) | |
download | lua-4aa9ad6514a98fd4e25015f29e04877e67d9772d.tar.gz lua-4aa9ad6514a98fd4e25015f29e04877e67d9772d.tar.bz2 lua-4aa9ad6514a98fd4e25015f29e04877e67d9772d.zip |
functions must return explicit `nil' on failure
-rw-r--r-- | lbuiltin.c | 10 | ||||
-rw-r--r-- | ldblib.c | 4 |
2 files changed, 9 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.c,v 1.103 2000/04/13 16:46:43 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.104 2000/04/13 18:08:18 roberto Exp roberto $ |
3 | ** Built-in functions | 3 | ** Built-in functions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -223,7 +223,7 @@ void luaB_newtag (lua_State *L) { | |||
223 | 223 | ||
224 | void luaB_copytagmethods (lua_State *L) { | 224 | void luaB_copytagmethods (lua_State *L) { |
225 | lua_pushnumber(L, lua_copytagmethods(L, luaL_check_int(L, 1), | 225 | lua_pushnumber(L, lua_copytagmethods(L, luaL_check_int(L, 1), |
226 | luaL_check_int(L, 2))); | 226 | luaL_check_int(L, 2))); |
227 | } | 227 | } |
228 | 228 | ||
229 | void luaB_rawgettable (lua_State *L) { | 229 | void luaB_rawgettable (lua_State *L) { |
@@ -296,7 +296,8 @@ void luaB_dostring (lua_State *L) { | |||
296 | lua_error(L, "`dostring' cannot run pre-compiled code"); | 296 | lua_error(L, "`dostring' cannot run pre-compiled code"); |
297 | if (lua_dobuffer(L, s, l, luaL_opt_string(L, 2, s)) == 0) | 297 | if (lua_dobuffer(L, s, l, luaL_opt_string(L, 2, s)) == 0) |
298 | passresults(L); | 298 | passresults(L); |
299 | /* else return no value */ | 299 | else |
300 | lua_pushnil(L); | ||
300 | } | 301 | } |
301 | 302 | ||
302 | 303 | ||
@@ -304,7 +305,8 @@ void luaB_dofile (lua_State *L) { | |||
304 | const char *fname = luaL_opt_string(L, 1, NULL); | 305 | const char *fname = luaL_opt_string(L, 1, NULL); |
305 | if (lua_dofile(L, fname) == 0) | 306 | if (lua_dofile(L, fname) == 0) |
306 | passresults(L); | 307 | passresults(L); |
307 | /* else return no value */ | 308 | else |
309 | lua_pushnil(L); | ||
308 | } | 310 | } |
309 | 311 | ||
310 | 312 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.11 2000/03/03 14:58:26 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.12 2000/03/30 17:19:48 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -88,6 +88,7 @@ static void getlocal (lua_State *L) { | |||
88 | lua_pushstring(L, lvar.name); | 88 | lua_pushstring(L, lvar.name); |
89 | lua_pushobject(L, lvar.value); | 89 | lua_pushobject(L, lvar.value); |
90 | } | 90 | } |
91 | else lua_pushnil(L); | ||
91 | } | 92 | } |
92 | 93 | ||
93 | 94 | ||
@@ -100,6 +101,7 @@ static void setlocal (lua_State *L) { | |||
100 | lvar.value = luaL_nonnullarg(L, 3); | 101 | lvar.value = luaL_nonnullarg(L, 3); |
101 | if (lua_setlocal(L, &ar, &lvar)) | 102 | if (lua_setlocal(L, &ar, &lvar)) |
102 | lua_pushstring(L, lvar.name); | 103 | lua_pushstring(L, lvar.name); |
104 | else lua_pushnil(L); | ||
103 | } | 105 | } |
104 | 106 | ||
105 | 107 | ||