From d49e4dd752928c5869a75c444b503060b2634968 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 19 Jan 1998 17:49:22 -0200 Subject: [PATCH] MAX_WORD should not be bigger than MAX_INT --- bugs | 11 +++++++++++ lbuiltin.c | 6 +++--- lgc.c | 4 ++-- lobject.h | 13 ++++++++++--- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/bugs b/bugs index e14fe4c1..c3e40c4d 100644 --- 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 index 2a5c30d1..13ea4fa1 100644 --- 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 index 38cc50d3..21550bb7 100644 --- 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; refrefSize; ref++) L->refArray[ref].status = FREE; ref = oldSize; diff --git a/lobject.h b/lobject.h index bc9be0ba..9e1f94d5 100644 --- 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) */