diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-05 11:50:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-05 11:50:42 -0300 |
commit | 7eb1ed21b7057ab5f1b921f8271eddcf13659737 (patch) | |
tree | 921d52f71dfa72461b0dc45ee3667f98f56521ba /lauxlib.c | |
parent | 2db966fcbf757775c842bc66449d7e697826aa1d (diff) | |
download | lua-7eb1ed21b7057ab5f1b921f8271eddcf13659737.tar.gz lua-7eb1ed21b7057ab5f1b921f8271eddcf13659737.tar.bz2 lua-7eb1ed21b7057ab5f1b921f8271eddcf13659737.zip |
More permissive use of 'errno'
Assume that no function will put garbage on errno (although ISO C allows
that). If any function during an operation set errno, and the operation
result in an error, assume that errno has something to say.
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -811,9 +811,9 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, | |||
811 | } | 811 | } |
812 | if (c != EOF) | 812 | if (c != EOF) |
813 | lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ | 813 | lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ |
814 | errno = 0; | ||
814 | status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); | 815 | status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); |
815 | readstatus = ferror(lf.f); | 816 | readstatus = ferror(lf.f); |
816 | errno = 0; /* no useful error number until here */ | ||
817 | if (filename) fclose(lf.f); /* close file (even in case of errors) */ | 817 | if (filename) fclose(lf.f); /* close file (even in case of errors) */ |
818 | if (readstatus) { | 818 | if (readstatus) { |
819 | lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ | 819 | lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ |