Subject: bug#25427: strip-trailing-cr makes -q not be quick

From: Tom Vajzovic <[email-masked]>
Date: Thu, 12 Jan 2017 14:37:45 +0000

Hi,

I have diff aliased to 'diff -d --strip-trailing-cr'.

When I run 'diff -qs file1 file2' it takes a very long time to return
(minutes).

If I run without the -d it still takes a noticeable amount of time (a
second or two).

If I run without --strip-trailing-cr it takes next-to-no-time, whether
or not I specify -d.

These are two very large text files, but they differ within the first
few lines.

I suspect that it is calculating the whole diff internally and
discarding it when --strip-trailing-cr is given at the same time as -q.

Obviously I understand that by putting --strip-trailing-cr in an alias
I am requiring the whole file to be read and modified in memory, this
is fine.  The fact that -d has any effect though suggests that
once the line endings are processed the wrong algorithm is being
applied.  It doesn't need to run the diff algorithm, something almost
as simple as a strcmp could be used if -q is given, in which case -d
would have no effect.

Are there active developers working on diff that want to look at and
fix this?  I am a C programmer so would be happy to do it myself, but I
have never contributed to GNU tools so I might not do it the way you
would like.  I'd rather not spend time on it if you are likely to reject
it and have to re-write it yourselves anyway.

I'm using version 3.3 from Ubuntu.  Let me know if you want me to
reproduce from master.

Many thanks/best regards,

Tom Vajzovic