Skip to content

Commit ea534cf

Browse files
committed
Handle multiple diff files at once in PATCH.LUA
1 parent d366d8a commit ea534cf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

xtra/PATCH.LUA

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env lua
22

33
M="malformed"
4-
local function patch(p)
5-
local pf,e=io.open(p)local ol,bl,cp,of,bf,h=0,0
6-
if not pf then print(e)os.exit(1)end
4+
local function patch(pf)
5+
local ol,bl,cp,of,bf,h,e=0,0
76
local function parseFileName(l)local first=l:sub(5,5)
87
if first=='"'or first=="'"then return l:match(first.."([^"..first.."]+)"..first,5)
98
else local words={}for v in string.gmatch(l,"%S+")do table.insert(words,v)end return words[2]end end
@@ -42,7 +41,8 @@ local function patch(p)
4241
for _=1,s do
4342
local ctx=bf:read("*l")if not ctx then print(M)os.exit(1)end
4443
bl=bl+1 if of then of:write(ctx.."\n")ol=ol+1 end end end end end end
45-
pf:close()if bf then writeRemainder()end end
44+
if bf then writeRemainder()end end
4645
if #arg<1 then print(arg[-1].." "..arg[0]..[[ diff...
4746
48-
Patch a unified difference file]])os.exit(1)end patch(arg[1])
47+
Patch unified difference file(s)]])os.exit(1)end
48+
for _,a in ipairs(arg) do local f,e=io.open(a) if f then patch(f)f:close()else print(e)end end

0 commit comments

Comments
 (0)