[Top][All Lists]

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

Re: diff and dos line endings

From: Toshio
Subject: Re: diff and dos line endings
Date: Sat, 09 Apr 2005 14:14:32 -0400

On Sat, 2005-04-09 at 18:18 +0300, Eli Zaretskii wrote:
> > From: Toshio <address@hidden>
> > Date: Fri, 08 Apr 2005 19:54:33 -0400
> > 
> > While working with quilt on a project which used dos line endings, I
> > found a bug with the way diff --show-c-function works.
> > 
> > If you do a diff -u --show-c-function test.c.bak test.c with the
> > included files, you'll see that diff -u generates the following line in
> > its output::
> >   @@ -4,5 +4,5 @@ int tester()^M
> What port of Diff is that?  It sounds like a bug in that port: Diff
> should never by default output any ^M characters.
Well -- I just tried with vanilla diffutils 2.8.1 and 2.8.7.  Both of
them produce the above output.  So if there shouldn't be any ^M
characters in the output there's a bug in diff.

> > The included diffutils-2.8.1-funclf.patch includes a small change to the
> > characters that can stop the detection of functions for the --show-c-
> > function that make diff produce output with only a \n at the end of the
> > line.
> Even if the reason for the patch is accepted as valid, I think the
> patch itself is not entirely correct: it should only treat \r
> characters like a newline if \n is immediately followed by \n.
> Otherwise, you will get bad results for single \r characters in the
> middle of a line.
Note that that would only be in the middle of a C function definition
line when using --show-c-function.  But I see your point.  New patch
addressing this issue is attached.

OTOH, I just tried patch-2.6.9 after reading Andreas comment.  It looks
like patch-2.5.4 chokes on this type of output but patch-2.5.9 is fine.
If diff really shouldn't be creating this type of output, then I'd say
this still needs to be fixed.  Otherwise, I suppose I'll have to look at
backporting a fix for patch.

> That said, I'm not the official Diffutils maintainer, so please wait
> for Paul Eggert to give the definitive response.

I shall await.


toshio \ 25th March, 1999:  Cold rain in Georgia.  Blustery blowing wind.
 @tiki  \ Freezing fingers and tired body.  Hiking on because the shelters
 -lounge \ are filled with other hikers.
 .com     \__________Life is miserable -- Life is grand!_______ GA->ME 1999
--- diffutils-2.8.1/src/context.c.lf    2005-04-09 13:48:17.000000000 -0400
+++ diffutils-2.8.1/src/context.c       2005-04-09 13:54:54.370238932 -0400
@@ -144,6 +144,8 @@
   putc (' ', out);
   for (i = 0; i < 40 && function[i] != '\n'; i++)
+  if (function[i - 1] == '\r')
+    i--;
   fwrite (function, 1, i, out);

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

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