aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormpeterv <mpeterval@gmail.com>2015-10-17 11:41:26 +0300
committermpeterv <mpeterval@gmail.com>2015-10-17 11:41:26 +0300
commitcfc253ffb580bd30cb004ad3bf4e72b3314791e0 (patch)
tree28a8a1fd928624c778ca8d2a00610a44c46fafc7
parent8fe1bbd627bae2da2d1b7d8e376a35ebf5626d2e (diff)
downloadluarocks-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.
-rw-r--r--src/luarocks/tools/patch.lua7
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