From 9aedea6ec8feaa163fe0503005dee30d4ed0ba55 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 6 Apr 2001 16:26:06 -0300 Subject: small bug (when parser fails, there is no function on the stack...) --- ldo.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ldo.c b/ldo.c index e9129805..e676b68d 100644 --- a/ldo.c +++ b/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 ** See Copyright Notice in lua.h */ @@ -259,6 +259,7 @@ static int parse_file (lua_State *L, const l_char *filename) { ZIO z; int status; int bin; /* flag for file mode */ + int nlevel; /* level on the stack of filename */ FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r")); if (f == NULL) return LUA_ERRFILE; /* unable to open file */ 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_pushstring(L, (filename == NULL) ? l_s("(stdin)") : filename); lua_concat(L, 2); + nlevel = lua_gettop(L); filename = lua_tostring(L, -1); /* filename = `@'..filename */ luaZ_Fopen(&z, f, filename); status = protectedparser(L, &z, bin); - lua_remove(L, -2); /* remove filename */ + lua_remove(L, nlevel); /* remove filename */ if (f != stdin) fclose(f); return status; -- cgit v1.2.3-55-g6feb