diff options
author | 2003-07-04 17:50:24 +0000 | |
---|---|---|
committer | 2003-07-04 17:50:24 +0000 | |
commit | e1b11c9e5e0f50a509c3432dd9b39cb95b3c5d4c (patch) | |
tree | 089e94cb31544ff21dc0c1248430797f13b21da6 /usr.bin/diff | |
parent | Kill diff -h, we don't use or want diffh. Discussed w/ tedu@ (diff) | |
download | wireguard-openbsd-e1b11c9e5e0f50a509c3432dd9b39cb95b3c5d4c.tar.xz wireguard-openbsd-e1b11c9e5e0f50a509c3432dd9b39cb95b3c5d4c.zip |
Kill non-standard -l option as discussed with tedu@
Diffstat (limited to 'usr.bin/diff')
-rw-r--r-- | usr.bin/diff/diff.1 | 12 | ||||
-rw-r--r-- | usr.bin/diff/diff.c | 14 | ||||
-rw-r--r-- | usr.bin/diff/diff.h | 4 | ||||
-rw-r--r-- | usr.bin/diff/diffdir.c | 133 | ||||
-rw-r--r-- | usr.bin/diff/pathnames.h | 1 |
5 files changed, 30 insertions, 134 deletions
diff --git a/usr.bin/diff/diff.1 b/usr.bin/diff/diff.1 index a2b45be3ff3..3518ca11573 100644 --- a/usr.bin/diff/diff.1 +++ b/usr.bin/diff/diff.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: diff.1,v 1.9 2003/07/04 17:37:07 millert Exp $ +.\" $OpenBSD: diff.1,v 1.10 2003/07/04 17:50:24 millert Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -61,7 +61,6 @@ .Fl c | Fl e | Fl f | .Fl n | Fl u .Oc -.Op Fl l .Op Fl r .Op Fl s .Op Fl S Ar name @@ -198,14 +197,6 @@ will compare equal to .Pp Directory comparison options: .Bl -tag -width Ds -.It Fl l -Long output format; each text file -.Nm diff Ns \'d -is piped through -.Xr pr 1 -to paginate it; -other differences are remembered and summarized -after all text file differences are reported. .It Fl r Causes application of .Nm @@ -387,7 +378,6 @@ Differences were found. An error occurred. .El .Sh SEE ALSO -.Xr cc 1 , .Xr cmp 1 , .Xr comm 1 , .Xr diff3 1 , diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c index 72dbcd78d85..813674f9faf 100644 --- a/usr.bin/diff/diff.c +++ b/usr.bin/diff/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.20 2003/07/04 17:37:07 millert Exp $ */ +/* $OpenBSD: diff.c,v 1.21 2003/07/04 17:50:24 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -58,7 +58,6 @@ int bflag; /* ignore blanks in comparisons */ int wflag; /* totally ignore blanks in comparisons */ int iflag; /* ignore case in comparisons */ /* Options on hierarchical diffs. */ -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 */ @@ -91,7 +90,7 @@ main(int argc, char **argv) status = 2; diffargv = argv; - while ((ch = getopt(argc, argv, "abC:cD:efilnrS:stU:uw")) != -1) { + while ((ch = getopt(argc, argv, "abC:cD:efinrS:stU:uw")) != -1) { switch (ch) { case 'a': aflag++; @@ -122,9 +121,6 @@ main(int argc, char **argv) case 'i': iflag++; break; - case 'l': - lflag++; - break; case 'n': opt = D_NREVERSE; break; @@ -260,12 +256,12 @@ __dead void usage(void) { (void)fprintf(stderr, - "usage: diff [-bitw] [-c | -e | -f | -h | -n | -u ] file1 file2\n" + "usage: diff [-bitw] [-c | -e | -f | -n | -u ] file1 file2\n" " diff [-bitw] -C number file1 file2\n" " diff [-bitw] -D string file1 file2\n" " diff [-bitw] -U number file1 file2\n" - " diff [-biwt] [-c | -e | -f | -h | -n | -u ] " - "[-l] [-r] [-s] [-S name]\n dir1 dir2\n"); + " diff [-biwt] [-c | -e | -f | -n | -u ] " + "[-r] [-s] [-S name]\n dir1 dir2\n"); exit(2); } diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h index e4039a4789f..971c9b3269a 100644 --- a/usr.bin/diff/diff.h +++ b/usr.bin/diff/diff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.h,v 1.13 2003/07/04 17:37:07 millert Exp $ */ +/* $OpenBSD: diff.h,v 1.14 2003/07/04 17:50:24 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -60,7 +60,7 @@ #define D_NREVERSE 5 /* Reverse ed script with numbered lines and no trailing . */ -extern int aflag, bflag, iflag, lflag, rflag, sflag, tflag, wflag; +extern int aflag, bflag, iflag, rflag, sflag, tflag, wflag; extern char *start, *ifdefname; extern int opt, wantelses, context, status, anychange; extern char *tempfiles[], **diffargv; diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c index a60116444ed..361bbf588c3 100644 --- a/usr.bin/diff/diffdir.c +++ b/usr.bin/diff/diffdir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffdir.c,v 1.16 2003/07/04 02:54:36 millert Exp $ */ +/* $OpenBSD: diffdir.c,v 1.17 2003/07/04 17:50:24 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -57,10 +57,7 @@ static const char sccsid[] = "@(#)diffdir.c 4.12 (Berkeley) 4/30/89"; */ #define d_flags d_ino -#define ONLY 1 /* Only in this directory */ -#define SAME 2 /* Both places and same */ -#define DIFFER 4 /* Both places and different */ -#define DIRECT 8 /* Directory */ +#define DIRECT 1 /* Directory */ struct dir { u_long d_ino; @@ -69,22 +66,17 @@ struct dir { char *d_entry; }; -int header; static int dirstatus; /* exit status from diffdir */ -extern int status; -char title[2 * BUFSIZ]; -char *etitle; -char *prargs[] = {"pr", "-h", 0, "-f", 0, 0}; +static char title[2 * BUFSIZ]; static struct dir *setupdir(char *); static int ascii(int); static void compare(struct dir *); -static void calldiff(char *); +static void calldiff(void); static void setfile(char **fpp, char **epp, char *file); static int useless(char *); static void only(struct dir *dp, int which); -static void scanpr(struct dir *, int, char *, char *, char *, char *, char *); static int entcmp(const void *, const void *); void @@ -96,8 +88,8 @@ diffdir(char **argv) if (opt == D_IFDEF) warnx("can't specify -I with directories"); - if (opt == D_EDIT && (sflag || lflag)) - warnx("warning: shouldn't give -s or -l with -e"); + if (opt == D_EDIT && sflag) + warnx("warning: shouldn't give -s with -e"); strlcpy(title, "diff ", sizeof title); for (i = 1; diffargv[i + 2]; i++) { if (!strcmp(diffargv[i], "-")) @@ -105,8 +97,6 @@ diffdir(char **argv) strlcat(title, diffargv[i], sizeof title); strlcat(title, " ", sizeof title); } - for (etitle = title; *etitle; etitle++) - ; setfile(&file1, &efile1, file1); setfile(&file2, &efile2, file2); argv[0] = file1; @@ -131,9 +121,7 @@ diffdir(char **argv) else cmp = strcmp(d1->d_entry, d2->d_entry); if (cmp < 0) { - if (lflag) - d1->d_flags |= ONLY; - else if (opt == 0 || opt == 2) + if (opt == 0 || opt == 2) only(d1, 1); d1++; dirstatus |= 1; @@ -142,27 +130,13 @@ diffdir(char **argv) d1++; d2++; } else { - if (lflag) - d2->d_flags |= ONLY; - else if (opt == 0 || opt == 2) + if (opt == 0 || opt == 2) only(d2, 2); d2++; dirstatus |= 1; } } - if (lflag) { - scanpr(dir1, ONLY, "Only in %.*s", file1, efile1, 0, 0); - scanpr(dir2, ONLY, "Only in %.*s", file2, efile2, 0, 0); - scanpr(dir1, SAME, "Common identical files in %.*s and %.*s", - file1, efile1, file2, efile2); - scanpr(dir1, DIFFER, "Binary files which differ in %.*s and %.*s", - file1, efile1, file2, efile2); - scanpr(dir1, DIRECT, "Common subdirectories of %.*s and %.*s", - file1, efile1, file2, efile2); - } if (rflag) { - if (header && lflag) - printf("\f"); for (d1 = dir1; d1->d_entry; d1++) { if ((d1->d_flags & DIRECT) == 0) continue; @@ -170,7 +144,7 @@ diffdir(char **argv) file1 + MAXPATHLEN - efile1); strlcpy(efile2, d1->d_entry, file2 + MAXPATHLEN - efile2); - calldiff(0); + calldiff(); } } status = dirstatus; @@ -198,30 +172,6 @@ setfile(char **fpp, char **epp, char *file) *epp = cp; } -static void -scanpr(struct dir *dp, int test, char *title, char *file1, char *efile1, - char *file2, char *efile2) -{ - int titled = 0; - - for (; dp->d_entry; dp++) { - if ((dp->d_flags & test) == 0) - continue; - if (titled == 0) { - if (header == 0) - header = 1; - else - printf("\n"); - printf(title, - efile1 - file1 - 1, file1, - efile2 - file2 - 1, file2); - printf(":\n"); - titled = 1; - } - printf("\t%s\n", dp->d_entry); - } -} - void only(struct dir *dp, int which) { @@ -302,7 +252,7 @@ compare(struct dir *dp) goto same; if (fmt1 == S_IFDIR) { dp->d_flags = DIRECT; - if (lflag || opt == D_EDIT) + if (opt == D_EDIT) goto closem; printf("Common subdirectories: %s and %s\n", file1, file2); @@ -325,19 +275,13 @@ compare(struct dir *dp) goto notsame; } same: - if (sflag == 0) - goto closem; - if (lflag) - dp->d_flags = SAME; - else + if (sflag != 0) printf("Files %s and %s are identical\n", file1, file2); goto closem; notsame: dirstatus |= 1; if (!ascii(f1) || !ascii(f2)) { - if (lflag) - dp->d_flags |= DIFFER; - else if (opt == D_NORMAL || opt == D_CONTEXT || opt == D_UNIFIED) + if (opt == D_NORMAL || opt == D_CONTEXT || opt == D_UNIFIED) printf("Binary files %s and %s differ\n", file1, file2); goto closem; @@ -345,19 +289,15 @@ notsame: close(f1); close(f2); anychange = 1; - if (lflag) - calldiff(title); - else { - if (opt == D_EDIT) { - printf("ed - %s << '-*-END-*-'\n", dp->d_entry); - calldiff(0); - } else { - printf("%s%s %s\n", title, file1, file2); - calldiff(0); - } - if (opt == D_EDIT) - printf("w\nq\n-*-END-*-\n"); + if (opt == D_EDIT) { + printf("ed - %s << '-*-END-*-'\n", dp->d_entry); + calldiff(); + } else { + printf("%s%s %s\n", title, file1, file2); + calldiff(); } + if (opt == D_EDIT) + printf("w\nq\n-*-END-*-\n"); return; closem: close(f1); @@ -365,50 +305,21 @@ closem: } static void -calldiff(char *wantpr) +calldiff(void) { - int lstatus, lstatus2, pv[2]; + int lstatus; pid_t pid; - prargs[2] = wantpr; fflush(stdout); - if (wantpr) { - snprintf(etitle, title + sizeof title - etitle, - "%s %s", file1, file2); - pipe(pv); - pid = fork(); - if (pid == -1) - errorx("No more processes"); - if (pid == 0) { - close(0); - dup(pv[0]); - close(pv[0]); - close(pv[1]); - execv(_PATH_PR, prargs); - errorx("%s", _PATH_PR); - } - } pid = fork(); if (pid == -1) errorx("No more processes"); if (pid == 0) { - if (wantpr) { - close(1); - dup(pv[1]); - close(pv[0]); - close(pv[1]); - } execv(_PATH_DIFF, diffargv); error("%s", _PATH_DIFF); } - if (wantpr) { - close(pv[0]); - close(pv[1]); - } while (wait(&lstatus) != pid) continue; - while (wait(&lstatus2) != -1) - continue; /* if ((lstatus >> 8) >= 2) done(0); diff --git a/usr.bin/diff/pathnames.h b/usr.bin/diff/pathnames.h index 403228048f8..83b4235e923 100644 --- a/usr.bin/diff/pathnames.h +++ b/usr.bin/diff/pathnames.h @@ -32,4 +32,3 @@ #include <paths.h> #define _PATH_DIFF "/usr/bin/diff" -#define _PATH_PR "/usr/bin/pr" |