Skip to content

Commit f65bc6c

Browse files
committed
Initial implementation of helper function setPatchFile.
1 parent 8aafcd8 commit f65bc6c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

xtra/PATCH.LUA

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
local function patch(p)
44
local pf, e = io.open(p)
5+
local ol, bl, cp, of, bf = 0, 0
56
if not pf then print(e) os.exit(1) end
67

78
local function parseFileName(l)
@@ -15,6 +16,23 @@ local function patch(p)
1516
end
1617
end
1718

19+
local function setPatchFile(f)
20+
local o, b
21+
local function abort()
22+
print(e)
23+
if o then o:close() end
24+
if b then b:close() end
25+
return false
26+
end
27+
o, e = io.open(f)if not o then return abort end
28+
b, e = io.open(f..".orig", "w")if not b then return abort end
29+
for m in o:lines() do b:write(m..'\n') end o:close() b:close()
30+
o, e = io.open(f, "w") if not o then return abort end
31+
b, e = io.open(f..".orig") if not b then return abort end
32+
if of then of:close() end if bf then bf:close() end of = o bf = b
33+
return true
34+
end
35+
1836
for l in pf:lines() do
1937
local ls = l:sub(1, 1)
2038
if ls == "+" then

0 commit comments

Comments
 (0)