On Mon 2004-06-28 Tobias Reif wrote:
> $ diff --ed old new > diff.ed
> $ cat diff.ed
> 1a
> ..
> .
> s/.//
> a
> .
> $
>
> (the last two lines seem unnecessary, btw)
well, this result is quite logical, as each line which contais just a dot
is replaced by
..
.
s/.//
a
Anyway, you are right and we can optimized this out.
The appropriate patch to diffutils-2.8.7 is attached to this mail.
Paul, will you accept it?
Stepan
I don't understand what you mean here: for an appended line which contains
just a dot, the diff should contain
[line-number]a
..
.
s/.//
because
$ ed
a
foo
bar
.
%p
foo
bar
1a
..
.
%p
foo
..
bar
2s/.//
%p
foo
.
bar
Q
$
and (shorter, using current dot value)
$ ed
a
foo
bar
.
1a
..
.
s/.//
%p
foo
.
bar
Q
$
> Anyway, you are right and we can optimized this out.
OK
> The appropriate patch to diffutils-2.8.7 is attached to this mail.
Thanks!
Tobi
--
to
bi
as
re
if
I'll try to explain my previous explanation ;-)
On Mon, Jul 19, 2004 at 12:34:10PM +0200, Tobias Reif wrote:
> On Mon 2004-07-19 Stepan Kasal wrote:
> > On Mon 2004-06-28 Tobias Reif wrote:
> > > $ diff --ed old new > diff.ed
> > > $ cat diff.ed
> > > 1a
> > > ..
> > > .
> > > s/.//
> > > a
> > > .
> > > $
> > >
> > > (the last two lines seem unnecessary, btw)
> >
> > well, this result is quite logical, as each line which contais just a dot
> > is replaced by
> > ..
> > .
> > s/.//
> > a
>
> I don't understand what you mean here:
Imagine you have two files:
$ cat old
start
end
$ cat new
start
foo
.
bar
end
When you write an ed-style diff, at first you just forget about the dot
problem; ``diff -f'' still demonstrates this problem:
$ diff -f old new
a1
foo
.
bar
.
Tnen you recognize the problem. A general fix might be to replace the
unfortunate line ".\n" by four lines: "..\n.\ns/.//\na\n"
This yields:
$ diff -f old new
a1
foo
..
.
s/.//
a
bar
.
Unfortunately, if this attitude is mechanically applied to a text
which contains the just-a-dot line at its very end, the unnecesary
empty ``a'' command will be created.
Hope this makes my previous comment clear.
Stepan
> Anyway, you are right and we can optimized this out.
> The appropriate patch to diffutils-2.8.7 is attached to this mail.
>
> Paul, will you accept it?
Yes, it looks fine; thanks.