11local function diff_u (fn1 ,fn2 )
22 local function open (fn ) local f , e = io.open (fn ) if not f then print (e ) os.exit (1 ) end return f end
3- local f1 , f2 , pre , add , del , post , x , y , h , l1 , l2 = open (fn1 ), open (fn2 ), {}, {}, {}, 0 , 0 , 0
3+ local f1 , f2 , pre , add , del , p1 , p2 , x , y , h , l1 , l2 = open (fn1 ), open (fn2 ), {}, {}, {}, 0 , 0 , 0 , 0
44 local buf = {add = 0 , del = 0 , line = {}}
55 local function flush_pre ()
66 if not h then print (" --- " .. fn1 .. " \n +++ " .. fn2 ) h = true end
@@ -24,21 +24,21 @@ local function diff_u(fn1,fn2)
2424 local function diagonal ()
2525 flush_hunk ()
2626 if # pre >= 3 then table.remove (pre , 1 ) end
27- if # pre <= 0 and post > 0 then
28- table.insert (buf .line , " " .. l2 ) post = post - 1
29- if post == 0 then flush_buf () end
27+ if # pre <= 0 and p1 > 0 then
28+ table.insert (buf .line , " " .. l2 ) p1 = p1 - 1
29+ if p1 == 0 then flush_buf () end
3030 else
3131 table.insert (pre , l2 )
3232 end
3333 x , y , l1 , l2 = x + 1 , y + 1 , f1 :read (" *l" ), f2 :read (" *l" )
3434 end
3535 local function right ()
36- flush_pre () post = 3
36+ flush_pre () p1 = 3
3737 table.insert (del , l1 )
3838 l1 = f1 :read (" *l" )
3939 end
4040 local function down ()
41- flush_pre () post = 3
41+ flush_pre () p1 = 3
4242 table.insert (add , l2 )
4343 l2 = f2 :read (" *l" )
4444 end
0 commit comments