summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-22 18:57:18 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-22 18:57:18 -0200
commit03f3f9e707ceaf46efb4917f8d32ea62283b9358 (patch)
treecdf8e8d255fc95e09b94521dff35cd4f0f57d1e6
parenta78eecee48c725549316629b9a8d936c990b65de (diff)
downloadlua-github-03f3f9e707ceaf46efb4917f8d32ea62283b9358.tar.gz
"zio" now keeps its "name".
-rw-r--r--ldo.c28
-rw-r--r--lparser.h4
-rw-r--r--lua.stx6
-rw-r--r--lzio.c12
-rw-r--r--lzio.h11
5 files changed, 32 insertions, 29 deletions
diff --git a/ldo.c b/ldo.c
index 8ab4854f..88261e50 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 1.16 1997/12/17 20:57:20 roberto Exp roberto $
+** $Id: ldo.c,v 1.17 1997/12/18 18:32:39 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -296,7 +296,7 @@ int luaD_protectedrun (int nResults)
/*
** returns 0 = chunk loaded; 1 = error; 2 = no more chunks to load
*/
-static int protectedparser (ZIO *z, char *chunkname, int bin)
+static int protectedparser (ZIO *z, int bin)
{
int status;
TProtoFunc *tf;
@@ -304,7 +304,7 @@ static int protectedparser (ZIO *z, char *chunkname, int bin)
jmp_buf *oldErr = L->errorJmp;
L->errorJmp = &myErrorJmp;
if (setjmp(myErrorJmp) == 0) {
- tf = bin ? luaU_undump1(z, chunkname) : luaY_parser(z, chunkname);
+ tf = bin ? luaU_undump1(z) : luaY_parser(z);
status = 0;
}
else {
@@ -322,12 +322,12 @@ static int protectedparser (ZIO *z, char *chunkname, int bin)
}
-static int do_main (ZIO *z, char *chunkname, int bin)
+static int do_main (ZIO *z, int bin)
{
int status;
do {
long old_blocks = (luaC_checkGC(), L->nblocks);
- status = protectedparser(z, chunkname, bin);
+ status = protectedparser(z, bin);
if (status == 1) return 1; /* error */
else if (status == 2) return 0; /* 'natural' end */
else {
@@ -368,8 +368,8 @@ int lua_dofile (char *filename)
bin = (c == ID_CHUNK);
if (bin)
f = freopen(filename, "rb", f); /* set binary mode */
- luaZ_Fopen(&z, f);
- status = do_main(&z, filename, bin);
+ luaZ_Fopen(&z, f, filename);
+ status = do_main(&z, bin);
if (f != stdin)
fclose(f);
return status;
@@ -383,15 +383,15 @@ int lua_dofile (char *filename)
int lua_dostring (char *str)
{
int status;
- char buff[SIZE_PREF+25];
+ char name[SIZE_PREF+25];
char *temp;
ZIO z;
if (str == NULL) return 1;
- sprintf(buff, "(dostring) >> %." SSIZE_PREF "s", str);
- temp = strchr(buff, '\n');
+ sprintf(name, "(dostring) >> %." SSIZE_PREF "s", str);
+ temp = strchr(name, '\n');
if (temp) *temp = 0; /* end string after first line */
- luaZ_sopen(&z, str);
- status = do_main(&z, buff, 0);
+ luaZ_sopen(&z, str, name);
+ status = do_main(&z, 0);
return status;
}
@@ -401,8 +401,8 @@ int lua_dobuffer (char *buff, int size)
{
int status;
ZIO z;
- luaZ_mopen(&z, buff, size);
- status = do_main(&z, "(buffer)", 1);
+ luaZ_mopen(&z, buff, size, "(buffer)");
+ status = do_main(&z, 1);
return status;
}
#endif
diff --git a/lparser.h b/lparser.h
index 5df77abc..f94045d2 100644
--- a/lparser.h
+++ b/lparser.h
@@ -1,5 +1,5 @@
/*
-** $Id: $
+** $Id: lparser.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
** Syntax analizer and code generator
** See Copyright Notice in lua.h
*/
@@ -12,7 +12,7 @@
void luaY_codedebugline (int line);
-TProtoFunc *luaY_parser (ZIO *z, char *chunkname);
+TProtoFunc *luaY_parser (ZIO *z);
void luaY_error (char *s);
void luaY_syntaxerror (char *s, char *token);
diff --git a/lua.stx b/lua.stx
index 6dbaf32b..3eac8519 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,6 +1,6 @@
%{
/*
-** $Id: lua.stx,v 1.23 1997/12/15 16:17:20 roberto Exp roberto $
+** $Id: lua.stx,v 1.24 1997/12/22 17:24:11 roberto Exp roberto $
** Syntax analizer and code generator
** See Copyright Notice in lua.h
*/
@@ -619,14 +619,14 @@ static TProtoFunc *close_func (void)
/*
** Parse Lua code.
*/
-TProtoFunc *luaY_parser (ZIO *z, char *chunkname)
+TProtoFunc *luaY_parser (ZIO *z)
{
struct LexState lexstate;
FuncState state[MAXSTATES];
L->currState = L->mainState = &state[0];
L->lexstate = &lexstate;
luaX_setinput(z);
- init_state(luaS_new(chunkname));
+ init_state(luaS_new(zname(z)));
if (luaY_parse()) lua_error("parse error");
return close_func();
}
diff --git a/lzio.c b/lzio.c
index eebecb08..35a2d6a7 100644
--- a/lzio.c
+++ b/lzio.c
@@ -1,5 +1,5 @@
/*
-** $Id: lzio.c,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
+** $Id: lzio.c,v 1.2 1997/11/21 19:00:46 roberto Exp roberto $
** a generic input stream interface
** See Copyright Notice in lua.h
*/
@@ -20,22 +20,23 @@ static int zmfilbuf (ZIO* z)
return EOZ;
}
-ZIO* zmopen (ZIO* z, char* b, int size)
+ZIO* zmopen (ZIO* z, char* b, int size, char *name)
{
if (b==NULL) return NULL;
z->n=size;
z->p= (unsigned char *)b;
z->filbuf=zmfilbuf;
z->u=NULL;
+ z->name=name;
return z;
}
/* ------------------------------------------------------------ strings --- */
-ZIO* zsopen (ZIO* z, char* s)
+ZIO* zsopen (ZIO* z, char* s, char *name)
{
if (s==NULL) return NULL;
- return zmopen(z,s,strlen(s));
+ return zmopen(z,s,strlen(s),name);
}
/* -------------------------------------------------------------- FILEs --- */
@@ -50,13 +51,14 @@ static int zffilbuf (ZIO* z)
}
-ZIO* zFopen (ZIO* z, FILE* f)
+ZIO* zFopen (ZIO* z, FILE* f, char *name)
{
if (f==NULL) return NULL;
z->n=0;
z->p=z->buffer;
z->filbuf=zffilbuf;
z->u=f;
+ z->name=name;
return z;
}
diff --git a/lzio.h b/lzio.h
index 4de21020..54354a8a 100644
--- a/lzio.h
+++ b/lzio.h
@@ -1,5 +1,5 @@
/*
-** $Id: lzio.h,v 1.1 1997/09/16 19:25:59 roberto Exp roberto $
+** $Id: lzio.h,v 1.2 1997/11/21 19:00:46 roberto Exp roberto $
** Buffered streams
** See Copyright Notice in lua.h
*/
@@ -22,15 +22,15 @@
typedef struct zio ZIO;
-ZIO* zFopen (ZIO* z, FILE* f); /* open FILEs */
-ZIO* zsopen (ZIO* z, char* s); /* string */
-ZIO* zmopen (ZIO* z, char* b, int size); /* memory */
+ZIO* zFopen (ZIO* z, FILE* f, char *name); /* open FILEs */
+ZIO* zsopen (ZIO* z, char* s, char *name); /* string */
+ZIO* zmopen (ZIO* z, char* b, int size, char *name); /* memory */
int zread (ZIO* z, void* b, int n); /* read next n bytes */
#define zgetc(z) (--(z)->n>=0 ? ((int)*(z)->p++): (z)->filbuf(z))
#define zungetc(z) (++(z)->n,--(z)->p)
-
+#define zname(z) ((z)->name)
/* --------- Private Part ------------------ */
@@ -43,6 +43,7 @@ struct zio {
int (*filbuf)(ZIO* z);
void* u; /* additional data */
unsigned char buffer[ZBSIZE]; /* buffer */
+ char *name;
};