From 9b45439860879dd282e6d0896c4ee8102febc7fd Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 26 Jan 2001 12:16:24 -0200 Subject: details --- liolib.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'liolib.c') diff --git a/liolib.c b/liolib.c index e4851209..cb3325f0 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 1.100 2001/01/25 16:45:36 roberto Exp roberto $ +** $Id: liolib.c,v 1.101 2001/01/26 11:45:51 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -306,14 +306,12 @@ static int io_read (lua_State *L) { luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); success = 1; for (n = 1; n<=nargs && success; n++) { - const char *p = luaL_check_string(L, n); - if (p[0] != '*') { - if (lua_isnumber(L, n)) - success = read_chars(L, f, (size_t)lua_tonumber(L, n)); - else - lua_error(L, "read patterns are deprecated"); - } + if (lua_type(L, n) == LUA_TNUMBER) + success = read_chars(L, f, (size_t)lua_tonumber(L, n)); else { + const char *p = lua_tostring(L, n); + if (!p || p[0] != '*') + lua_error(L, "invalid `read' option"); switch (p[1]) { case 'n': /* number */ success = read_number(L, f); -- cgit v1.2.3-55-g6feb