🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Sat, 05 Nov 1988 21:17
GNU "diff dir path/file" should read dir/file, not dir/path/file.
#1403
Author: Paul Eggert
Date: Sat, 05 Nov 1988 21:17
35 lines
1745 bytes
Consider the following scenario with GNU diff 1.4 (SunOS 4.0 + Sun-3/60):

	% mkdir a b 
	% touch a/f b/f 
	% diff a b/f 
	diff: a/b/f: No such file or directory

GNU diff tries to compare a/b/f to b/f.  Instead, it should be comparing
a/f to b/f.  Here is a fix (uglified to preserve line numbers):

*** diff1.4/diff.c	Sat Nov  5 13:13:14 1988
--- diffnew/diff.c	Sat Nov  5 13:08:23 1988
***************
*** 462,471 ****
  
        /* If only one is a directory, and it was specified in the command line,
! 	 use the file in that dir whose name matches the other file.  */
  
        int dir_arg = (inf[0].dir_p ? 0 : 1);
        int fnm_arg = (inf[0].dir_p ? 1 : 0);
!       char *filename = concat (inf[dir_arg].name, "/", inf[fnm_arg].name);
! 
        inf[dir_arg].desc = open (filename, O_RDONLY, 0);
  
--- 462,471 ----
  
        /* If only one is a directory, and it was specified in the command line,
! 	 use the file in that dir whose basename matches the other file's.  */
  
        int dir_arg = (inf[0].dir_p ? 0 : 1);
        int fnm_arg = (inf[0].dir_p ? 1 : 0);
!       extern char *rindex();  char *p = rindex (inf[fnm_arg].name, '/');
!       char *filename = concat (inf[dir_arg].name,  "/",  p ? p+1 : inf[fnm_arg].name);
        inf[dir_arg].desc = open (filename, O_RDONLY, 0);
  
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