CVSROOT:        /cvs
Module name:    src
Changes by:     nat...@cvs.openbsd.org  2016/03/01 13:57:35

Modified files:
        usr.bin/diff   : diffreg.c 

Log message:
Rectify line numbers for s/.// commands in ed-style diffs.

When diff encounters a line that consists of a single dot, it emits two
dots instead, stops the current command and emits a substitute command
to replace the double dot with a single one. Then it restarts the
(original) command if necessary and inserts further lines. This is done
because a single dot on a line does have special meaning in ed. (It
stops text insertion.)

Following issues are fixed by this commit.

- The line number for the substitute command should be the number of the
most recently inserted line. diff instead uses the number of the first
inserted line of the current hunk. The first character of that line is
removed when applying the diff, while the superfluous dot is not.

- The line number of the restarted command is not adjusted for the
number of lines already inserted, resulting in the reordering of lines..

- When there is a bare dot in the replacement text of a change command,
too many lines are deleted, because a second change command is emitted.
An append command should be emitted instead, because the target lines
have already been removed by the first change command.

tweaks and ok stefan@

Reply via email to