USHRT_MAX may not fit in a (16-bit) int

This commit is contained in:
Roberto Ierusalimschy 2005-03-07 13:58:27 -03:00
parent 49f90ffdeb
commit b6a7983b65
2 changed files with 4 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: lparser.c,v 2.12 2005/01/04 15:55:12 roberto Exp roberto $
** $Id: lparser.c,v 2.13 2005/01/05 18:20:51 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@ -167,7 +167,7 @@ static int registerlocalvar (LexState *ls, TString *varname) {
Proto *f = fs->f;
int oldsize = f->sizelocvars;
luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
LocVar, USHRT_MAX, "too many local variables");
LocVar, SHRT_MAX, "too many local variables");
while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL;
f->locvars[fs->nlocvars].varname = varname;
luaC_objbarrier(ls->L, f, varname);

View File

@ -1,5 +1,5 @@
/*
** $Id: lparser.h,v 1.50 2003/08/25 19:51:54 roberto Exp roberto $
** $Id: lparser.h,v 1.51 2004/05/31 18:51:50 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@ -65,7 +65,7 @@ typedef struct FuncState {
int freereg; /* first free register */
int nk; /* number of elements in `k' */
int np; /* number of elements in `p' */
int nlocvars; /* number of elements in `locvars' */
short nlocvars; /* number of elements in `locvars' */
lu_byte nactvar; /* number of active local variables */
upvaldesc upvalues[MAXUPVALUES]; /* upvalues */
unsigned short actvar[MAXVARS]; /* declared-variable stack */