bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inserting a single dot line: patch --ed seems to generate incorrect


From: Stepan Kasal
Subject: Re: inserting a single dot line: patch --ed seems to generate incorrect results (unlike ed)
Date: Tue, 20 Jul 2004 11:08:36 +0200
User-agent: Mutt/1.4.1i

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]