2
0
Эх сурвалжийг харах

C functions don't need to "pushnil" to return nil value (this is
the default value).

Roberto Ierusalimschy 29 жил өмнө
parent
commit
6dfdb76538
3 өөрчлөгдсөн 4 нэмэгдсэн , 21 устгасан
  1. 1 7
      hash.c
  2. 1 7
      inout.c
  3. 2 7
      table.c

+ 1 - 7
hash.c

@@ -3,7 +3,7 @@
 ** hash manager for lua
 */
 
-char *rcs_hash="$Id: hash.c,v 2.29 1996/02/14 18:25:04 roberto Exp roberto $";
+char *rcs_hash="$Id: hash.c,v 2.30 1996/05/06 14:30:27 roberto Exp roberto $";
 
 
 #include "mem.h"
@@ -283,17 +283,11 @@ Object *lua_hashdefine (Hash *t, Object *ref)
 static void hashnext (Hash *t, int i)
 {
  if (i >= nhash(t))
- {
-  lua_pushnil(); lua_pushnil();
   return;
- }
  while (tag(ref(node(t,i))) == LUA_T_NIL || tag(val(node(t,i))) == LUA_T_NIL)
  {
   if (++i >= nhash(t))
-  {
-   lua_pushnil(); lua_pushnil();
    return;
-  }
  }
  luaI_pushobject(ref(node(t,i)));
  luaI_pushobject(val(node(t,i)));

+ 1 - 7
inout.c

@@ -5,7 +5,7 @@
 ** Also provides some predefined lua functions.
 */
 
-char *rcs_inout="$Id: inout.c,v 2.36 1996/03/19 22:28:37 roberto Exp roberto $";
+char *rcs_inout="$Id: inout.c,v 2.37 1996/05/28 21:07:32 roberto Exp $";
 
 #include <stdio.h>
 
@@ -113,8 +113,6 @@ void lua_internaldostring (void)
  lua_Object obj = lua_getparam (1);
  if (lua_isstring(obj) && !lua_dostring(lua_getstring(obj)))
   lua_pushnumber(1);
- else
-  lua_pushnil();
 }
 
 /*
@@ -131,8 +129,6 @@ void lua_internaldofile (void)
  /* else fname = NULL */
  if (!lua_dofile(fname))
   lua_pushnumber(1);
- else
-  lua_pushnil();
 }
  
 
@@ -218,8 +214,6 @@ void lua_obj2number (void)
   lua_Object o = lua_getparam(1);
   if (lua_isnumber(o))
     lua_pushnumber(lua_getnumber(o));
-  else
-    lua_pushnil();
 }
 
 

+ 2 - 7
table.c

@@ -3,7 +3,7 @@
 ** Module to control static tables
 */
 
-char *rcs_table="$Id: table.c,v 2.55 1996/05/28 21:07:32 roberto Exp roberto $";
+char *rcs_table="$Id: table.c,v 2.56 1996/06/18 21:12:23 roberto Exp roberto $";
 
 #include "mem.h"
 #include "opcode.h"
@@ -240,12 +240,7 @@ static void lua_nextvar (void)
  else
    next = luaI_findsymbolbyname(lua_getstring(o)) + 1;
  while (next < lua_ntable && s_tag(next) == LUA_T_NIL) next++;
- if (next >= lua_ntable)
- {
-  lua_pushnil();
-  lua_pushnil();
- }
- else
+ if (next < lua_ntable)
  {
   lua_pushstring(lua_table[next].varname->str);
   luaI_pushobject(&s_object(next));