@@ -15,7 +15,8 @@ local function patch(p)
1515 o ,e = io.open (f ," w" )if not o then return abort ()end
1616 b ,e = io.open (f .. " .orig" )if not b then return abort ()end
1717 if of then of :close ()end if bf then bf :close ()end of ,ol ,bf ,bl ,h = o ,0 ,b ,0 ,nil return true end
18- local function writeRemainder ()if of then local rest = bf :read (" *l" )while rest do of :write (rest .. ' \n ' )rest = bf :read (" *l" )end of :close ()of ,ol = nil ,0 end bf :close ()bf ,bl ,h = nil ,0 ,nil end
18+ local function writeRemainder ()if h then if h .o .l ~= bl - (h .o .s - 1 )or h .n .l ~= ol - (h .n .s - 1 )then print (M )os.exit (1 )else print (" patched" )end end
19+ if of then local rest = bf :read (" *l" )while rest do of :write (rest .. ' \n ' )rest = bf :read (" *l" )end of :close ()of ,ol = nil ,0 end bf :close ()bf ,bl ,h = nil ,0 ,nil end
1920 local n = pf :read (" *l" )while n do
2021 local l ,ls = n n = pf :read (" *l" )ls = l :sub (1 ,1 )
2122 if ls == ' +' then
@@ -41,7 +42,7 @@ local function patch(p)
4142 for _ = 1 ,s do
4243 local ctx = bf :read (" *l" )if not ctx then print (M )os.exit (1 )end
4344 bl = bl + 1 if of then of :write (ctx .. " \n " )ol = ol + 1 end end end end end end
44- pf :close ()if h then print ( " patched " ) end if bf then writeRemainder ()end end
45+ pf :close ()if bf then writeRemainder ()end end
4546if # arg < 1 then print (arg [- 1 ].. " " .. arg [0 ].. [[ diff...
4647
4748Patch a unified difference file]] )os.exit (1 )end patch (arg [1 ])
0 commit comments