diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-04-06 16:26:06 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-04-06 16:26:06 -0300 |
commit | 9aedea6ec8feaa163fe0503005dee30d4ed0ba55 (patch) | |
tree | 48b9c660cbb44ec7ad5a3128627bd1846c39a519 | |
parent | a68635a919c5541b6acf5c2e8da5f81c67b65a7a (diff) | |
download | lua-9aedea6ec8feaa163fe0503005dee30d4ed0ba55.tar.gz lua-9aedea6ec8feaa163fe0503005dee30d4ed0ba55.tar.bz2 lua-9aedea6ec8feaa163fe0503005dee30d4ed0ba55.zip |
small bug (when parser fails, there is no function on the stack...)
-rw-r--r-- | ldo.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.131 2001/03/07 18:09:25 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.132 2001/03/26 14:31:49 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -259,6 +259,7 @@ static int parse_file (lua_State *L, const l_char *filename) { | |||
259 | ZIO z; | 259 | ZIO z; |
260 | int status; | 260 | int status; |
261 | int bin; /* flag for file mode */ | 261 | int bin; /* flag for file mode */ |
262 | int nlevel; /* level on the stack of filename */ | ||
262 | FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r")); | 263 | FILE *f = (filename == NULL) ? stdin : fopen(filename, l_s("r")); |
263 | if (f == NULL) return LUA_ERRFILE; /* unable to open file */ | 264 | if (f == NULL) return LUA_ERRFILE; /* unable to open file */ |
264 | bin = (ungetc(fgetc(f), f) == ID_CHUNK); | 265 | bin = (ungetc(fgetc(f), f) == ID_CHUNK); |
@@ -270,10 +271,11 @@ static int parse_file (lua_State *L, const l_char *filename) { | |||
270 | lua_pushliteral(L, l_s("@")); | 271 | lua_pushliteral(L, l_s("@")); |
271 | lua_pushstring(L, (filename == NULL) ? l_s("(stdin)") : filename); | 272 | lua_pushstring(L, (filename == NULL) ? l_s("(stdin)") : filename); |
272 | lua_concat(L, 2); | 273 | lua_concat(L, 2); |
274 | nlevel = lua_gettop(L); | ||
273 | filename = lua_tostring(L, -1); /* filename = `@'..filename */ | 275 | filename = lua_tostring(L, -1); /* filename = `@'..filename */ |
274 | luaZ_Fopen(&z, f, filename); | 276 | luaZ_Fopen(&z, f, filename); |
275 | status = protectedparser(L, &z, bin); | 277 | status = protectedparser(L, &z, bin); |
276 | lua_remove(L, -2); /* remove filename */ | 278 | lua_remove(L, nlevel); /* remove filename */ |
277 | if (f != stdin) | 279 | if (f != stdin) |
278 | fclose(f); | 280 | fclose(f); |
279 | return status; | 281 | return status; |