Skip to content

Commit 2b26b55

Browse files
committed
Initial implementation of finding the next block of matches.
1 parent 2868be8 commit 2b26b55

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

xtra/DIFF.LUA

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@ local function diff_u(fn1,fn2)
1717
h,w,m=#f1//ps,#f2//ps,{}
1818
for x=1,h do
1919
local b={}
20+
local function inList(v)for k,p in ipairs(b)do if v==p then return k end end end
2021
for y=1,w do if cmp(x,y)then table.insert(b,y)end end
2122
if #m>0 and m[#m].x+m[#m].l==x then
22-
local function inList(v)for k,p in ipairs(b)do if v==p then return k end end end
2323
if inList(m[#m].y+m[#m].l) then
2424
m[#m].l=m[#m].l+1
2525
else
2626
--TODO: Know where to run the next block
27+
local n=inList(m[#m].y+m[#m].l)
28+
if n then
29+
table.insert(m,{y=b[n],x=x,l=1})
30+
end
2731
end
2832
else
29-
table.insert(m,{y=b[1],x=x,l=1})
33+
if #b>0 then
34+
local n=#m>0 and inList(m[#m].y+m[#m].l) or 1
35+
table.insert(m,{y=b[n],x=x,l=1})
36+
end
3037
end
3138
end
3239
local function get(fn,p,x)local l,_,o,f,r=string.unpack(PF,p,(x-1)*ps+1)f=assert(io.open(fn,"rb"))f:seek(S,o)r=f:read(l)f:close()return r end

0 commit comments

Comments
 (0)