Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: inserting a single dot line: patch --ed seems to generate incorrect results (unlike ed)

2 views
Skip to first unread message

Stepan Kasal

unread,
Jul 19, 2004, 5:46:25 AM7/19/04
to bug-gn...@gnu.org, Tobias Reif, egg...@twinsun.com, bug-...@gnu.org, cgab...@softwarelibero.org
Hello all,

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

diffutils-2.8.7-ed-optimize.patch

Tobias Reif

unread,
Jul 19, 2004, 6:34:10 AM7/19/04
to Stepan Kasal, egg...@twinsun.com, bug-...@gnu.org, bug-gn...@gnu.org, cgab...@softwarelibero.org
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: 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

Stepan Kasal

unread,
Jul 20, 2004, 5:08:36 AM7/20/04
to Tobias Reif, egg...@twinsun.com, bug-...@gnu.org, bug-gn...@gnu.org, cgab...@softwarelibero.org
Hello,

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


Paul Eggert

unread,
Jul 21, 2004, 4:59:17 AM7/21/04
to Stepan Kasal, bug-...@gnu.org, Tobias Reif, bug-gn...@gnu.org, cgab...@softwarelibero.org
At Mon, 19 Jul 2004 11:46:25 +0200, Stepan Kasal <ka...@ucw.cz> writes:

> 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.


0 new messages