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

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

Re: Possible bug in diff?


From: Stepan Kasal
Subject: Re: Possible bug in diff?
Date: Sat, 23 Oct 2004 17:28:34 +0200
User-agent: Mutt/1.4.1i

Hello,

thank you for your bug report.

On Sat, Oct 23, 2004 at 01:45:48AM -0400, B Traver wrote:
> routine to patch context files works perfectly _except_ that it doesn't
> know how to handle this situation:
> 
> --- 541,546 ----
> ***************

This output is correct.  Your understanding of the context diff is correct,
with one small mistake:

> The otherwise consistent pattern of the diff file is that after a pair
> of numbers you're given the lines for the range specified (for file a or
> file b, according to whether they're preceded by "***" or "---").

Yes, but lines for that range are omitted, if there are only unchanged
lines.  In other words, if the chunk only deletes lines, the second part
is omitted, and if the chunk only adds lines, the first  part is omitted.

Thus the following:

***************
*** 540,546 ****

  /* Is there space for something L big in the buffer? */
  #define chksize(l)  if ((l) > ofre) { \
-       long olen = obufout - obuf; \
        erealloc(obuf, char *, osiz * 2, "format_tree"); \
        obufout = obuf + olen; \
        ofre += osiz; \
--- 540,545 ----
***************

is the same as if it were:

***************
*** 540,546 ****

  /* Is there space for something L big in the buffer? */
  #define chksize(l)  if ((l) > ofre) { \
-       long olen = obufout - obuf; \
        erealloc(obuf, char *, osiz * 2, "format_tree"); \
        obufout = obuf + olen; \
        ofre += osiz; \
--- 540,545 ----

  /* Is there space for something L big in the buffer? */
  #define chksize(l)  if ((l) > ofre) { \
        erealloc(obuf, char *, osiz * 2, "format_tree"); \
        obufout = obuf + olen; \
        ofre += osiz; \
***************

and you can also encounter this:

***************
*** 540,545 ****
--- 540,546 ----

  /* Is there space for something L big in the buffer? */
  #define chksize(l)  if ((l) > ofre) { \
+       long olen = obufout - obuf; \
        erealloc(obuf, char *, osiz * 2, "format_tree"); \
        obufout = obuf + olen; \
        ofre += osiz; \
***************

As you can see, it won't bi difficult to fix your program.

Have a nice day,
        Stepan Kasal




reply via email to

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