Roberto Ierusalimschy 20 years ago
parent
commit
a72fbf794d
3 changed files with 8 additions and 8 deletions
  1. 3 5
      loslib.c
  2. 3 1
      luaconf.h
  3. 2 2
      lvm.c

+ 3 - 5
loslib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: loslib.c,v 1.2 2004/08/05 19:30:37 roberto Exp roberto $
+** $Id: loslib.c,v 1.3 2004/10/08 18:57:16 roberto Exp roberto $
 ** Standard Operating System library
 ** See Copyright Notice in lua.h
 */
@@ -91,15 +91,13 @@ static int io_clock (lua_State *L) {
 */
 
 static void setfield (lua_State *L, const char *key, int value) {
-  lua_pushstring(L, key);
   lua_pushinteger(L, value);
-  lua_rawset(L, -3);
+  lua_setfield(L, -2, key);
 }
 
 static void setboolfield (lua_State *L, const char *key, int value) {
-  lua_pushstring(L, key);
   lua_pushboolean(L, value);
-  lua_rawset(L, -3);
+  lua_setfield(L, -2, key);
 }
 
 static int getboolfield (lua_State *L, const char *key) {

+ 3 - 1
luaconf.h

@@ -1,5 +1,5 @@
 /*
-** $Id: luaconf.h,v 1.25 2005/01/10 16:31:30 roberto Exp roberto $
+** $Id: luaconf.h,v 1.26 2005/01/10 18:17:39 roberto Exp roberto $
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 */
@@ -237,6 +237,8 @@ __inline int l_lrint (double flt)
 /* function to convert a lua_Number to a string */
 #include <stdio.h>
 #define lua_number2str(s,n)	sprintf((s), LUA_NUMBER_FMT, (n))
+/* maximum size of previous conversion */
+#define MAX_NUMBER2STR	32 /* 16 digits, sign, point and \0  (+ some extra) */
 
 /* function to convert a string to a lua_Number */
 #define lua_str2number(s,p)	strtod((s), (p))

+ 2 - 2
lvm.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 2.21 2005/01/07 20:00:33 roberto Exp roberto $
+** $Id: lvm.c,v 2.22 2005/01/10 18:17:39 roberto Exp roberto $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -47,7 +47,7 @@ int luaV_tostring (lua_State *L, StkId obj) {
   if (!ttisnumber(obj))
     return 0;
   else {
-    char s[32];  /* 16 digits, sign, point and \0  (+ some extra...) */
+    char s[MAX_NUMBER2STR];
     lua_number2str(s, nvalue(obj));
     setsvalue2s(L, obj, luaS_new(L, s));
     return 1;