Roberto Ierusalimschy 19 년 전
부모
커밋
baffc37f5c
3개의 변경된 파일9개의 추가작업 그리고 8개의 파일을 삭제
  1. 2 2
      lbaselib.c
  2. 5 4
      liolib.c
  3. 2 2
      ltable.c

+ 2 - 2
lbaselib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lbaselib.c,v 1.187 2005/12/27 17:10:11 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.188 2005/12/29 15:32:11 roberto Exp roberto $
 ** Basic library
 ** Basic library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -201,7 +201,7 @@ static int luaB_collectgarbage (lua_State *L) {
   switch (optsnum[o]) {
   switch (optsnum[o]) {
     case LUA_GCCOUNT: {
     case LUA_GCCOUNT: {
       int b = lua_gc(L, LUA_GCCOUNTB, 0);
       int b = lua_gc(L, LUA_GCCOUNTB, 0);
-      lua_pushnumber(L, ((lua_Number)res*1024 + b)/1024);
+      lua_pushnumber(L, res + ((lua_Number)b/1024));
       return 1;
       return 1;
     }
     }
     case LUA_GCSTEP: {
     case LUA_GCSTEP: {

+ 5 - 4
liolib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: liolib.c,v 2.69 2005/10/19 13:05:11 roberto Exp roberto $
+** $Id: liolib.c,v 2.70 2005/12/29 15:32:11 roberto Exp roberto $
 ** Standard I/O (and system) library
 ** Standard I/O (and system) library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -28,6 +28,7 @@ static const char *const fnames[] = {"input", "output"};
 
 
 
 
 static int pushresult (lua_State *L, int i, const char *filename) {
 static int pushresult (lua_State *L, int i, const char *filename) {
+  int en = errno;  /* calls to Lua API may change this value */
   if (i) {
   if (i) {
     lua_pushboolean(L, 1);
     lua_pushboolean(L, 1);
     return 1;
     return 1;
@@ -35,10 +36,10 @@ static int pushresult (lua_State *L, int i, const char *filename) {
   else {
   else {
     lua_pushnil(L);
     lua_pushnil(L);
     if (filename)
     if (filename)
-      lua_pushfstring(L, "%s: %s", filename, strerror(errno));
+      lua_pushfstring(L, "%s: %s", filename, strerror(en));
     else
     else
-      lua_pushfstring(L, "%s", strerror(errno));
-    lua_pushinteger(L, errno);
+      lua_pushfstring(L, "%s", strerror(en));
+    lua_pushinteger(L, en);
     return 3;
     return 3;
   }
   }
 }
 }

+ 2 - 2
ltable.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: ltable.c,v 2.30 2006/01/10 12:51:53 roberto Exp roberto $
+** $Id: ltable.c,v 2.31 2006/01/10 13:13:06 roberto Exp roberto $
 ** Lua tables (hash)
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -122,7 +122,7 @@ static int arrayindex (const TValue *key) {
     lua_Number n = nvalue(key);
     lua_Number n = nvalue(key);
     int k;
     int k;
     lua_number2int(k, n);
     lua_number2int(k, n);
-    if (luai_numeq(cast_num(k), nvalue(key)))
+    if (luai_numeq(cast_num(k), n))
       return k;
       return k;
   }
   }
   return -1;  /* `key' did not match some condition */
   return -1;  /* `key' did not match some condition */