fix 'off by one' error for emtpy scripts.

This commit is contained in:
tdijck 2015-03-25 13:10:27 -07:00 committed by Tom van Dijck
parent 1738c13263
commit 9b2c8c3c9a

View File

@ -49,20 +49,24 @@
local max = 4096
local start = 1
local len = contents:len()
while start <= len do
local n = len - start
if n > max then n = max end
local finish = start + n
if len > 0 then
while start <= len do
local n = len - start
if n > max then n = max end
local finish = start + n
-- make sure I don't cut an escape sequence
while contents:sub(finish, finish) == "\\" do
finish = finish - 1
-- make sure I don't cut an escape sequence
while contents:sub(finish, finish) == "\\" do
finish = finish - 1
end
local s = contents:sub(start, finish)
table.insert(result, "\t\"" .. s .. iif(finish < len, '"', '",'))
start = finish + 1
end
local s = contents:sub(start, finish)
table.insert(result, "\t\"" .. s .. iif(finish < len, '"', '",'))
start = finish + 1
else
table.insert(result, "\t\"\",")
end
table.insert(result, "")