diff options
Diffstat (limited to 'liolib.c')
| -rw-r--r-- | liolib.c | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 2.69 2005/10/19 13:05:11 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.70 2005/12/29 15:32:11 roberto Exp roberto $ |
| 3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -28,6 +28,7 @@ static const char *const fnames[] = {"input", "output"}; | |||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | static int pushresult (lua_State *L, int i, const char *filename) { | 30 | static int pushresult (lua_State *L, int i, const char *filename) { |
| 31 | int en = errno; /* calls to Lua API may change this value */ | ||
| 31 | if (i) { | 32 | if (i) { |
| 32 | lua_pushboolean(L, 1); | 33 | lua_pushboolean(L, 1); |
| 33 | return 1; | 34 | return 1; |
| @@ -35,10 +36,10 @@ static int pushresult (lua_State *L, int i, const char *filename) { | |||
| 35 | else { | 36 | else { |
| 36 | lua_pushnil(L); | 37 | lua_pushnil(L); |
| 37 | if (filename) | 38 | if (filename) |
| 38 | lua_pushfstring(L, "%s: %s", filename, strerror(errno)); | 39 | lua_pushfstring(L, "%s: %s", filename, strerror(en)); |
| 39 | else | 40 | else |
| 40 | lua_pushfstring(L, "%s", strerror(errno)); | 41 | lua_pushfstring(L, "%s", strerror(en)); |
| 41 | lua_pushinteger(L, errno); | 42 | lua_pushinteger(L, en); |
| 42 | return 3; | 43 | return 3; |
| 43 | } | 44 | } |
| 44 | } | 45 | } |
