diff options
| -rw-r--r-- | liolib.c | 12 |
1 files changed, 10 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 2.107 2011/11/14 16:55:35 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.108 2011/11/25 12:50:03 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 | */ |
| @@ -29,6 +29,14 @@ | |||
| 29 | #include "lualib.h" | 29 | #include "lualib.h" |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | #if !defined(lua_checkmode) | ||
| 33 | |||
| 34 | /* | ||
| 35 | ** this macro can accept other 'modes' for 'fopen' besides the standard ones | ||
| 36 | */ | ||
| 37 | #define lua_checkmode(mode) 0 | ||
| 38 | |||
| 39 | #endif | ||
| 32 | 40 | ||
| 33 | /* | 41 | /* |
| 34 | ** {====================================================== | 42 | ** {====================================================== |
| @@ -217,7 +225,7 @@ static int io_open (lua_State *L) { | |||
| 217 | if (!(mode[i] != '\0' && strchr("rwa", mode[i++]) != NULL && | 225 | if (!(mode[i] != '\0' && strchr("rwa", mode[i++]) != NULL && |
| 218 | (mode[i] != '+' || ++i) && /* skip if char is '+' */ | 226 | (mode[i] != '+' || ++i) && /* skip if char is '+' */ |
| 219 | (mode[i] != 'b' || ++i) && /* skip if char is 'b' */ | 227 | (mode[i] != 'b' || ++i) && /* skip if char is 'b' */ |
| 220 | (mode[i] == '\0'))) | 228 | (mode[i] == '\0')) && !lua_checkmode(mode)) |
| 221 | return luaL_error(L, "invalid mode " LUA_QS | 229 | return luaL_error(L, "invalid mode " LUA_QS |
| 222 | " (should match " LUA_QL("[rwa]%%+?b?") ")", mode); | 230 | " (should match " LUA_QL("[rwa]%%+?b?") ")", mode); |
| 223 | p->f = fopen(filename, mode); | 231 | p->f = fopen(filename, mode); |
