From 46e65775bf4394a370ac61ec304417cd7488b222 Mon Sep 17 00:00:00 2001 From: Geoff Leyland Date: Mon, 26 May 2014 17:38:58 +1200 Subject: [PATCH] whoops. Fix up find's return values when we've hit the end of file. How did that work? --- lua/csv.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lua/csv.lua b/lua/csv.lua index 192e9d2..8424304 100644 --- a/lua/csv.lua +++ b/lua/csv.lua @@ -188,10 +188,15 @@ local function separated_values_iterator(file, parameters) -- more. if not first or last == #buffer then local s = file:read(buffer_size) - -- if we read nothing from the file: - -- - and first is nil, then we found nothing. This will return nil. - -- - and last == #buffer, then the capture we found above is good. - if not s then return first, last, capture end + -- if we read nothing from the file... + if not s then + if first then + -- ...and last == #buffer, then the capture we found above is good. + return first - anchor_pos + 1, last - anchor_pos + 1, capture + else + return + end + end buffer = buffer..s else return first - anchor_pos + 1, last - anchor_pos + 1, capture