🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Thu, 06 Jul 1989 01:04
GNU DIFF 1.7 exit status wrong if only trailing newlines differ
#97
Author: Paul Eggert
Date: Thu, 06 Jul 1989 01:04
30 lines
1306 bytes
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>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads