diff options
Diffstat (limited to 'usr.bin/diff')
-rw-r--r-- | usr.bin/diff/diff.c | 16 | ||||
-rw-r--r-- | usr.bin/diff/diff.h | 4 | ||||
-rw-r--r-- | usr.bin/diff/diffreg.c | 37 |
3 files changed, 18 insertions, 39 deletions
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index 8448b7ee8a0..63fb2e40abe 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.16 2003/06/26 21:03:08 millert Exp $ */ +/* $OpenBSD: diff.c,v 1.17 2003/06/26 22:04:45 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -62,11 +62,8 @@ int lflag; /* long output format with header */ int rflag; /* recursively trace directories */ int sflag; /* announce files which are same */ char *start; /* do file only if name >= this */ -/* Variables for -I D_IFDEF option. */ -int wantelses; /* -E */ -char *ifdef1; /* String for -1 */ -char *ifdef2; /* String for -2 */ -char *endifname; /* What we will print on next #endif */ +/* Variables for -D D_IFDEF option. */ +char *ifdefname; /* What we will print for #ifdef/#endif */ int inifdef; /* Variables for -c and -u context option. */ int context; /* lines of context to be printed */ @@ -97,8 +94,6 @@ main(int argc, char **argv) { int ch; - ifdef1 = "FILE1"; - ifdef2 = "FILE2"; status = 2; diffargv = argv; @@ -121,11 +116,8 @@ main(int argc, char **argv) context = 3; break; case 'D': - /* -Dfoo = -E -1 -2foo */ opt = D_IFDEF; - ifdef1 = ""; - ifdef2 = optarg; - wantelses++; + ifdefname = optarg; break; case 'e': opt = D_EDIT; diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h index fc155fcf2a9..092a0f8d53d 100644 --- a/usr.bin/diff/diff.h +++ b/usr.bin/diff/diff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.h,v 1.10 2003/06/26 18:19:29 millert Exp $ */ +/* $OpenBSD: diff.h,v 1.11 2003/06/26 22:04:45 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -61,7 +61,7 @@ lines and no trailing . */ extern int aflag, bflag, hflag, iflag, lflag, rflag, sflag, tflag, wflag; -extern char *start, *ifdef1, *ifdef2, *endifname; +extern char *start, *ifdefname; extern int opt, wantelses, inifdef, context, status, anychange; extern char *tempfiles[], **diffargv; extern char *file1, *file2, *efile1, *efile2; diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 0707749ae40..be2e9bfe466 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.21 2003/06/26 18:19:29 millert Exp $ */ +/* $OpenBSD: diffreg.c,v 1.22 2003/06/26 22:04:45 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -792,7 +792,7 @@ change(int a, int b, int c, int d) } if (opt == D_CONTEXT || opt == D_UNIFIED) { /* - * if this new change is within 'context' lines of + * If this new change is within 'context' lines of * the previous change, just add it to the change * record. If the record is full or if this * change is more than 'context' lines from the previous @@ -849,7 +849,7 @@ change(int a, int b, int c, int d) if ((opt == D_EDIT || opt == D_REVERSE) && c <= d) prints(".\n"); if (inifdef) { - fprintf(stdout, "#endif /* %s */\n", endifname); + fprintf(stdout, "#endif /* %s */\n", ifdefname); inifdef = 0; } } @@ -865,7 +865,6 @@ range(int a, int b, char *separator) static void fetch(long *f, int a, int b, FILE *lb, char *s, int oldfile) { - int oneflag = (*ifdef1 != '\0') != (*ifdef2 != '\0'); int i, j, c, col, nc; /* @@ -882,21 +881,14 @@ fetch(long *f, int a, int b, FILE *lb, char *s, int oldfile) if (a > b) return; if (opt == D_IFDEF) { - if (inifdef) + if (inifdef) { fprintf(stdout, "#else /* %s%s */\n", - oneflag && oldfile == 1 ? "!" : "", ifdef2); - else { - if (oneflag) { - /* There was only one ifdef given */ - endifname = ifdef2; - if (oldfile) - fprintf(stdout, "#ifndef %s\n", endifname); - else - fprintf(stdout, "#ifdef %s\n", endifname); - } else { - endifname = oldfile ? ifdef1 : ifdef2; - fprintf(stdout, "#ifdef %s\n", endifname); - } + oldfile == 1 ? "!" : "", ifdefname); + } else { + if (oldfile) + fprintf(stdout, "#ifndef %s\n", ifdefname); + else + fprintf(stdout, "#ifdef %s\n", ifdefname); } inifdef = 1 + oldfile; } @@ -918,11 +910,6 @@ fetch(long *f, int a, int b, FILE *lb, char *s, int oldfile) } } } - - if (inifdef && !wantelses) { - fprintf(stdout, "#endif /* %s */\n", endifname); - inifdef = 0; - } } #define POW2 /* define only if HALFLONG is 2**n */ @@ -1023,7 +1010,7 @@ dump_context_vec(void) int a, b, c, d; char ch; - if (cvp > context_vec_ptr) + if (context_vec_start > context_vec_ptr) return; b = d = 0; /* gcc */ @@ -1120,7 +1107,7 @@ dump_unified_vec(void) int a, b, c, d; char ch; - if (cvp > context_vec_ptr) + if (context_vec_start > context_vec_ptr) return; b = d = 0; /* gcc */ |