diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-07-12 17:00:26 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-07-12 17:00:26 -0300 |
| commit | 6dfdb765388da481a7020e44e7cfb253f9751699 (patch) | |
| tree | 95af256d806f52658b6a268a0f6509f4383aa252 | |
| parent | 9a3c51cff1b925e125197e89a4c867c1d99ad1ba (diff) | |
| download | lua-6dfdb765388da481a7020e44e7cfb253f9751699.tar.gz lua-6dfdb765388da481a7020e44e7cfb253f9751699.tar.bz2 lua-6dfdb765388da481a7020e44e7cfb253f9751699.zip | |
C functions don't need to "pushnil" to return nil value (this is
the default value).
| -rw-r--r-- | hash.c | 8 | ||||
| -rw-r--r-- | inout.c | 8 | ||||
| -rw-r--r-- | table.c | 9 |
3 files changed, 4 insertions, 21 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** hash manager for lua | 3 | ** hash manager for lua |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_hash="$Id: hash.c,v 2.29 1996/02/14 18:25:04 roberto Exp roberto $"; | 6 | char *rcs_hash="$Id: hash.c,v 2.30 1996/05/06 14:30:27 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | #include "mem.h" | 9 | #include "mem.h" |
| @@ -283,17 +283,11 @@ Object *lua_hashdefine (Hash *t, Object *ref) | |||
| 283 | static void hashnext (Hash *t, int i) | 283 | static void hashnext (Hash *t, int i) |
| 284 | { | 284 | { |
| 285 | if (i >= nhash(t)) | 285 | if (i >= nhash(t)) |
| 286 | { | ||
| 287 | lua_pushnil(); lua_pushnil(); | ||
| 288 | return; | 286 | return; |
| 289 | } | ||
| 290 | while (tag(ref(node(t,i))) == LUA_T_NIL || tag(val(node(t,i))) == LUA_T_NIL) | 287 | while (tag(ref(node(t,i))) == LUA_T_NIL || tag(val(node(t,i))) == LUA_T_NIL) |
| 291 | { | 288 | { |
| 292 | if (++i >= nhash(t)) | 289 | if (++i >= nhash(t)) |
| 293 | { | ||
| 294 | lua_pushnil(); lua_pushnil(); | ||
| 295 | return; | 290 | return; |
| 296 | } | ||
| 297 | } | 291 | } |
| 298 | luaI_pushobject(ref(node(t,i))); | 292 | luaI_pushobject(ref(node(t,i))); |
| 299 | luaI_pushobject(val(node(t,i))); | 293 | luaI_pushobject(val(node(t,i))); |
| @@ -5,7 +5,7 @@ | |||
| 5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | char *rcs_inout="$Id: inout.c,v 2.36 1996/03/19 22:28:37 roberto Exp roberto $"; | 8 | char *rcs_inout="$Id: inout.c,v 2.37 1996/05/28 21:07:32 roberto Exp $"; |
| 9 | 9 | ||
| 10 | #include <stdio.h> | 10 | #include <stdio.h> |
| 11 | 11 | ||
| @@ -113,8 +113,6 @@ void lua_internaldostring (void) | |||
| 113 | lua_Object obj = lua_getparam (1); | 113 | lua_Object obj = lua_getparam (1); |
| 114 | if (lua_isstring(obj) && !lua_dostring(lua_getstring(obj))) | 114 | if (lua_isstring(obj) && !lua_dostring(lua_getstring(obj))) |
| 115 | lua_pushnumber(1); | 115 | lua_pushnumber(1); |
| 116 | else | ||
| 117 | lua_pushnil(); | ||
| 118 | } | 116 | } |
| 119 | 117 | ||
| 120 | /* | 118 | /* |
| @@ -131,8 +129,6 @@ void lua_internaldofile (void) | |||
| 131 | /* else fname = NULL */ | 129 | /* else fname = NULL */ |
| 132 | if (!lua_dofile(fname)) | 130 | if (!lua_dofile(fname)) |
| 133 | lua_pushnumber(1); | 131 | lua_pushnumber(1); |
| 134 | else | ||
| 135 | lua_pushnil(); | ||
| 136 | } | 132 | } |
| 137 | 133 | ||
| 138 | 134 | ||
| @@ -218,8 +214,6 @@ void lua_obj2number (void) | |||
| 218 | lua_Object o = lua_getparam(1); | 214 | lua_Object o = lua_getparam(1); |
| 219 | if (lua_isnumber(o)) | 215 | if (lua_isnumber(o)) |
| 220 | lua_pushnumber(lua_getnumber(o)); | 216 | lua_pushnumber(lua_getnumber(o)); |
| 221 | else | ||
| 222 | lua_pushnil(); | ||
| 223 | } | 217 | } |
| 224 | 218 | ||
| 225 | 219 | ||
| @@ -3,7 +3,7 @@ | |||
| 3 | ** Module to control static tables | 3 | ** Module to control static tables |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_table="$Id: table.c,v 2.55 1996/05/28 21:07:32 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.56 1996/06/18 21:12:23 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include "mem.h" | 8 | #include "mem.h" |
| 9 | #include "opcode.h" | 9 | #include "opcode.h" |
| @@ -240,12 +240,7 @@ static void lua_nextvar (void) | |||
| 240 | else | 240 | else |
| 241 | next = luaI_findsymbolbyname(lua_getstring(o)) + 1; | 241 | next = luaI_findsymbolbyname(lua_getstring(o)) + 1; |
| 242 | while (next < lua_ntable && s_tag(next) == LUA_T_NIL) next++; | 242 | while (next < lua_ntable && s_tag(next) == LUA_T_NIL) next++; |
| 243 | if (next >= lua_ntable) | 243 | if (next < lua_ntable) |
| 244 | { | ||
| 245 | lua_pushnil(); | ||
| 246 | lua_pushnil(); | ||
| 247 | } | ||
| 248 | else | ||
| 249 | { | 244 | { |
| 250 | lua_pushstring(lua_table[next].varname->str); | 245 | lua_pushstring(lua_table[next].varname->str); |
| 251 | luaI_pushobject(&s_object(next)); | 246 | luaI_pushobject(&s_object(next)); |
