Date: 14 Dec 2002 02:47:17 -0000 From: Colin Percival <cperciva@sfu.ca> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/46249: [PATCH] /usr/bin/cmp -x ignored on special files Message-ID: <20021214024717.53827.qmail@www.idlepower.net>
next in thread | raw e-mail | index | archive | help
>Number: 46249
>Category: bin
>Synopsis: [PATCH] /usr/bin/cmp -x ignored on special files
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Dec 13 18:50:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Colin Percival
>Release: FreeBSD 5.0-CURRENT
>Organization:
>Environment:
System: All versions of FreeBSD since 4.1-RELEASE
>Description:
phk added the -x option in May 2000, but only for regular files; for
special files it is treated like -l
>How-To-Repeat:
#echo "hello" | (echo "hbllo" | cmp -x /dev/fd/0 /dev/fd/3) 3<&0
2 142 145
#echo "hello" > temp1; echo "hbllo" > temp2; cmp -x temp2 temp1
00000001 62 65
#echo "hello" > temp1; echo "hbllo" > temp2; cmp -l temp2 temp1
2 142 145
>Fix:
Add code to special.c to match the code in regular.c
The following patches apply to -CURRENT and -STABLE respectively.
--- HEAD.diff begins here ---
Index: special.c
===================================================================
RCS file: /usr/cvsroot/src/usr.bin/cmp/special.c,v
retrieving revision 1.9
diff -u -r1.9 special.c
--- special.c 28 Jul 2002 15:13:17 -0000 1.9
+++ special.c 14 Dec 2002 02:26:57 -0000
@@ -77,7 +77,11 @@
if (ch1 == EOF || ch2 == EOF)
break;
if (ch1 != ch2) {
- if (lflag) {
+ if (xflag) {
+ dfound = 1;
+ (void)printf("%08llx %02x %02x\n",
+ (long long)byte - 1, ch1, ch2);
+ } else if (lflag) {
dfound = 1;
(void)printf("%6lld %3o %3o\n",
(long long)byte, ch1, ch2);
--- HEAD.diff ends here ---
--- RELENG4.diff begins here ---
Index: special.c
===================================================================
RCS file: /usr/cvsroot/src/usr.bin/cmp/special.c,v
retrieving revision 1.4.2.1
diff -u -r1.4.2.1 special.c
--- special.c 21 Nov 2001 10:47:54 -0000 1.4.2.1
+++ special.c 14 Dec 2002 02:22:53 -0000
@@ -77,7 +77,10 @@
if (ch1 == EOF || ch2 == EOF)
break;
if (ch1 != ch2) {
- if (lflag) {
+ if (xflag) {
+ dfound = 1;
+ (void)printf("%08qx %02x %02x\n", byte-1, ch1, ch2);
+ } else if (lflag) {
dfound = 1;
(void)printf("%6qd %3o %3o\n", byte, ch1, ch2);
} else {
--- RELENG4.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021214024717.53827.qmail>
