small bug (when parser fails, there is no function on the stack...)
This commit is contained in:
6
ldo.c
6
ldo.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.131 2001/03/07 18:09:25 roberto Exp roberto $
|
** $Id: ldo.c,v 1.132 2001/03/26 14:31:49 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -259,6 +259,7 @@ static int parse_file (lua_State *L, const l_char *filename) {
|
|||||||
ZIO z;
|
ZIO z;
|
||||||
int status;
|
int status;
|
||||||
int bin; /* flag for file mode */
|
int bin; /* flag for file mode */
|
||||||
|
int nlevel; /* level on the stack of filename */
|
||||||
FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r"));
|
FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r"));
|
||||||
if (f == NULL) return LUA_ERRFILE; /* unable to open file */
|
if (f == NULL) return LUA_ERRFILE; /* unable to open file */
|
||||||
bin = (ungetc(fgetc(f), f) == ID_CHUNK);
|
bin = (ungetc(fgetc(f), f) == ID_CHUNK);
|
||||||
@@ -270,10 +271,11 @@ static int parse_file (lua_State *L, const l_char *filename) {
|
|||||||
lua_pushliteral(L, l_s("@"));
|
lua_pushliteral(L, l_s("@"));
|
||||||
lua_pushstring(L, (filename == NULL) ? l_s("(stdin)") : filename);
|
lua_pushstring(L, (filename == NULL) ? l_s("(stdin)") : filename);
|
||||||
lua_concat(L, 2);
|
lua_concat(L, 2);
|
||||||
|
nlevel = lua_gettop(L);
|
||||||
filename = lua_tostring(L, -1); /* filename = `@'..filename */
|
filename = lua_tostring(L, -1); /* filename = `@'..filename */
|
||||||
luaZ_Fopen(&z, f, filename);
|
luaZ_Fopen(&z, f, filename);
|
||||||
status = protectedparser(L, &z, bin);
|
status = protectedparser(L, &z, bin);
|
||||||
lua_remove(L, -2); /* remove filename */
|
lua_remove(L, nlevel); /* remove filename */
|
||||||
if (f != stdin)
|
if (f != stdin)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
Reference in New Issue
Block a user