Commit f2d8543
authored
patch: parse 2-address append in ed-diff (briandfoy#962)
* When processing an "a" (append text) command in an ed-style diff, line number ranges are not parsed correctly
* If a range (e.g. "1,2") is given as a prefix to "a", the 2nd address ("2") is used as the target address
* Regular diff tools don't output "a" commands with 2 addresses
* ed-style diffs can be pasted from a previous ed editor session or typed manually, so having extra validation here is helpful
* To test this, I bypassed the code for running an external ed program
* I modified a diff generated by "diff -e", changing the "322a" command to "1,322a"... the file is patched successfully
%cat bad.diffe
1,322a
my $Maxlen = 1; # longest string for current directory
.
317,318d
113d
%perl patch -e ls bad.diffe
Hmm... Looks like an ed diff to me...
Patching file ls using Plan A...
Hunk briandfoy#1 succeeded at 113
Hunk briandfoy#2 succeeded at 317
Hunk briandfoy#3 succeeded at 322
done
%cmp ls ls21 parent 7e33d43 commit f2d8543
1 file changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
| 1000 | + | |
| 1001 | + | |
1000 | 1002 | | |
1001 | 1003 | | |
1002 | 1004 | | |
| |||
0 commit comments