zio does not keep "source" name (nobody uses it)

This commit is contained in:
Roberto Ierusalimschy 2003-08-25 16:51:54 -03:00
parent 64066359dd
commit 9fcc485176
9 changed files with 24 additions and 27 deletions

6
lapi.c
View File

@ -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;
}

10
ldo.c
View File

@ -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);

4
ldo.h
View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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])

View File

@ -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);

5
lzio.c
View File

@ -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;
}

7
lzio.h
View File

@ -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;
};