From 2bddbe660321547e606022f9c82e9511e54d5df6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 10 Oct 2000 17:51:39 -0200 Subject: cannot change `filename' before eventual call to `freopen' --- ldo.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ldo.c b/ldo.c index d209d12b..ab61e40d 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 1.105 2000/10/09 13:47:32 roberto Exp roberto $ +** $Id: ldo.c,v 1.106 2000/10/09 15:46:43 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -264,11 +264,6 @@ static int parse_file (lua_State *L, const char *filename) { int c; /* look ahead char */ FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); if (f == NULL) return LUA_ERRFILE; /* unable to open file */ - lua_pushstring(L, "@"); - lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename); - lua_concat(L, 2); - filename = lua_tostring(L, -1); /* filename = '@'..filename */ - lua_pop(L, 1); /* OK: there is no GC during parser */ c = fgetc(f); ungetc(c, f); bin = (c == ID_CHUNK); @@ -276,6 +271,11 @@ static int parse_file (lua_State *L, const char *filename) { f = freopen(filename, "rb", f); /* set binary mode */ if (f == NULL) return LUA_ERRFILE; /* unable to reopen file */ } + lua_pushstring(L, "@"); + lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename); + lua_concat(L, 2); + filename = lua_tostring(L, -1); /* filename = '@'..filename */ + lua_pop(L, 1); /* OK: there is no GC during parser */ luaZ_Fopen(&z, f, filename); status = protectedparser(L, &z, bin); if (f != stdin) -- cgit v1.2.3-55-g6feb