-
Couldn't load subscription status.
- Fork 54
patch: correctly parse two-address append in ed-diff #962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mknos
commented
Feb 25, 2025
- When processing an append ("a") 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 so this is a corner case
- 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
* 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 ls2
Pull Request Test Coverage Report for Build 13511545565Details
💛 - Coveralls |
|
SEE ALSO: I submitted this other bug report because GNU patch seemed to fail when processing my test input file with [valid] ed command "1,322a". See how test cases for this project can help the wider Loonix world... |
|
changes: handle line range correctly for append operations |