| 3975 | } |
| 3976 | |
| 3977 | COMPAT53_API int lua_load(lua_State* L, lua_Reader reader, void* data, const char* source, const char* mode) { |
| 3978 | int status = LUA_OK; |
| 3979 | compat53_reader_data compat53_data = { reader, data, 1, 0, 0 }; |
| 3980 | compat53_data.peeked_data = reader(L, data, &(compat53_data.peeked_data_size)); |
| 3981 | if (compat53_data.peeked_data && compat53_data.peeked_data_size && compat53_data.peeked_data[0] == LUA_SIGNATURE[0]) /* binary file? */ |
| 3982 | status = compat53_checkmode(L, mode, "binary", LUA_ERRSYNTAX); |
| 3983 | else |
| 3984 | status = compat53_checkmode(L, mode, "text", LUA_ERRSYNTAX); |
| 3985 | if (status != LUA_OK) |
| 3986 | return status; |
| 3987 | /* we need to call the original 5.1 version of lua_load! */ |
| 3988 | #undef lua_load |
| 3989 | return lua_load(L, compat53_reader, &compat53_data, source); |
| 3990 | #define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53) |
| 3991 | } |
| 3992 | |
| 3993 | typedef struct { |
| 3994 | int n; /* number of pre-read characters */ |
no test coverage detected