Skip to content

Commit f87339e

Browse files
committed
Write the remainder of a file after all hunks have been processed.
1 parent b464c86 commit f87339e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

xtra/PATCH.LUA

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ local function patch(p)
3333
return true
3434
end
3535

36+
local function writeRemainder()
37+
if of then
38+
local rest = bf:read("*l")
39+
while rest do
40+
of:write(rest .. '\n')
41+
rest = bf:read("*l")
42+
end
43+
of:close()
44+
end
45+
bf:close()
46+
end
47+
3648
for l in pf:lines() do
3749
local ls = l:sub(1, 1)
3850
if ls == "+" then
@@ -45,6 +57,7 @@ local function patch(p)
4557
if l:sub(2,4) == "-- " then
4658
local filename = parseFileName(l)
4759
if setPatchFile(filename) then cp = filename end
60+
if bf then writeRemainder() end
4861
else
4962
local cmp = bf:read("*l") bl = bl + 1
5063
if cmp ~= l:sub(2) then
@@ -99,6 +112,7 @@ local function patch(p)
99112
end
100113
end
101114
pf:close()
115+
if bf then writeRemainder() end
102116
end
103117

104118
if #arg < 1 then os.exit(1) end

0 commit comments

Comments
 (0)