Let cmp(1) grow in -x option to print differences in contemporarry hex
format rather than the mixed decimal/octal format of -l.
This commit is contained in:
parent
0669702c01
commit
e03983a32c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=60583
@ -66,6 +66,11 @@ byte values (octal) for each difference.
|
||||
.It Fl s
|
||||
Print nothing for differing files; return exit
|
||||
status only.
|
||||
.It Fl x
|
||||
Like
|
||||
.Fl l
|
||||
but prints in hexadecimal and using zero as index
|
||||
for the first byte in the files.
|
||||
.El
|
||||
.Pp
|
||||
The optional arguments
|
||||
|
@ -29,6 +29,9 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -53,7 +56,7 @@ static const char sccsid[] = "@(#)cmp.c 8.3 (Berkeley) 4/2/94";
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
int lflag, sflag;
|
||||
int lflag, sflag, xflag;
|
||||
|
||||
static void usage __P((void));
|
||||
|
||||
@ -67,7 +70,7 @@ main(argc, argv)
|
||||
int ch, fd1, fd2, special;
|
||||
char *file1, *file2;
|
||||
|
||||
while ((ch = getopt(argc, argv, "-ls")) != -1)
|
||||
while ((ch = getopt(argc, argv, "-lsx")) != -1)
|
||||
switch (ch) {
|
||||
case 'l': /* print all differences */
|
||||
lflag = 1;
|
||||
@ -75,6 +78,10 @@ main(argc, argv)
|
||||
case 's': /* silent run */
|
||||
sflag = 1;
|
||||
break;
|
||||
case 'x': /* hex output */
|
||||
lflag = 1;
|
||||
xflag = 1;
|
||||
break;
|
||||
case '-': /* stdin (must be after options) */
|
||||
--optind;
|
||||
goto endargs;
|
||||
|
@ -31,6 +31,9 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.3 (Berkeley) 4/2/94
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
|
||||
#define OK_EXIT 0
|
||||
@ -42,4 +45,4 @@ void c_special __P((int, char *, off_t, int, char *, off_t));
|
||||
void diffmsg __P((char *, char *, off_t, off_t));
|
||||
void eofmsg __P((char *));
|
||||
|
||||
extern int lflag, sflag;
|
||||
extern int lflag, sflag, xflag;
|
||||
|
@ -29,6 +29,9 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -96,7 +99,10 @@ c_regular(fd1, file1, skip1, len1, fd2, file2, skip2, len2)
|
||||
p2 += skip2 - off2;
|
||||
for (byte = line = 1; length--; ++p1, ++p2, ++byte) {
|
||||
if ((ch = *p1) != *p2) {
|
||||
if (lflag) {
|
||||
if (xflag) {
|
||||
dfound = 1;
|
||||
(void)printf("%08x %02x %02x\n", byte - 1, ch, *p2);
|
||||
} else if (lflag) {
|
||||
dfound = 1;
|
||||
(void)printf("%6qd %3o %3o\n", byte, ch, *p2);
|
||||
} else
|
||||
|
Loading…
Reference in New Issue
Block a user