Hi! I run some test-cases for patch(1p) I created on your implementation and found two cases where it fails.
I have attached four files. If you run diff -C0 old-1 new-1 | patch -o - old-1 diff -C0 old-2 new-2 | patch -o - old-2 you will see that both runs output patch: **** replacement text or line numbers mangled in hunk at line 4 There is nothing wrong in the output of diff. This error only happens if -C0 is used, -c, -u -C1, -U0, -U1, and no flags works just fine. Sincerely, Mattias Andrée
new-1
Description: Binary data
new-2
Description: Binary data
old-1
Description: Binary data
old-2
Description: Binary data
pgpP4kPlRlz9N.pgp
Description: OpenPGP digital signature