@@ -28,14 +28,14 @@ local function diff_u(fn1,fn2)
2828 local l ,_ ,o = string.unpack (PF ,p ,(i - 1 )* ps + 1 )
2929 local f = assert (io.open (fn ," rb" ))f :seek (" set" ,o )
3030 local r = f :read (l )f :close ()return r end
31+ local function pfl (p ,s )print (p .. s :gsub (' \n $' ,' ' ):gsub (' \r $' ,' ' ))end
3132 local i ,j = 1 ,1 for _ ,p in ipairs (path )do
32- while i < p .x do io.write (" -" ,get (fn1 ,f1 ,i ))i = i + 1 end
33- while j < p .y do io.write (" +" ,get (fn2 ,f2 ,j ))j = j + 1 end
34- io.write (" " ,get (fn1 ,f1 ,i ))i ,j = i + 1 ,j + 1 end
35- local function nlc () if la then la = la :sub (- 1 )if la ~= ' \n ' and la ~= ' \r ' then print (" \n\\ No newline at end of file" )end end end
36- while i <= h do la = get (fn1 ,f1 ,i ,ps )io.write (" -" ,la )i = i + 1 end nlc ()
37- while j <= w do la = get (fn2 ,f2 ,j ,ps )io.write (" +" ,la )j = j + 1 end nlc ()
38- end
33+ while i < p .x do pfl (" -" ,get (fn1 ,f1 ,i ))i = i + 1 end
34+ while j < p .y do pfl (" +" ,get (fn2 ,f2 ,j ))j = j + 1 end
35+ pfl (" " ,get (fn1 ,f1 ,i ))i ,j = i + 1 ,j + 1 end
36+ local function nlc () if la then la = la :sub (- 1 )if la ~= ' \n ' and la ~= ' \r ' then print (" \\ No newline at end of file" )end end end
37+ while i <= h do la = get (fn1 ,f1 ,i ,ps )pfl (" -" ,la )i = i + 1 end nlc ()
38+ while j <= w do la = get (fn2 ,f2 ,j ,ps )pfl (" +" ,la )j = j + 1 end nlc ()end
3939if # arg < 2 or# arg % 2 ~= 0 then print (arg [- 1 ].. " " .. arg [0 ].. [[ old new...
4040
4141Compare differences between files, print them as unified context.
0 commit comments