diff options
Diffstat (limited to 'iolib.c')
-rw-r--r-- | iolib.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -288,9 +288,10 @@ static void getbyte (void) | |||
288 | lua_pushnumber(lua_getbindatasize(ud)); | 288 | lua_pushnumber(lua_getbindatasize(ud)); |
289 | else { | 289 | else { |
290 | i--; | 290 | i--; |
291 | luaL_arg_check(0 <= i && i < lua_getbindatasize(ud), "getbyte", 2, | 291 | if (0 <= i && i < lua_getbindatasize(ud)) |
292 | "out of range"); | 292 | lua_pushnumber(*(((char *)lua_getbinarydata(ud))+i)); |
293 | lua_pushnumber(*(((char *)lua_getbinarydata(ud))+i)); | 293 | else |
294 | lua_pushnil(); | ||
294 | } | 295 | } |
295 | } | 296 | } |
296 | 297 | ||
@@ -341,7 +342,7 @@ static struct luaL_reg iolib[] = { | |||
341 | 342 | ||
342 | void iolib_open (void) | 343 | void iolib_open (void) |
343 | { | 344 | { |
344 | lua_tagio = lua_newtag("userdata"); | 345 | lua_tagio = lua_newtag(); |
345 | lua_infile=stdin; lua_outfile=stdout; | 346 | lua_infile=stdin; lua_outfile=stdout; |
346 | luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0]))); | 347 | luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0]))); |
347 | lua_seterrormethod(errorfb); | 348 | lua_seterrormethod(errorfb); |