diff options
| author | Mike Pall <mike> | 2024-08-19 17:33:23 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2024-08-19 17:33:23 +0200 |
| commit | fb5e1c9f0d449a2b987c2c4b29f6cc811242b0a1 (patch) | |
| tree | 57492083153c67f3c5a41af9af420a715b997894 /src | |
| parent | fddc9650d85ec6021c4e3509753b9a88766c5ae1 (diff) | |
| parent | ab39082fddfca0de268a106a3b6d736eef032328 (diff) | |
| download | luajit-fb5e1c9f0d449a2b987c2c4b29f6cc811242b0a1.tar.gz luajit-fb5e1c9f0d449a2b987c2c4b29f6cc811242b0a1.tar.bz2 luajit-fb5e1c9f0d449a2b987c2c4b29f6cc811242b0a1.zip | |
Merge branch 'master' into v2.1
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_load.c | 16 |
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 | } |
