From a3e88724cbdd488844edb3debf70ccc351fade25 Mon Sep 17 00:00:00 2001 From: Van Jacobson Date: Sat, 17 Aug 1985 04:12:33 -0800 Subject: [PATCH] added -n flag from rcs diff SCCS-vsn: usr.bin/diff/diff/diff.c 4.5 SCCS-vsn: usr.bin/diff/diff/diff.h 4.7 SCCS-vsn: usr.bin/diff/diff/diffreg.c 4.13 --- usr/src/usr.bin/diff/diff/diff.c | 7 +++++-- usr/src/usr.bin/diff/diff/diff.h | 5 +++-- usr/src/usr.bin/diff/diff/diffreg.c | 12 +++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/usr/src/usr.bin/diff/diff/diff.c b/usr/src/usr.bin/diff/diff/diff.c index 0f937ee2a3..34ec82549e 100644 --- a/usr/src/usr.bin/diff/diff/diff.c +++ b/usr/src/usr.bin/diff/diff/diff.c @@ -1,4 +1,4 @@ -static char sccsid[] = "@(#)diff.c 4.4 %G%"; +static char sccsid[] = "@(#)diff.c 4.5 %G%"; #include "diff.h" /* @@ -57,6 +57,9 @@ main(argc, argv) case 'f': opt = D_REVERSE; continue; + case 'n': + opt = D_NREVERSE; + continue; case 'b': bflag = 1; continue; @@ -118,7 +121,7 @@ main(argc, argv) file2 = argv[1]; if (hflag && opt) { fprintf(stderr, - "diff: -h doesn't support -e, -f, -c, or -I\n"); + "diff: -h doesn't support -e, -f, -n, -c, or -I\n"); done(); } if (!strcmp(file1, "-")) diff --git a/usr/src/usr.bin/diff/diff/diff.h b/usr/src/usr.bin/diff/diff/diff.h index 29d5a414b7..7c11a5fb50 100644 --- a/usr/src/usr.bin/diff/diff/diff.h +++ b/usr/src/usr.bin/diff/diff/diff.h @@ -1,4 +1,4 @@ -/* diff.h 4.6 85/06/07 */ +/* diff.h 4.7 85/08/16 */ /* * diff - common declarations @@ -21,6 +21,8 @@ int opt; #define D_REVERSE 1 /* Reverse editor script */ #define D_CONTEXT 2 /* Diff with context */ #define D_IFDEF 3 /* Diff with merged #ifdef's */ +#define D_NREVERSE 4 /* Reverse ed script with numbered + lines and no trailing . */ int tflag; /* expand tabs on output */ @@ -74,7 +76,6 @@ char **diffargv; /* option list to pass to recursive diffs */ */ char *file1, *file2, *efile1, *efile2; struct stat stb1, stb2; -struct stat stb1, stb2; char *malloc(), *talloc(), *ralloc(); char *savestr(), *splice(), *splicen(); diff --git a/usr/src/usr.bin/diff/diff/diffreg.c b/usr/src/usr.bin/diff/diff/diffreg.c index 33988debb2..37f1661736 100644 --- a/usr/src/usr.bin/diff/diff/diffreg.c +++ b/usr/src/usr.bin/diff/diff/diffreg.c @@ -1,4 +1,4 @@ -static char sccsid[] = "@(#)diffreg.c 4.12 %G%"; +static char sccsid[] = "@(#)diffreg.c 4.13 %G%"; #include "diff.h" /* @@ -730,6 +730,16 @@ change(a,b,c,d) range(a,b," "); putchar('\n'); break; + case D_NREVERSE: + if (a>b) + printf("a%d %d\n",b,d-c+1); + else { + printf("d%d %d\n",a,b-a+1); + if (!(c>d)) + /* add changed lines */ + printf("a%d %d\n",b, d-c+1); + } + break; } if(opt == D_NORMAL || opt == D_IFDEF) { fetch(ixold,a,b,input[0],"< ", 1); -- 2.20.1