Skip to content

Commit 5b7d1c5

Browse files
committed
Fixed WriteRemaining(WR) not honoring when a file doesn't end in a new line.
1 parent 1cadaee commit 5b7d1c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

xtra/PATCH.LUA

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ local function patch(pf)
1111
local function RW(x)x:seek("set",0)end
1212
local function W(s)wl=wl+1 return wf:write(s)end
1313
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
14-
if rf and wf then local r=R()while r do W(r..'\n')r=R()end
15-
local function B()local n,f,l=cp:match("(.*)%.[^%.]*")..".bak"f=io.open(n,"a+")
14+
if rf and wf then local r,f,l=R()while r do W(r..'\n')r=R()end
15+
local function B()local n=cp:match("(.*)%.[^%.]*")..".bak"f=io.open(n,"a+")
1616
local function C()RW(f)RW(rf)repeat r,l=R(),rf:read("*l")if r~=l then return 1 end until not r or not l end
1717
if f:seek()~=rf:seek()or C()then RW(rf)f:close()f=assert(io.open(n,"w"))r=R()repeat f:write(r..'\n')r=R()until not r end end
18-
B()rf:close()rf=assert(io.open(cp,"w"))RW(wf)r=wf:read("*l")repeat rf:write(r.."\n")r=wf:read("*l")until not r wf:close()wf,wl=nil,0 end
18+
B()rf:close()rf=assert(io.open(cp,"w"))f,l=0,wf:seek("end")RW(wf)r=wf:read("*l")repeat rf:write(r..(f+#r<l and"\n"or""))f=f+#r r=wf:read("*l")until not r wf:close()wf,wl=nil,0 end
1919
rf:close()rf,rl,h=nil,0,nil end
2020
local n=pf:read("*l")while n do local l,f=n n=pf:read("*l")f=l:sub(1,1)if f=='+'then
2121
if l:sub(2,4)~="++ "then W(l:sub(2)..(n and n:match("^\\ No newline at end of file")and""or'\n'))end

0 commit comments

Comments
 (0)