diff options
| author | mpeterv <mpeterval@gmail.com> | 2015-10-17 11:41:26 +0300 |
|---|---|---|
| committer | mpeterv <mpeterval@gmail.com> | 2015-10-17 11:41:26 +0300 |
| commit | cfc253ffb580bd30cb004ad3bf4e72b3314791e0 (patch) | |
| tree | 28a8a1fd928624c778ca8d2a00610a44c46fafc7 /src | |
| parent | 8fe1bbd627bae2da2d1b7d8e376a35ebf5626d2e (diff) | |
| download | luarocks-cfc253ffb580bd30cb004ad3bf4e72b3314791e0.tar.gz luarocks-cfc253ffb580bd30cb004ad3bf4e72b3314791e0.tar.bz2 luarocks-cfc253ffb580bd30cb004ad3bf4e72b3314791e0.zip | |
Fix empty line handling in patch.lua
Interpret empty lines in hunk bodies as empty context lines, that is,
add a space to them. This is consistent with command-line patch tool
behaviour.
Fixes #434.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/tools/patch.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/luarocks/tools/patch.lua b/src/luarocks/tools/patch.lua index b53bad61..9e5074ad 100644 --- a/src/luarocks/tools/patch.lua +++ b/src/luarocks/tools/patch.lua | |||
| @@ -200,8 +200,13 @@ function patch.read_patch(filename, data) | |||
| 200 | if state == 'hunkbody' then | 200 | if state == 'hunkbody' then |
| 201 | -- skip hunkskip and hunkbody code until definition of hunkhead read | 201 | -- skip hunkskip and hunkbody code until definition of hunkhead read |
| 202 | 202 | ||
| 203 | if line:match"^[\r\n]*$" then | ||
| 204 | -- prepend space to empty lines to interpret them as context properly | ||
| 205 | line = " " .. line | ||
| 206 | end | ||
| 207 | |||
| 203 | -- process line first | 208 | -- process line first |
| 204 | if line:match"^[- +\\]" or line:match"^[\r\n]*$" then | 209 | if line:match"^[- +\\]" then |
| 205 | -- gather stats about line endings | 210 | -- gather stats about line endings |
| 206 | local he = files.hunkends[nextfileno] | 211 | local he = files.hunkends[nextfileno] |
| 207 | if endswith(line, "\r\n") then | 212 | if endswith(line, "\r\n") then |
