Subject: Fix for diff -ZE behaviour

From: felix <[email-masked]>
Date: Mon, 02 Mar 2020 08:29:57 +0000

Hello,

While combing through a collection of files, I noticed that whenever I 
called diff with both --ignore-trailing-space and 
--ignore-tab-expansion, the latter option was seemingly ignored. 
Initially I was worried that combining them was’t supported at all, 
even though the documentation suggested nothing of the sort. So I dug 
into the source code to see whether this was a feature omission or a 
bug. Half an hour later, I had a patch ready. Attached.

I don’t believe the patch needs copyright assignment, given that it 
changes just two lines and adds one. Though I figure writing some tests 
to cover this case is in order, which I did not do.

—f

Index: diffutils-3.7/src/util.c
===================================================================
--- diffutils-3.7.orig/src/util.c
+++ diffutils-3.7/src/util.c
@@ -1074,7 +1074,7 @@ lines_differ (char const *s1, char const
 		      while ((c = *p) != '\n' && isspace (c))
 			++p;
 		      if (c != '\n')
-			break;
+			goto not_eol;
 		    }
 		  if (c2 != '\n')
 		    {
@@ -1082,11 +1082,12 @@ lines_differ (char const *s1, char const
 		      while ((c = *p) != '\n' && isspace (c))
 			++p;
 		      if (c != '\n')
-			break;
+			goto not_eol;
 		    }
 		  /* Both lines have nothing but whitespace left.  */
 		  return false;
 		}
+	    not_eol:
 	      if (ignore_white_space == IGNORE_TRAILING_SPACE)
 		break;
 	      FALLTHROUGH;