From 075b7918c3dcc1e8b4d5e7f19ae213b081e01bf2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 2 Apr 1997 20:04:12 -0300 Subject: new function "getintmethod" --- iolib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'iolib.c') diff --git a/iolib.c b/iolib.c index fa105828..1a2a9009 100644 --- a/iolib.c +++ b/iolib.c @@ -288,9 +288,10 @@ static void getbyte (void) lua_pushnumber(lua_getbindatasize(ud)); else { i--; - luaL_arg_check(0 <= i && i < lua_getbindatasize(ud), "getbyte", 2, - "out of range"); - lua_pushnumber(*(((char *)lua_getbinarydata(ud))+i)); + if (0 <= i && i < lua_getbindatasize(ud)) + lua_pushnumber(*(((char *)lua_getbinarydata(ud))+i)); + else + lua_pushnil(); } } @@ -341,7 +342,7 @@ static struct luaL_reg iolib[] = { void iolib_open (void) { - lua_tagio = lua_newtag("userdata"); + lua_tagio = lua_newtag(); lua_infile=stdin; lua_outfile=stdout; luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0]))); lua_seterrormethod(errorfb); -- cgit v1.2.3-55-g6feb