lexer could not cope with zero length file

This commit is contained in:
steve donovan 2011-06-21 18:30:57 +02:00
parent 4fd3c78388
commit 3ca03ea818
1 changed files with 5 additions and 1 deletions

View File

@ -154,7 +154,11 @@ function lexer.scan (s,matches,filter,options)
function lex () function lex ()
local i1,i2,idx,res1,res2,tok,pat,fun,capt local i1,i2,idx,res1,res2,tok,pat,fun,capt
local line = 1 local line = 1
if file then s = file:read()..'\n' end if file then
s = file:read()
if not s then return nil end -- empty file
s = s ..'\n'
end
local sz = #s local sz = #s
local idx = 1 local idx = 1
--print('sz',sz) --print('sz',sz)