Skip to content

Commit 129b265

Browse files
committed
Initial skeleton of PATCH.LUA
1 parent 3efa029 commit 129b265

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

demo/xtra/PATCH.LUA

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env lua
2+
3+
local function patch(p)
4+
local pf, e = io.open(p)
5+
if not pf then print(e) os.exit(1) end
6+
for l in pf:lines() do
7+
local ls = l:sub(1, 1)
8+
if ls == "+" then
9+
if l:sub(2,4) == "++ " then
10+
--TODO: New file
11+
else
12+
--TODO: Add Line
13+
end
14+
elseif ls == '-' then
15+
if l:sub(2,4) == "-- " then
16+
--TODO: Old file
17+
else
18+
--TODO: Del Line
19+
end
20+
elseif ls == ' ' then
21+
--TODO: context line verification
22+
end
23+
end
24+
pf:close()
25+
end
26+
27+
if #arg < 1 then os.exit(1) end
28+
patch(arg[1], arg[2])

0 commit comments

Comments
 (0)