eggert@SM.UNISYS.COM (Paul Eggert) (11/06/88)
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);