From 9fcc48517659c72de43bece515fdd5cea88c07f8 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 25 Aug 2003 16:51:54 -0300 Subject: [PATCH] zio does not keep "source" name (nobody uses it) --- lapi.c | 6 +++--- ldo.c | 10 ++++++---- ldo.h | 4 ++-- lparser.c | 6 +++--- lparser.h | 4 ++-- lundump.c | 5 ++--- lundump.h | 4 ++-- lzio.c | 5 ++--- lzio.h | 7 ++----- 9 files changed, 24 insertions(+), 27 deletions(-) diff --git a/lapi.c b/lapi.c index 88ed5dd6..2a8283a4 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 1.240 2003/07/07 13:34:25 roberto Exp roberto $ +** $Id: lapi.c,v 1.241 2003/08/15 13:48:53 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -718,9 +718,9 @@ LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, int c; lua_lock(L); if (!chunkname) chunkname = "?"; - luaZ_init(&z, reader, data, chunkname); + luaZ_init(&z, reader, data); c = luaZ_lookahead(&z); - status = luaD_protectedparser(L, &z, (c == LUA_SIGNATURE[0])); + status = luaD_protectedparser(L, &z, (c == LUA_SIGNATURE[0]), chunkname); lua_unlock(L); return status; } diff --git a/ldo.c b/ldo.c index 25c4a27a..c6fd0b59 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 1.220 2003/07/16 20:49:02 roberto Exp roberto $ +** $Id: ldo.c,v 1.221 2003/07/16 20:51:47 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -431,6 +431,7 @@ struct SParser { /* data to `f_parser' */ ZIO *z; Mbuffer buff; /* buffer to be used by the scanner */ int bin; + const char *name; }; static void f_parser (lua_State *L, void *ud) { @@ -439,7 +440,8 @@ static void f_parser (lua_State *L, void *ud) { Closure *cl; luaC_checkGC(L); p = cast(struct SParser *, ud); - tf = p->bin ? luaU_undump(L, p->z, &p->buff) : luaY_parser(L, p->z, &p->buff); + tf = p->bin ? luaU_undump(L, p->z, &p->buff, p->name) : + luaY_parser(L, p->z, &p->buff, p->name); cl = luaF_newLclosure(L, 0, gt(L)); cl->l.p = tf; setclvalue(L->top, cl); @@ -447,11 +449,11 @@ static void f_parser (lua_State *L, void *ud) { } -int luaD_protectedparser (lua_State *L, ZIO *z, int bin) { +int luaD_protectedparser (lua_State *L, ZIO *z, int bin, const char *name) { struct SParser p; int status; ptrdiff_t oldtopr = savestack(L, L->top); /* save current top */ - p.z = z; p.bin = bin; + p.z = z; p.bin = bin; p.name = name; luaZ_initbuffer(L, &p.buff); status = luaD_rawrunprotected(L, f_parser, &p); luaZ_freebuffer(L, &p.buff); diff --git a/ldo.h b/ldo.h index 929ee8ed..af13516f 100644 --- a/ldo.h +++ b/ldo.h @@ -1,5 +1,5 @@ /* -** $Id: ldo.h,v 1.55 2002/11/21 17:41:25 roberto Exp roberto $ +** $Id: ldo.h,v 1.56 2002/12/04 17:29:32 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -42,7 +42,7 @@ typedef void (*Pfunc) (lua_State *L, void *ud); void luaD_resetprotection (lua_State *L); -int luaD_protectedparser (lua_State *L, ZIO *z, int bin); +int luaD_protectedparser (lua_State *L, ZIO *z, int bin, const char *name); void luaD_callhook (lua_State *L, int event, int line); StkId luaD_precall (lua_State *L, StkId func); void luaD_call (lua_State *L, StkId func, int nResults); diff --git a/lparser.c b/lparser.c index 33d0344e..1eb56401 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.214 2003/07/28 18:31:20 roberto Exp roberto $ +** $Id: lparser.c,v 1.215 2003/07/29 18:51:00 roberto Exp roberto $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -348,12 +348,12 @@ static void close_func (LexState *ls) { } -Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff) { +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { struct LexState lexstate; struct FuncState funcstate; lexstate.buff = buff; lexstate.nestlevel = 0; - luaX_setinput(L, &lexstate, z, luaS_new(L, zname(z))); + luaX_setinput(L, &lexstate, z, luaS_new(L, name)); open_func(&lexstate, &funcstate); next(&lexstate); /* read first token */ chunk(&lexstate); diff --git a/lparser.h b/lparser.h index 1cb52623..42d46783 100644 --- a/lparser.h +++ b/lparser.h @@ -1,5 +1,5 @@ /* -** $Id: lparser.h,v 1.48 2003/07/09 15:36:38 roberto Exp roberto $ +** $Id: lparser.h,v 1.49 2003/07/09 20:11:30 roberto Exp roberto $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -71,7 +71,7 @@ typedef struct FuncState { } FuncState; -Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff); +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name); #endif diff --git a/lundump.c b/lundump.c index a4a9bc26..30f6f904 100644 --- a/lundump.c +++ b/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 1.49 2003/04/07 20:34:20 lhf Exp lhf $ +** $Id: lundump.c,v 1.62 2003/08/15 13:48:53 roberto Exp roberto $ ** load pre-compiled Lua chunks ** See Copyright Notice in lua.h */ @@ -256,10 +256,9 @@ static Proto* LoadChunk (LoadState* S) /* ** load precompiled chunk */ -Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff) +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char *s) { LoadState S; - const char* s=zname(Z); if (*s=='@' || *s=='=') S.name=s+1; else if (*s==LUA_SIGNATURE[0]) diff --git a/lundump.h b/lundump.h index b9ae7126..b3f9b6d2 100644 --- a/lundump.h +++ b/lundump.h @@ -1,5 +1,5 @@ /* -** $Id: lundump.h,v 1.30 2003/04/07 20:34:20 lhf Exp lhf $ +** $Id: lundump.h,v 1.33 2003/08/15 13:48:53 roberto Exp roberto $ ** load pre-compiled Lua chunks ** See Copyright Notice in lua.h */ @@ -11,7 +11,7 @@ #include "lzio.h" /* load one chunk; from lundump.c */ -Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff); +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char *name); /* find byte order; from lundump.c */ int luaU_endianness (void); diff --git a/lzio.c b/lzio.c index ed14abc6..4ce47161 100644 --- a/lzio.c +++ b/lzio.c @@ -1,5 +1,5 @@ /* -** $Id: lzio.c,v 1.23 2002/12/04 17:38:31 roberto Exp roberto $ +** $Id: lzio.c,v 1.24 2003/03/20 16:00:56 roberto Exp roberto $ ** a generic input stream interface ** See Copyright Notice in lua.h */ @@ -37,10 +37,9 @@ int luaZ_lookahead (ZIO *z) { } -void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data, const char *name) { +void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data) { z->reader = reader; z->data = data; - z->name = name; z->n = 0; z->p = NULL; } diff --git a/lzio.h b/lzio.h index 2637eb1b..d2a99071 100644 --- a/lzio.h +++ b/lzio.h @@ -1,5 +1,5 @@ /* -** $Id: lzio.h,v 1.14 2002/10/08 18:46:08 roberto Exp roberto $ +** $Id: lzio.h,v 1.15 2003/03/20 16:00:56 roberto Exp roberto $ ** Buffered streams ** See Copyright Notice in lua.h */ @@ -20,9 +20,7 @@ typedef struct Zio ZIO; #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) -#define zname(z) ((z)->name) - -void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data, const char *name); +void luaZ_init (ZIO *z, lua_Chunkreader reader, void *data); size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ int luaZ_lookahead (ZIO *z); @@ -55,7 +53,6 @@ struct Zio { const char *p; /* current position in buffer */ lua_Chunkreader reader; void* data; /* additional data */ - const char *name; };