Skip to content

Commit 3e89ae2

Browse files
committed
Added no newline at end of file support to PATCH.LUA
1 parent 6e56d8d commit 3e89ae2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

xtra/PATCH.LUA

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ local function patch(p)
4545
bf:close()
4646
end
4747

48-
for l in pf:lines() do
48+
local n=pf:read("*l")
49+
while n do
50+
local l=n n=pf:read("*l")
4951
local ls = l:sub(1, 1)
5052
if ls == "+" then
5153
if l:sub(2,4) == "++ " then
5254
--TODO: Just ignore this line?
5355
else
54-
if of then of:write(l:sub(2) .. '\n') ol = ol + 1 end
56+
if of then
57+
local nl = n and n:match("^\\ No newline at end of file")
58+
of:write(l:sub(2)..(nl and""or'\n')) ol = ol + 1
59+
end
5560
end
5661
elseif ls == '-' then
5762
if l:sub(2,4) == "-- " then

0 commit comments

Comments
 (0)