Module Name: src
Committed By: christos
Date: Sun Oct 30 19:13:37 UTC 2016
Modified Files:
src/usr.bin/cmp: cmp.1 cmp.c
Log Message:
add a flag to avoid mmap...
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/cmp/cmp.1
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/cmp/cmp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/cmp/cmp.1
diff -u src/usr.bin/cmp/cmp.1:1.9 src/usr.bin/cmp/cmp.1:1.10
--- src/usr.bin/cmp/cmp.1:1.9 Thu Aug 7 07:13:21 2003
+++ src/usr.bin/cmp/cmp.1 Sun Oct 30 15:13:36 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: cmp.1,v 1.9 2003/08/07 11:13:21 agc Exp $
+.\" $NetBSD: cmp.1,v 1.10 2016/10/30 19:13:36 christos Exp $
.\"
.\" Copyright (c) 1987, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" @(#)cmp.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd June 6, 1993
+.Dd October 30, 2016
.Dt CMP 1
.Os
.Sh NAME
@@ -40,7 +40,7 @@
.Nd compare two files
.Sh SYNOPSIS
.Nm
-.Op Fl l | Fl s
+.Op Fl c | Fl l | Fl s
.Ar file1 file2
.Op Ar skip1 Op Ar skip2
.Sh DESCRIPTION
@@ -55,6 +55,15 @@ Bytes and lines are numbered beginning w
.Pp
The following options are available:
.Bl -tag -width flag
+.It Fl c
+Do the compare using
+.Xr getc 3
+rather than
+.Xr mmap 2 .
+Combined with the
+.Fl l
+flag, this can be helpful in locating an I/O error in the underlying
+device.
.It Fl l
Print the byte number (decimal) and the differing
byte values (octal) for each difference.
Index: src/usr.bin/cmp/cmp.c
diff -u src/usr.bin/cmp/cmp.c:1.18 src/usr.bin/cmp/cmp.c:1.19
--- src/usr.bin/cmp/cmp.c:1.18 Mon Aug 29 10:14:11 2011
+++ src/usr.bin/cmp/cmp.c Sun Oct 30 15:13:36 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: cmp.c,v 1.18 2011/08/29 14:14:11 joerg Exp $ */
+/* $NetBSD: cmp.c,v 1.19 2016/10/30 19:13:36 christos Exp $ */
/*
* Copyright (c) 1987, 1990, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19
#if 0
static char sccsid[] = "@(#)cmp.c 8.3 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: cmp.c,v 1.18 2011/08/29 14:14:11 joerg Exp $");
+__RCSID("$NetBSD: cmp.c,v 1.19 2016/10/30 19:13:36 christos Exp $");
#endif
#endif /* not lint */
@@ -71,8 +71,12 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
- while ((ch = getopt(argc, argv, "ls")) != -1)
+ special = 0;
+ while ((ch = getopt(argc, argv, "cls")) != -1)
switch (ch) {
+ case 'c':
+ special = 1; /* careful! Don't use mmap() */
+ break;
case 'l': /* print all differences */
lflag = 1;
break;
@@ -93,7 +97,6 @@ main(int argc, char *argv[])
usage();
/* Backward compatibility -- handle "-" meaning stdin. */
- special = 0;
if (strcmp(file1 = argv[0], "-") == 0) {
special = 1;
fd1 = 0;
@@ -159,6 +162,6 @@ usage(void)
{
(void)fprintf(stderr,
- "usage: cmp [-l | -s] file1 file2 [skip1 [skip2]]\n");
+ "usage: cmp [-c | -l | -s] file1 file2 [skip1 [skip2]]\n");
exit(ERR_EXIT);
}