From cperciva@www.idlepower.net  Fri Dec 13 18:47:32 2002
Return-Path: <cperciva@www.idlepower.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5622137B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Dec 2002 18:47:32 -0800 (PST)
Received: from www.idlepower.net (h24-79-84-133.vc.shawcable.net [24.79.84.133])
	by mx1.FreeBSD.org (Postfix) with SMTP id 589D043ED1
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Dec 2002 18:47:31 -0800 (PST)
	(envelope-from cperciva@www.idlepower.net)
Received: (qmail 53829 invoked by uid 0); 14 Dec 2002 02:47:18 -0000
Received: (for user cperciva)
Message-Id: <20021214024717.53827.qmail@www.idlepower.net>
Date: 14 Dec 2002 02:47:17 -0000
From: Colin Percival <cperciva@sfu.ca>
Reply-To: Colin Percival <cperciva@sfu.ca>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] /usr/bin/cmp -x ignored on special files
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         46249
>Category:       bin
>Synopsis:       [PATCH] /usr/bin/cmp -x ignored on special files
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    murray
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 13 18:50:00 PST 2002
>Closed-Date:    Thu Jul 10 01:20:48 PDT 2003
>Last-Modified:  Thu Jul 10 01:20:48 PDT 2003
>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:
Responsible-Changed-From-To: freebsd-bugs->murray 
Responsible-Changed-By: murray 
Responsible-Changed-When: Fri May 30 22:30:55 PDT 2003 
Responsible-Changed-Why:  
I'm looking at this and hope to address it after the freeze. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=46249 
State-Changed-From-To: open->patched 
State-Changed-By: murray 
State-Changed-When: Thu Jun 19 00:24:59 PDT 2003 
State-Changed-Why:  
Applied to -CURRENT.  I will MFC this in a week or so. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=46249 
State-Changed-From-To: patched->closed 
State-Changed-By: murray 
State-Changed-When: Thu Jul 10 01:20:30 PDT 2003 
State-Changed-Why:  
I've MFCed this to -STABLE.  Thanks for your patience. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=46249 
>Unformatted:
