summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff/diff.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2003-07-27 07:39:52 +0000
committerotto <otto@openbsd.org>2003-07-27 07:39:52 +0000
commit6e18f850405e4ce784c344ca4202e782f4f51254 (patch)
tree0a9657e58aed7bde0dcf38af134c273f993546fd /usr.bin/diff/diff.c
parentinstall ed tutorial papers; (diff)
downloadwireguard-openbsd-6e18f850405e4ce784c344ca4202e782f4f51254.tar.xz
wireguard-openbsd-6e18f850405e4ce784c344ca4202e782f4f51254.zip
- Use a heuristic to bound memory and cpu usage, at the cost of
producing suboptimal diffs for large file containing lots of changes. Switch heuristic off with -d/--minimal (GNU compatible). Some hints from millert@. - Improve performance by reducing the number of realloc(3) calls. ok millert@ tedu@
Diffstat (limited to 'usr.bin/diff/diff.c')
-rw-r--r--usr.bin/diff/diff.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c
index b671ec3892e..56b11e3da95 100644
--- a/usr.bin/diff/diff.c
+++ b/usr.bin/diff/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.34 2003/07/22 16:42:58 millert Exp $ */
+/* $OpenBSD: diff.c,v 1.35 2003/07/27 07:39:52 otto 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.34 2003/07/22 16:42:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: diff.c,v 1.35 2003/07/27 07:39:52 otto Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -39,19 +39,20 @@ static const char rcsid[] = "$OpenBSD: diff.c,v 1.34 2003/07/22 16:42:58 millert
#include "diff.h"
-int aflag, bflag, iflag, lflag, Nflag, Pflag, rflag, sflag, tflag, Tflag,
- wflag;
+int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, rflag, sflag, tflag,
+ Tflag, wflag;
int format, context, status;
char *start, *ifdefname, *diffargs, *label;
struct stat stb1, stb2;
struct excludes *excludes_list;
-#define OPTIONS "abC:cD:efhiL:lnNPqrS:sTtU:uwX:x:"
+#define OPTIONS "abC:cdD:efhiL:lnNPqrS:sTtU:uwX:x:"
static struct option longopts[] = {
{ "text", no_argument, 0, 'a' },
{ "ignore-space-change", no_argument, 0, 'b' },
{ "context", optional_argument, 0, 'C' },
{ "ifdef", required_argument, 0, 'D' },
+ { "minimal", no_argument, 0, 'd' },
{ "ed", no_argument, 0, 'e' },
{ "forward-ed", no_argument, 0, 'f' },
{ "ignore-case", no_argument, 0, 'i' },
@@ -107,6 +108,9 @@ main(int argc, char **argv)
} else
context = 3;
break;
+ case 'd':
+ dflag = 1;
+ break;
case 'D':
format = D_IFDEF;
ifdefname = optarg;
@@ -361,11 +365,11 @@ __dead void
usage(void)
{
(void)fprintf(stderr,
- "usage: diff [-bilqtTw] [-c | -e | -f | -n | -u] [-L label] file1 file2\n"
- " diff [-bilqtTw] [-L label] -C number file1 file2\n"
- " diff [-bilqtw] -D string file1 file2\n"
- " diff [-bilqtTw] [-L label] -U number file1 file2\n"
- " diff [-bilNPqwtT] [-c | -e | -f | -n | -u ] [-L label] [-r] [-s] [-S name]\n"
+ "usage: diff [-bdilqtTw] [-c | -e | -f | -n | -u] [-L label] file1 file2\n"
+ " diff [-bdilqtTw] [-L label] -C number file1 file2\n"
+ " diff [-bdilqtw] -D string file1 file2\n"
+ " diff [-bdilqtTw] [-L label] -U number file1 file2\n"
+ " diff [-bdilNPqwtT] [-c | -e | -f | -n | -u ] [-L label] [-r] [-s] [-S name]\n"
" [-X file] [-x pattern] dir1 dir2\n");
exit(2);