aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-19 17:49:22 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-19 17:49:22 -0200
commitd49e4dd752928c5869a75c444b503060b2634968 (patch)
tree4e13ace68c6940dd12efae1014b18237e1004caa
parent981fddea022b6cad7768223353b4e7386080c271 (diff)
downloadlua-d49e4dd752928c5869a75c444b503060b2634968.tar.gz
lua-d49e4dd752928c5869a75c444b503060b2634968.tar.bz2
lua-d49e4dd752928c5869a75c444b503060b2634968.zip
MAX_WORD should not be bigger than MAX_INT
-rw-r--r--bugs11
-rw-r--r--lbuiltin.c6
-rw-r--r--lgc.c4
-rw-r--r--lobject.h13
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 @@
2Tue Dec 2 10:45:48 EDT 1997 2Tue Dec 2 10:45:48 EDT 1997
3>> BUG: "lastline" was not reset on function entry, so debug information 3>> BUG: "lastline" was not reset on function entry, so debug information
4>> started only in the 2nd line of a function. 4>> started only in the 2nd line of a function.
5
6
7--- Version 3.1 alpha
8
9** lua.c
10Thu Jan 15 14:34:58 EDT 1998
11>> must include "stdlib.h" (for "exit()").
12
13** lbuiltin.c / lobject.h
14Thu Jan 15 14:34:58 EDT 1998
15>> 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 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.21 1998/01/02 17:46:32 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.22 1998/01/07 16:26:48 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -263,7 +263,7 @@ static int getnarg (lua_Object table)
263 lua_Object temp; 263 lua_Object temp;
264 /* temp = table.n */ 264 /* temp = table.n */
265 lua_pushobject(table); lua_pushstring("n"); temp = lua_rawgettable(); 265 lua_pushobject(table); lua_pushstring("n"); temp = lua_rawgettable();
266 return (lua_isnumber(temp) ? lua_getnumber(temp) : MAX_WORD); 266 return (lua_isnumber(temp) ? lua_getnumber(temp) : MAX_INT);
267} 267}
268 268
269static void luaI_call (void) 269static void luaI_call (void)
@@ -283,7 +283,7 @@ static void luaI_call (void)
283 lua_Object temp; 283 lua_Object temp;
284 /* temp = arg[i+1] */ 284 /* temp = arg[i+1] */
285 lua_pushobject(arg); lua_pushnumber(i+1); temp = lua_rawgettable(); 285 lua_pushobject(arg); lua_pushnumber(i+1); temp = lua_rawgettable();
286 if (narg == MAX_WORD && lua_isnil(temp)) 286 if (narg == MAX_INT && lua_isnil(temp))
287 break; 287 break;
288 lua_pushobject(temp); 288 lua_pushobject(temp);
289 } 289 }
diff --git a/lgc.c b/lgc.c
index 38cc50d3..21550bb7 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.14 1997/12/17 20:48:58 roberto Exp roberto $ 2** $Id: lgc.c,v 1.15 1998/01/09 14:44:55 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -41,7 +41,7 @@ int luaC_ref (TObject *o, int lock)
41 /* no more empty spaces */ { 41 /* no more empty spaces */ {
42 int oldSize = L->refSize; 42 int oldSize = L->refSize;
43 L->refSize = luaM_growvector(&L->refArray, L->refSize, struct ref, 43 L->refSize = luaM_growvector(&L->refArray, L->refSize, struct ref,
44 refEM, MAX_WORD); 44 refEM, MAX_INT);
45 for (ref=oldSize; ref<L->refSize; ref++) 45 for (ref=oldSize; ref<L->refSize; ref++)
46 L->refArray[ref].status = FREE; 46 L->refArray[ref].status = FREE;
47 ref = oldSize; 47 ref = oldSize;
diff --git a/lobject.h b/lobject.h
index bc9be0ba..9e1f94d5 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.15 1998/01/13 13:27:25 roberto Exp $ 2** $Id: lobject.h,v 1.15 1998/01/14 13:48:28 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -25,8 +25,15 @@
25#define Byte lua_Byte /* some systems have Byte as a predefined type */ 25#define Byte lua_Byte /* some systems have Byte as a predefined type */
26typedef unsigned char Byte; /* unsigned 8 bits */ 26typedef unsigned char Byte; /* unsigned 8 bits */
27 27
28#define MAX_WORD (65534U) /* maximum value of a word (-2 for safety) */ 28
29#define MAX_INT (INT_MAX-2) /* maximum value of a int (-2 for safety) */ 29#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */
30
31/* maximum value of a word of 2 bytes (-2 for safety); must fit in an "int" */
32#if MAX_INT < 65534
33#define MAX_WORD MAX_INT
34#else
35#define MAX_WORD 65534
36#endif
30 37
31typedef unsigned int IntPoint; /* unsigned with same size as a pointer (for hashing) */ 38typedef unsigned int IntPoint; /* unsigned with same size as a pointer (for hashing) */
32 39