@@ -26,8 +26,7 @@ local function patch(p)
2626 print (" Context: '" .. l :sub (2 ) .. " '" )
2727 elseif ls == ' @' then
2828 if l :sub (2 ,3 ) == " @ " then
29- -- TODO: Jump through file to when hunk starts
30- local function hunkData ()
29+ local function parseHunkHeader ()
3130 local function split (i ,d )
3231 local r = {}
3332 for m in (i .. d ):gmatch (" (.-)" .. d )do table.insert (r ,m )end
@@ -38,9 +37,14 @@ local function patch(p)
3837 if words [3 ] then new = split (words [3 ]," ," )end
3938 if old [1 ] then old [1 ]= old [1 ]:sub (2 )end
4039 if new [1 ] then new [1 ]= new [1 ]:sub (2 )end
41- return old [1 ],old [2 ]or " 1" ,new [1 ],new [2 ]or " 1"
40+ return {
41+ old = { start = tonumber (old [1 ]), lines = tonumber (old [2 ]) or 1 },
42+ new = { start = tonumber (new [1 ]), lines = tonumber (new [2 ]) or 1 }
43+ }
4244 end
43- local a ,b ,c ,d = hunkData ()print (" Hunk Header" ,a ,b ,c ,d )
45+ -- TODO: Something useful with this table
46+ local hunk = parseHunkHeader ()print (" Hunk Header" ,hunk .old .start ,hunk .old .count ,hunk .new .start ,hunk .new .lines )
47+ -- TODO: Jump through file to when hunk starts
4448 end
4549 end
4650 end
0 commit comments