[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
diff(1) gnu -L compatibility
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: diff(1) gnu -L compatibility
- From: YAMAMOTO Takashi <yamt_(_at_)_mwd_(_dot_)_biglobe_(_dot_)_ne_(_dot_)_jp>
- Date: Thu, 09 Dec 2004 03:19:58 +0900
hi,
the attached patch is to make diff(1) more compatible with the gnu version.
namely, if -L is specified twice, use it for the second filename.
this feature seems to be used by subversion.
YAMAMOTO Takashi
Index: diff.1
===================================================================
RCS file: /cvs/src/usr.bin/diff/diff.1,v
retrieving revision 1.26
diff -u -p -r1.26 diff.1
--- diff.1 20 Jun 2004 18:47:45 -0000 1.26
+++ diff.1 8 Dec 2004 18:14:25 -0000
@@ -223,7 +223,8 @@ after all text file differences are repo
.It Fl L Ar label
Print
.Ar label
-instead of the first file name and time in the context or unified diff header.
+instead of the first (and second, if this options is specified twice)
+file name and time in the context or unified diff header.
.It Fl p
With unified and context diffs, show with each change
the first 40 characters of the last line before the context beginning
Index: diff.c
===================================================================
RCS file: /cvs/src/usr.bin/diff/diff.c,v
retrieving revision 1.47
diff -u -p -r1.47 diff.c
--- diff.c 7 Dec 2004 11:53:29 -0000 1.47
+++ diff.c 8 Dec 2004 18:14:25 -0000
@@ -43,7 +43,7 @@ static const char rcsid[] = "$OpenBSD: d
int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
int sflag, tflag, Tflag, wflag;
int format, context, status;
-char *start, *ifdefname, *diffargs, *label, *ignore_pats;
+char *start, *ifdefname, *diffargs, *label1, *label2, *ignore_pats;
struct stat stb1, stb2;
struct excludes *excludes_list;
regex_t ignore_re;
@@ -149,7 +149,12 @@ main(int argc, char **argv)
iflag = 1;
break;
case 'L':
- label = optarg;
+ if (label1 == NULL)
+ label1 = optarg;
+ else if (label2 == NULL)
+ label2 = optarg;
+ else
+ usage();
break;
case 'l':
lflag = 1;
Index: diff.h
===================================================================
RCS file: /cvs/src/usr.bin/diff/diff.h,v
retrieving revision 1.28
diff -u -p -r1.28 diff.h
--- diff.h 20 Jun 2004 18:47:45 -0000 1.28
+++ diff.h 8 Dec 2004 18:14:25 -0000
@@ -76,7 +76,7 @@ struct excludes {
extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
sflag, tflag, Tflag, wflag;
extern int format, context, status;
-extern char *start, *ifdefname, *diffargs, *label, *ignore_pats;
+extern char *start, *ifdefname, *diffargs, *label1, *label2, *ignore_pats;
extern struct stat stb1, stb2;
extern struct excludes *excludes_list;
extern regex_t ignore_re;
Index: diffreg.c
===================================================================
RCS file: /cvs/src/usr.bin/diff/diffreg.c,v
retrieving revision 1.60
diff -u -p -r1.60 diffreg.c
--- diffreg.c 27 Nov 2004 19:16:25 -0000 1.60
+++ diffreg.c 8 Dec 2004 18:14:26 -0000
@@ -1048,16 +1048,22 @@ proceed:
/*
* Print the context/unidiff header first time through.
*/
- if (label != NULL)
+ if (label1 != NULL)
printf("%s %s\n",
- format == D_CONTEXT ? "***" : "---", label);
+ format == D_CONTEXT ? "***" : "---",
+ label1);
else
printf("%s %s\t%s",
format == D_CONTEXT ? "***" : "---", file1,
ctime(&stb1.st_mtime));
- printf("%s %s\t%s",
- format == D_CONTEXT ? "---" : "+++", file2,
- ctime(&stb2.st_mtime));
+ if (label2 != NULL)
+ printf("%s %s\n",
+ format == D_CONTEXT ? "---" : "+++",
+ label2);
+ else
+ printf("%s %s\t%s",
+ format == D_CONTEXT ? "---" : "+++", file2,
+ ctime(&stb2.st_mtime));
anychange = 1;
} else if (a > context_vec_ptr->b + (2 * context) + 1 &&
c > context_vec_ptr->d + (2 * context) + 1) {
Visit your host, monkey.org