commit a72fbf794d263d6c2e99e06f4efbe7a75d532a8c
parent 8ddfe3df29dfff3ac9f75972150bd263cc4e3487
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 10 Jan 2005 17:16:07 -0200
detail
Diffstat:
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/loslib.c b/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) {
diff --git a/luaconf.h b/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))
diff --git a/lvm.c b/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;