summaryrefslogtreecommitdiff
path: root/usr.bin/diff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-10-05 20:15:01 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-10-05 20:15:01 +0000
commit36eed06dd9be4b7d8dbb9e2b35ba1039917dfbab (patch)
treedfbc373a47ad99f5b5750def9ff8b6c54b304f27 /usr.bin/diff
parent775cd0daa9a5cd1526bb295c074248d0da5f1b97 (diff)
Remove the non-standard -l flag that pipes the output through pr(1).
Based on a diff from and OK deraadt@
Diffstat (limited to 'usr.bin/diff')
-rw-r--r--usr.bin/diff/diff.114
-rw-r--r--usr.bin/diff/diff.c42
-rw-r--r--usr.bin/diff/diff.h17
-rw-r--r--usr.bin/diff/diffdir.c24
-rw-r--r--usr.bin/diff/diffreg.c59
-rw-r--r--usr.bin/diff/pathnames.h25
6 files changed, 29 insertions, 152 deletions
diff --git a/usr.bin/diff/diff.1 b/usr.bin/diff/diff.1
index 51a3246342e..5ce4c826d77 100644
--- a/usr.bin/diff/diff.1
+++ b/usr.bin/diff/diff.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: diff.1,v 1.43 2014/02/13 14:52:53 jmc Exp $
+.\" $OpenBSD: diff.1,v 1.44 2015/10/05 20:15:00 millert Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)diff.1 8.1 (Berkeley) 6/30/93
.\"
-.Dd $Mdocdate: February 13 2014 $
+.Dd $Mdocdate: October 5 2015 $
.Dt DIFF 1
.Os
.Sh NAME
@@ -37,7 +37,7 @@
.Nd differential file and directory comparator
.Sh SYNOPSIS
.Nm diff
-.Op Fl abdilpTtw
+.Op Fl abdipTtw
.Oo
.Fl c | e | f |
.Fl n | q | u
@@ -224,14 +224,6 @@ Print
.Ar label
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 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 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 c7b47c98aa5..eb2d8e5d0a2 100644
--- a/usr.bin/diff/diff.c
+++ b/usr.bin/diff/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.61 2015/10/05 15:42:54 semarie Exp $ */
+/* $OpenBSD: diff.c,v 1.62 2015/10/05 20:15:00 millert Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -26,7 +26,6 @@
#include <err.h>
#include <errno.h>
#include <getopt.h>
-#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
@@ -37,7 +36,7 @@
#include "diff.h"
#include "xmalloc.h"
-int lflag, Nflag, Pflag, rflag, sflag, Tflag;
+int Nflag, Pflag, rflag, sflag, Tflag;
int diff_format, diff_context, status;
char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
struct stat stb1, stb2;
@@ -55,7 +54,6 @@ static struct option longopts[] = {
{ "forward-ed", no_argument, 0, 'f' },
{ "ignore-matching-lines", required_argument, 0, 'I' },
{ "ignore-case", no_argument, 0, 'i' },
- { "paginate", no_argument, 0, 'l' },
{ "label", required_argument, 0, 'L' },
{ "new-file", no_argument, 0, 'N' },
{ "rcs", no_argument, 0, 'n' },
@@ -152,10 +150,6 @@ main(int argc, char **argv)
else
usage();
break;
- case 'l':
- lflag = 1;
- signal(SIGPIPE, SIG_IGN);
- break;
case 'N':
Nflag = 1;
break;
@@ -217,15 +211,14 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (lflag == 0) {
- if (getenv("TMPDIR")) {
- if (tame("stdio rpath wpath cpath", NULL) == -1)
- err(1, "tame");
- } else {
- if (tame("stdio rpath tmppath", NULL) == -1)
- err(1, "tame");
- }
+ if (getenv("TMPDIR")) {
+ if (tame("stdio rpath wpath cpath", NULL) == -1)
+ err(1, "tame");
+ } else {
+ if (tame("stdio rpath tmppath", NULL) == -1)
+ err(1, "tame");
}
+
/*
* Do sanity checks, fill in stb1 and stb2 and call the appropriate
* driver routine. Both drivers use the contents of stb1 and stb2.
@@ -364,13 +357,6 @@ void
print_status(int val, char *path1, char *path2, char *entry)
{
switch (val) {
- case D_ONLY:
- print_only(path1, strlen(path1), entry);
- break;
- case D_COMMON:
- printf("Common subdirectories: %s%s and %s%s\n",
- path1, entry, path2, entry);
- break;
case D_BINARY:
printf("Binary files %s%s and %s%s differ\n",
path1, entry, path2, entry);
@@ -408,12 +394,12 @@ __dead void
usage(void)
{
(void)fprintf(stderr,
- "usage: diff [-abdilpTtw] [-c | -e | -f | -n | -q | -u] [-I pattern] [-L label]\n"
+ "usage: diff [-abdipTtw] [-c | -e | -f | -n | -q | -u] [-I pattern] [-L label]\n"
" file1 file2\n"
- " diff [-abdilpTtw] [-I pattern] [-L label] -C number file1 file2\n"
- " diff [-abdiltw] [-I pattern] -D string file1 file2\n"
- " diff [-abdilpTtw] [-I pattern] [-L label] -U number file1 file2\n"
- " diff [-abdilNPprsTtw] [-c | -e | -f | -n | -q | -u] [-I pattern]\n"
+ " diff [-abdipTtw] [-I pattern] [-L label] -C number file1 file2\n"
+ " diff [-abditw] [-I pattern] -D string file1 file2\n"
+ " diff [-abdipTtw] [-I pattern] [-L label] -U number file1 file2\n"
+ " diff [-abdiNPprsTtw] [-c | -e | -f | -n | -q | -u] [-I pattern]\n"
" [-L label] [-S name] [-X file] [-x pattern] dir1 dir2\n");
exit(2);
diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h
index 5ac5f92e49a..3a36222419a 100644
--- a/usr.bin/diff/diff.h
+++ b/usr.bin/diff/diff.h
@@ -1,6 +1,6 @@
-/* $OpenBSD: diff.h,v 1.32 2009/06/07 08:39:13 ray Exp $ */
-/*-
+
+/*ROR
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -71,20 +71,17 @@
#define D_SAME 0 /* Files are the same */
#define D_DIFFER 1 /* Files are different */
#define D_BINARY 2 /* Binary files are different */
-#define D_COMMON 3 /* Subdirectory common to both dirs */
-#define D_ONLY 4 /* Only exists in one directory */
-#define D_MISMATCH1 5 /* path1 was a dir, path2 a file */
-#define D_MISMATCH2 6 /* path1 was a file, path2 a dir */
-#define D_ERROR 7 /* An error occurred */
-#define D_SKIPPED1 8 /* path1 was a special file */
-#define D_SKIPPED2 9 /* path2 was a special file */
+#define D_MISMATCH1 3 /* path1 was a dir, path2 a file */
+#define D_MISMATCH2 4 /* path1 was a file, path2 a dir */
+#define D_SKIPPED1 5 /* path1 was a special file */
+#define D_SKIPPED2 6 /* path2 was a special file */
struct excludes {
char *pattern;
struct excludes *next;
};
-extern int lflag, Nflag, Pflag, rflag, sflag, Tflag;
+extern int Nflag, Pflag, rflag, sflag, Tflag;
extern int diff_format, diff_context, status;
extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
extern struct stat stb1, stb2;
diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c
index eac7497dccb..3b817f1a2c6 100644
--- a/usr.bin/diff/diffdir.c
+++ b/usr.bin/diff/diffdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffdir.c,v 1.44 2015/09/25 16:16:26 tedu Exp $ */
+/* $OpenBSD: diffdir.c,v 1.45 2015/10/05 20:15:00 millert Exp $ */
/*
* Copyright (c) 2003, 2010 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -132,8 +132,6 @@ diffdir(char *p1, char *p2, int flags)
if (Nflag)
diffit(dent1, path1, dirlen1, path2, dirlen2,
flags);
- else if (lflag)
- dent1->d_status |= D_ONLY;
else
print_only(path1, dirlen1, dent1->d_name);
dp1++;
@@ -142,26 +140,11 @@ diffdir(char *p1, char *p2, int flags)
if (Nflag || Pflag)
diffit(dent2, path1, dirlen1, path2, dirlen2,
flags);
- else if (lflag)
- dent2->d_status |= D_ONLY;
else
print_only(path2, dirlen2, dent2->d_name);
dp2++;
}
}
- if (lflag) {
- path1[dirlen1] = '\0';
- path2[dirlen2] = '\0';
- for (dp1 = dirp1; (dent1 = *dp1) != NULL; dp1++) {
- print_status(dent1->d_status, path1, path2,
- dent1->d_name);
- }
- for (dp2 = dirp2; (dent2 = *dp2) != NULL; dp2++) {
- if (dent2->d_status == D_ONLY)
- print_status(dent2->d_status, path2, NULL,
- dent2->d_name);
- }
- }
closem:
if (dirp1 != NULL) {
@@ -210,8 +193,6 @@ diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2,
if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) {
if (rflag)
diffdir(path1, path2, flags);
- else if (lflag)
- dp->d_status |= D_COMMON;
else
printf("Common subdirectories: %s and %s\n",
path1, path2);
@@ -223,8 +204,7 @@ diffit(struct dirent *dp, char *path1, size_t plen1, char *path2, size_t plen2,
dp->d_status = D_SKIPPED2;
else
dp->d_status = diffreg(path1, path2, flags);
- if (!lflag)
- print_status(dp->d_status, path1, path2, "");
+ print_status(dp->d_status, path1, path2, "");
}
/*
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 446fa359b22..8226ff803c8 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffreg.c,v 1.87 2015/09/25 16:16:26 tedu Exp $ */
+/* $OpenBSD: diffreg.c,v 1.88 2015/10/05 20:15:00 millert Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -71,6 +71,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <paths.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
@@ -80,7 +81,6 @@
#include <limits.h>
#include "diff.h"
-#include "pathnames.h"
#include "xmalloc.h"
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
@@ -293,8 +293,7 @@ int
diffreg(char *file1, char *file2, int flags)
{
FILE *f1, *f2;
- int i, rval, ostdout = -1;
- pid_t pid = -1;
+ int i, rval;
f1 = f2 = NULL;
rval = D_SAME;
@@ -370,45 +369,6 @@ diffreg(char *file1, char *file2, int flags)
status |= 1;
goto closem;
}
- if (lflag) {
- /* redirect stdout to pr */
- int pfd[2];
- char *header;
- char *prargv[] = { "pr", "-h", NULL, "-f", NULL };
-
- xasprintf(&header, "%s %s %s", diffargs, file1, file2);
- prargv[2] = header;
- fflush(stdout);
- rewind(stdout);
- pipe(pfd);
- switch ((pid = fork())) {
- case -1:
- warnx("No more processes");
- status |= 2;
- free(header);
- rval = D_ERROR;
- goto closem;
- case 0:
- /* child */
- if (pfd[0] != STDIN_FILENO) {
- dup2(pfd[0], STDIN_FILENO);
- close(pfd[0]);
- }
- close(pfd[1]);
- execv(_PATH_PR, prargv);
- _exit(127);
- default:
- /* parent */
- if (pfd[1] != STDOUT_FILENO) {
- ostdout = dup(STDOUT_FILENO);
- dup2(pfd[1], STDOUT_FILENO);
- close(pfd[1]);
- }
- close(pfd[0]);
- rewind(stdout);
- free(header);
- }
- }
prepare(0, f1, stb1.st_size, flags);
prepare(1, f2, stb2.st_size, flags);
@@ -441,19 +401,6 @@ diffreg(char *file1, char *file2, int flags)
ixnew = xreallocarray(ixnew, len[1] + 2, sizeof(*ixnew));
check(f1, f2, flags);
output(file1, f1, file2, f2, flags);
- if (ostdout != -1) {
- int wstatus;
-
- /* close the pipe to pr and restore stdout */
- fflush(stdout);
- rewind(stdout);
- if (ostdout != STDOUT_FILENO) {
- close(STDOUT_FILENO);
- dup2(ostdout, STDOUT_FILENO);
- close(ostdout);
- }
- waitpid(pid, &wstatus, 0);
- }
closem:
if (anychange) {
status |= 1;
diff --git a/usr.bin/diff/pathnames.h b/usr.bin/diff/pathnames.h
deleted file mode 100644
index ab79dca284d..00000000000
--- a/usr.bin/diff/pathnames.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* $OpenBSD: pathnames.h,v 1.10 2003/07/09 00:07:44 millert Exp $ */
-
-/*
- * Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Sponsored in part by the Defense Advanced Research Projects
- * Agency (DARPA) and Air Force Research Laboratory, Air Force
- * Materiel Command, USAF, under agreement number F39502-99-1-0512.
- */
-
-#include <paths.h>
-
-#define _PATH_PR "/usr/bin/pr"