Skip to content

Commit 3f656ab

Browse files
committed
Added l variable to loop to get the last entry.
1 parent a1fdaa4 commit 3f656ab

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

xtra/DIFF.LUA

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,20 @@ local function diff_u(fn1,fn2)
1515
local function li(fn,o,l)f,e=io.open(fn,"rb")if not f then return nil,e end f:seek(S,o)local g=f:read(l)f:close()return g end
1616
b1,e,b2=li(fn1,o1,l1)if not b1 then error(e)end b2,e=li(fn2,o2,l2)if not b2 then error(e)end return b1==b2 end
1717
h,w,m=#f1//ps,#f2//ps,{}
18-
local ly,n=1
18+
local ly,l,n=1
1919
for x=1,h do
2020
local b={}
2121
local function inList(v)for k,p in ipairs(b)do if v==p then return k end end end
2222
for y=ly,w do if cmp(x,y)then table.insert(b,y)end end
2323
if #b>0 then
2424
if #m>0 then
25-
if m[#m].x+m[#m].l==x then
26-
n=inList(m[#m].y+m[#m].l)
27-
if n then m[#m].l=m[#m].l+1 end
25+
l=m[#m]
26+
if l.x+l.l==x then
27+
n=inList(l.y+l.l)
28+
if n then l.l=l.l+1 end
2829
else
2930
--TODO: calculate how far ahead we should be from last and current x and y
30-
n=inList(m[#m].y+m[#m].l)
31+
n=inList(l.y+l.l)
3132
if n then table.insert(m,{y=b[n],x=x,l=1}) end
3233
end
3334
else

0 commit comments

Comments
 (0)