summaryrefslogtreecommitdiff
path: root/src/ldo.c
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2000-02-22 12:00:00 +0000
committerrepogen <>2000-02-22 12:00:00 +0000
commitb7610da5fed99f59ac73ae452da8839a0f2c1bda (patch)
treedc18aa9fc220b4d560aa2a71949e885ca9c077bf /src/ldo.c
parente7eacfb8851d87e681e6f5a1fbead87565b4aa46 (diff)
downloadlua-github-b7610da5fed99f59ac73ae452da8839a0f2c1bda.tar.gz
Lua 3.2.23.2.2
Diffstat (limited to 'src/ldo.c')
-rw-r--r--src/ldo.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ldo.c b/src/ldo.c
index bf840bf4..281a4ec4 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 1.45 1999/06/22 20:37:23 roberto Exp $
+** $Id: ldo.c,v 1.45b 1999/06/22 20:37:23 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -357,12 +357,14 @@ int lua_dofile (char *filename) {
FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
if (f == NULL)
return 2;
+ luaL_filesource(source, filename, sizeof(source));
c = fgetc(f);
ungetc(c, f);
bin = (c == ID_CHUNK);
- if (bin)
+ if (bin && f != stdin) {
f = freopen(filename, "rb", f); /* set binary mode */
- luaL_filesource(source, filename, sizeof(source));
+ if (f == NULL) return 2;
+ }
luaZ_Fopen(&z, f, source);
status = do_main(&z, bin);
if (f != stdin)