diff options
-rw-r--r-- | usr.bin/diff/diff.1 | 5 | ||||
-rw-r--r-- | usr.bin/diff/diff.c | 13 | ||||
-rw-r--r-- | usr.bin/diff/diff.h | 4 | ||||
-rw-r--r-- | usr.bin/diff/diffreg.c | 33 |
4 files changed, 35 insertions, 20 deletions
diff --git a/usr.bin/diff/diff.1 b/usr.bin/diff/diff.1 index 48668dfd229..b14ca7d5519 100644 --- a/usr.bin/diff/diff.1 +++ b/usr.bin/diff/diff.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: diff.1,v 1.26 2004/06/20 18:47:45 otto Exp $ +.\" $OpenBSD: diff.1,v 1.27 2004/12/09 18:56:10 millert Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -223,7 +223,8 @@ after all text file differences are reported. .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 option 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 diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index 0d16791b4c1..065def887d1 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.47 2004/12/07 11:53:29 espie Exp $ */ +/* $OpenBSD: diff.c,v 1.48 2004/12/09 18:56:10 millert Exp $ */ /* * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -21,7 +21,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diff.c,v 1.47 2004/12/07 11:53:29 espie Exp $"; +static const char rcsid[] = "$OpenBSD: diff.c,v 1.48 2004/12/09 18:56:10 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -43,7 +43,7 @@ static const char rcsid[] = "$OpenBSD: diff.c,v 1.47 2004/12/07 11:53:29 espie E 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, *label[2], *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 (label[0] == NULL) + label[0] = optarg; + else if (label[1] == NULL) + label[1] = optarg; + else + usage(); break; case 'l': lflag = 1; diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h index 8d5e70813dd..817057d8ca6 100644 --- a/usr.bin/diff/diff.h +++ b/usr.bin/diff/diff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.h,v 1.28 2004/06/20 18:47:45 otto Exp $ */ +/* $OpenBSD: diff.h,v 1.29 2004/12/09 18:56:10 millert Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -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, *label[2], *ignore_pats; extern struct stat stb1, stb2; extern struct excludes *excludes_list; extern regex_t ignore_re; diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 4b406f6ce86..afd15b57154 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.60 2004/11/27 19:16:25 otto Exp $ */ +/* $OpenBSD: diffreg.c,v 1.61 2004/12/09 18:56:10 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -65,7 +65,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.60 2004/11/27 19:16:25 otto Exp $"; +static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.61 2004/12/09 18:56:10 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -214,6 +214,7 @@ static void unravel(int); static void unsort(struct line *, int, int *); static void change(char *, FILE *, char *, FILE *, int, int, int, int); static void sort(struct line *, int); +static void print_header(const char *, const char *); static int ignoreline(char *); static int asciifile(FILE *); static int fetch(long *, int, int, FILE *, int, int); @@ -1048,16 +1049,7 @@ proceed: /* * Print the context/unidiff header first time through. */ - if (label != NULL) - printf("%s %s\n", - format == D_CONTEXT ? "***" : "---", label); - 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)); + print_header(file1, file2); anychange = 1; } else if (a > context_vec_ptr->b + (2 * context) + 1 && c > context_vec_ptr->d + (2 * context) + 1) { @@ -1510,3 +1502,20 @@ dump_unified_vec(FILE *f1, FILE *f2) context_vec_ptr = context_vec_start - 1; } + +static void +print_header(const char *file1, const char *file2) +{ + if (label[0] != NULL) + printf("%s %s\n", format == D_CONTEXT ? "***" : "---", + label[0]); + else + printf("%s %s\t%s", format == D_CONTEXT ? "***" : "---", + file1, ctime(&stb1.st_mtime)); + if (label[1] != NULL) + printf("%s %s\n", format == D_CONTEXT ? "---" : "+++", + label[1]); + else + printf("%s %s\t%s", format == D_CONTEXT ? "---" : "+++", + file2, ctime(&stb2.st_mtime)); +} |