Skip to content

Commit 1f18daa

Browse files
committed
Expanded WR() function in preparation for patched file copy code.
1 parent 0c1abeb commit 1f18daa

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

xtra/PATCH.LUA

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,26 @@ local function patch(pf)
1616
if wf then wf:close()end if rf then rf:close()end wf,wl,rf,rl,h=w,0,r,0,nil return true end
1717
local function R()rl=rl+1 return rf:read("*l")end
1818
local function W(s)wl=wl+1 return wf:write(s)end
19-
local function WR()if h then if(h.o.l>0 and h.o.s>0)and(h.o.l~=rl-(h.o.s-1)or h.n.l~=wl-(h.n.s-1))then print(M)os.exit(1)else print(P)end end
20-
if wf then local r=R()while r do W(r..'\n')r=R()end wf:close()wf,wl=nil,0 end rf:close()rf,rl,h=nil,0,nil end --TODO: Write original to backup here
19+
local function WR()
20+
if h then
21+
if(h.o.l>0 and h.o.s>0)and(h.o.l~=rl-(h.o.s-1)or h.n.l~=wl-(h.n.s-1))then
22+
print(M)os.exit(1)
23+
else
24+
print(P)
25+
end
26+
end
27+
if rf and wf then
28+
local r=R()
29+
while r do
30+
W(r..'\n')r=R()
31+
end
32+
--TODO: Write original to a backup here if it differs from the backup
33+
--TODO: reopen rf with write permissions and copy wf content to it
34+
wf:close() --TODO: close and nil rf here to
35+
wf,wl=nil,0
36+
end
37+
rf:close()rf,rl,h=nil,0,nil
38+
end
2139
local n=pf:read("*l")while n do local l,f=n n=pf:read("*l")f=l:sub(1,1)if f=='+'then
2240
if l:sub(2,4)~="++ "then W(l:sub(2)..(n and n:match("^\\ No newline at end of file")and""or'\n'))end
2341
elseif f=='-'then

0 commit comments

Comments
 (0)