From 223bb04090344b1972dc2a7910a54b46210f0d40 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 31 Jul 2019 11:41:59 -0300 Subject: Correction in the documentation of 'io.lines' The loop does not end on end of file, but when the iterator function fails to read a value. (In particular, the format "a" never fails, so a loop with 'io.lines(fname, "a")' never ends.) --- liolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'liolib.c') diff --git a/liolib.c b/liolib.c index 83fbb172..56507d5e 100644 --- a/liolib.c +++ b/liolib.c @@ -624,7 +624,7 @@ static int io_readline (lua_State *L) { lua_pushvalue(L, lua_upvalueindex(3 + i)); n = g_read(L, p->f, 2); /* 'n' is number of results */ lua_assert(n > 0); /* should return at least a nil */ - if (lua_toboolean(L, -n)) /* read at least one value? */ + if (!lua_isnil(L, -n)) /* read at least one value? */ return n; /* return them */ else { /* first result is nil: EOF or error */ if (n > 1) { /* is there error information? */ -- cgit v1.2.3-55-g6feb