buffer should better use `size_t' for its size

This commit is contained in:
Roberto Ierusalimschy 2003-10-03 13:05:34 -03:00
parent 3a508b8bd7
commit 7b8504840f
2 changed files with 13 additions and 9 deletions

12
llex.c
View File

@ -1,5 +1,5 @@
/*
** $Id: llex.c,v 1.124 2003/08/29 16:48:14 roberto Exp roberto $
** $Id: llex.c,v 1.125 2003/09/04 20:00:28 roberto Exp roberto $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@ -24,7 +24,15 @@
#define next(ls) (ls->current = zgetc(ls->z))
#define save(ls,c) luaZ_save(ls->L,ls->buff,c)
#define MINLEXBUF 32
#define save(ls,c) { \
Mbuffer *b = ls->buff; \
if (b->n + 1 > b->buffsize) \
luaZ_resizebuffer(ls->L, b, ((b->buffsize*2) + MINLEXBUF)); \
b->buffer[b->n++] = cast(char, c); }
#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r')

10
lzio.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lzio.h,v 1.17 2003/08/25 20:00:50 roberto Exp roberto $
** $Id: lzio.h,v 1.18 2003/08/28 14:38:46 roberto Exp roberto $
** Buffered streams
** See Copyright Notice in lua.h
*/
@ -30,8 +30,8 @@ int luaZ_lookahead (ZIO *z);
typedef struct Mbuffer {
char *buffer;
int n;
int buffsize;
size_t n;
size_t buffsize;
} Mbuffer;
@ -52,10 +52,6 @@ char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
#define luaZ_save(L,b,c) { \
luaM_growvector(L, b->buffer, b->n, b->buffsize, char, \
MAX_INT, "token too long"); \
b->buffer[b->n++] = cast(char, c); }
/* --------- Private Part ------------------ */