aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lj_load.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lj_load.c b/src/lj_load.c
index fa6ed5bf..5bb10b5b 100644
--- a/src/lj_load.c
+++ b/src/lj_load.c
@@ -101,6 +101,7 @@ LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename,
101 FileReaderCtx ctx; 101 FileReaderCtx ctx;
102 int status; 102 int status;
103 const char *chunkname; 103 const char *chunkname;
104 int err = 0;
104 if (filename) { 105 if (filename) {
105 chunkname = lua_pushfstring(L, "@%s", filename); 106 chunkname = lua_pushfstring(L, "@%s", filename);
106 ctx.fp = fopen(filename, "rb"); 107 ctx.fp = fopen(filename, "rb");
@@ -114,17 +115,16 @@ LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename,
114 chunkname = "=stdin"; 115 chunkname = "=stdin";
115 } 116 }
116 status = lua_loadx(L, reader_file, &ctx, chunkname, mode); 117 status = lua_loadx(L, reader_file, &ctx, chunkname, mode);
117 if (ferror(ctx.fp)) { 118 if (ferror(ctx.fp)) err = errno;
118 L->top -= filename ? 2 : 1;
119 lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(errno));
120 if (filename)
121 fclose(ctx.fp);
122 return LUA_ERRFILE;
123 }
124 if (filename) { 119 if (filename) {
120 fclose(ctx.fp);
125 L->top--; 121 L->top--;
126 copyTV(L, L->top-1, L->top); 122 copyTV(L, L->top-1, L->top);
127 fclose(ctx.fp); 123 }
124 if (err) {
125 L->top--;
126 lua_pushfstring(L, "cannot read %s: %s", chunkname+1, strerror(err));
127 return LUA_ERRFILE;
128 } 128 }
129 return status; 129 return status;
130} 130}