commit d49e4dd752928c5869a75c444b503060b2634968
parent 981fddea022b6cad7768223353b4e7386080c271
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 19 Jan 1998 17:49:01 -0200
MAX_WORD should not be bigger than MAX_INT
Diffstat:
4 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/bugs b/bugs
@@ -2,3 +2,14 @@
Tue Dec 2 10:45:48 EDT 1997
>> BUG: "lastline" was not reset on function entry, so debug information
>> started only in the 2nd line of a function.
+
+
+--- Version 3.1 alpha
+
+** lua.c
+Thu Jan 15 14:34:58 EDT 1998
+>> must include "stdlib.h" (for "exit()").
+
+** lbuiltin.c / lobject.h
+Thu Jan 15 14:34:58 EDT 1998
+>> MAX_WORD may be bigger than MAX_INT
diff --git a/lbuiltin.c b/lbuiltin.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbuiltin.c,v 1.21 1998/01/02 17:46:32 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.22 1998/01/07 16:26:48 roberto Exp roberto $
** Built-in functions
** See Copyright Notice in lua.h
*/
@@ -263,7 +263,7 @@ static int getnarg (lua_Object table)
lua_Object temp;
/* temp = table.n */
lua_pushobject(table); lua_pushstring("n"); temp = lua_rawgettable();
- return (lua_isnumber(temp) ? lua_getnumber(temp) : MAX_WORD);
+ return (lua_isnumber(temp) ? lua_getnumber(temp) : MAX_INT);
}
static void luaI_call (void)
@@ -283,7 +283,7 @@ static void luaI_call (void)
lua_Object temp;
/* temp = arg[i+1] */
lua_pushobject(arg); lua_pushnumber(i+1); temp = lua_rawgettable();
- if (narg == MAX_WORD && lua_isnil(temp))
+ if (narg == MAX_INT && lua_isnil(temp))
break;
lua_pushobject(temp);
}
diff --git a/lgc.c b/lgc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 1.14 1997/12/17 20:48:58 roberto Exp roberto $
+** $Id: lgc.c,v 1.15 1998/01/09 14:44:55 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -41,7 +41,7 @@ int luaC_ref (TObject *o, int lock)
/* no more empty spaces */ {
int oldSize = L->refSize;
L->refSize = luaM_growvector(&L->refArray, L->refSize, struct ref,
- refEM, MAX_WORD);
+ refEM, MAX_INT);
for (ref=oldSize; ref<L->refSize; ref++)
L->refArray[ref].status = FREE;
ref = oldSize;
diff --git a/lobject.h b/lobject.h
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 1.15 1998/01/13 13:27:25 roberto Exp $
+** $Id: lobject.h,v 1.15 1998/01/14 13:48:28 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -25,8 +25,15 @@
#define Byte lua_Byte /* some systems have Byte as a predefined type */
typedef unsigned char Byte; /* unsigned 8 bits */
-#define MAX_WORD (65534U) /* maximum value of a word (-2 for safety) */
-#define MAX_INT (INT_MAX-2) /* maximum value of a int (-2 for safety) */
+
+#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
+
+/* maximum value of a word of 2 bytes (-2 for safety); must fit in an "int" */
+#if MAX_INT < 65534
+#define MAX_WORD MAX_INT
+#else
+#define MAX_WORD 65534
+#endif
typedef unsigned int IntPoint; /* unsigned with same size as a pointer (for hashing) */