aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-10 17:51:39 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-10 17:51:39 -0200
commit2bddbe660321547e606022f9c82e9511e54d5df6 (patch)
tree1c6e09ff3c6e37d64b68615ccffb560343ada43e
parente323338fd09216069d1290ec099ac987aadb036b (diff)
downloadlua-2bddbe660321547e606022f9c82e9511e54d5df6.tar.gz
lua-2bddbe660321547e606022f9c82e9511e54d5df6.tar.bz2
lua-2bddbe660321547e606022f9c82e9511e54d5df6.zip
cannot change `filename' before eventual call to `freopen'
-rw-r--r--ldo.c12
1 files 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 @@
1/* 1/*
2** $Id: ldo.c,v 1.105 2000/10/09 13:47:32 roberto Exp roberto $ 2** $Id: ldo.c,v 1.106 2000/10/09 15:46:43 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*/
@@ -264,11 +264,6 @@ static int parse_file (lua_State *L, const char *filename) {
264 int c; /* look ahead char */ 264 int c; /* look ahead char */
265 FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); 265 FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
266 if (f == NULL) return LUA_ERRFILE; /* unable to open file */ 266 if (f == NULL) return LUA_ERRFILE; /* unable to open file */
267 lua_pushstring(L, "@");
268 lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename);
269 lua_concat(L, 2);
270 filename = lua_tostring(L, -1); /* filename = '@'..filename */
271 lua_pop(L, 1); /* OK: there is no GC during parser */
272 c = fgetc(f); 267 c = fgetc(f);
273 ungetc(c, f); 268 ungetc(c, f);
274 bin = (c == ID_CHUNK); 269 bin = (c == ID_CHUNK);
@@ -276,6 +271,11 @@ static int parse_file (lua_State *L, const char *filename) {
276 f = freopen(filename, "rb", f); /* set binary mode */ 271 f = freopen(filename, "rb", f); /* set binary mode */
277 if (f == NULL) return LUA_ERRFILE; /* unable to reopen file */ 272 if (f == NULL) return LUA_ERRFILE; /* unable to reopen file */
278 } 273 }
274 lua_pushstring(L, "@");
275 lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename);
276 lua_concat(L, 2);
277 filename = lua_tostring(L, -1); /* filename = '@'..filename */
278 lua_pop(L, 1); /* OK: there is no GC during parser */
279 luaZ_Fopen(&z, f, filename); 279 luaZ_Fopen(&z, f, filename);
280 status = protectedparser(L, &z, bin); 280 status = protectedparser(L, &z, bin);
281 if (f != stdin) 281 if (f != stdin)