lexer would hang on an empty file
This commit is contained in:
parent
2e016bbe65
commit
d864e49f47
|
@ -156,11 +156,12 @@ function lexer.scan (s,matches,filter,options)
|
|||
local line = 1
|
||||
if file then
|
||||
s = file:read()
|
||||
if not s then return nil end -- empty file
|
||||
if not s or s == '' then return nil end -- empty file
|
||||
s = s ..'\n'
|
||||
end
|
||||
local sz = #s
|
||||
local idx = 1
|
||||
if sz == 0 then return nil end -- empty file
|
||||
--print('sz',sz)
|
||||
while true do
|
||||
for _,m in ipairs(matches) do
|
||||
|
|
|
@ -39,6 +39,7 @@ function prettify.lua (file)
|
|||
|
||||
local tok = lexer.lua(code,{},{})
|
||||
local t,val = tok()
|
||||
if not t then return nil,"empty file" end
|
||||
while t do
|
||||
val = escape(val)
|
||||
if spans[t] then
|
||||
|
|
Loading…
Reference in New Issue