From b518d1407149a23d31b486f5bd3ef9e6daae93c1 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 20 Mar 2003 13:00:56 -0300 Subject: bug: zio mixes a 255 as first char in a buffer with EOZ --- bugs | 5 +++++ lzio.c | 6 +++--- lzio.h | 9 +++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bugs b/bugs index e39ae780..89ec20db 100644 --- a/bugs +++ b/bugs @@ -329,3 +329,8 @@ Fri Feb 28 14:20:33 EST 2003 >> GC metamethod calls could mess C/Lua stack syncronization (by Roberto; since 5.0b) +** lzio.h/zlio.c +Thu Mar 20 11:40:12 EST 2003 +>> zio mixes a 255 as first char in a buffer with EOZ +(by lhf; since 5.0a) + diff --git a/lzio.c b/lzio.c index 19e05c5c..ed14abc6 100644 --- a/lzio.c +++ b/lzio.c @@ -1,5 +1,5 @@ /* -** $Id: lzio.c,v 1.22 2002/10/08 18:46:08 roberto Exp roberto $ +** $Id: lzio.c,v 1.23 2002/12/04 17:38:31 roberto Exp roberto $ ** a generic input stream interface ** See Copyright Notice in lua.h */ @@ -22,7 +22,7 @@ int luaZ_fill (ZIO *z) { if (buff == NULL || size == 0) return EOZ; z->n = size - 1; z->p = buff; - return *(z->p++); + return char2int(*(z->p++)); } @@ -33,7 +33,7 @@ int luaZ_lookahead (ZIO *z) { z->n++; z->p--; } - return *z->p; + return char2int(*z->p); } diff --git a/lzio.h b/lzio.h index f2fbad90..2637eb1b 100644 --- a/lzio.h +++ b/lzio.h @@ -1,5 +1,5 @@ /* -** $Id: lzio.h,v 1.13 2002/08/05 18:45:02 roberto Exp roberto $ +** $Id: lzio.h,v 1.14 2002/10/08 18:46:08 roberto Exp roberto $ ** Buffered streams ** See Copyright Notice in lua.h */ @@ -15,9 +15,10 @@ typedef struct Zio ZIO; -#define zgetc(z) (((z)->n--)>0 ? \ - cast(int, cast(unsigned char, *(z)->p++)) : \ - luaZ_fill(z)) + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) #define zname(z) ((z)->name) -- cgit v1.2.3-55-g6feb