🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1403

GNU "diff dir path/file" should read dir/file, not dir/path/file.

#1403
From: 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);
  
Technical Details
Message-ID: <8811052117.AA16354@poi.sm.unisys.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!SM.UNISYS.COM!eggert

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!SM.UNISYS.COM!eggert
From: eggert@SM.UNISYS.COM (Paul Eggert)
Newsgroups: gnu.utils.bug
Subject: GNU "diff dir path/file" should read dir/file, not dir/path/file.
Message-ID: <8811052117.AA16354@poi.sm.unisys.com>
Date: 5 Nov 88 21:17:18 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 35