[gnu.utils.bug] GNU DIFF 1.7 exit status wrong if only trailing newlines differ

eggert@twinsun.com (Paul Eggert) (07/06/89)

Suppose two files whose last lines are nonempty differ only in that one lacks
a trailing newline after its last line.  Then GNU DIFF 1.7 exits with zero
status, meaning no differences.  It should exit with status 1, because the
files differ.  The following Bourne shell transcript illustrates the problem.

	$ echo x >/tmp/x
	$ tr -d '\012' </tmp/x >/tmp/y
	$ if diff /tmp/x /tmp/y; then echo same; else echo different; fi
	No newline at end of file /tmp/y
	same

The following patch to diff_2_files() fixes the problem.

*** OLD/analyze.c	Fri Feb 24 09:42:16 1989
--- analyze.c	Wed Jul  5 09:08:58 1989
***************
*** 793,797 ****
        free (e);
      }
  
!   return script ? 1 : 0;
  }
--- 793,797 ----
        free (e);
      }
  
!   return script  ||  filevec[0].missing_newline != filevec[1].missing_newline;
  }

-- Paul Eggert <eggert@twinsun.com>