summaryrefslogtreecommitdiffstats
path: root/usr.bin/hexdump
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>1998-12-13 06:40:18 +0000
committerdillon <dillon@FreeBSD.org>1998-12-13 06:40:18 +0000
commita9cca9c815fe1d2b280f4312a83866b0b14b57ce (patch)
treec46e85b4ff0367f53686d020454a7d99368eae54 /usr.bin/hexdump
parentd2013aefd04d7ec6dcceccae50845084d5fe80e2 (diff)
downloadFreeBSD-src-a9cca9c815fe1d2b280f4312a83866b0b14b57ce.zip
FreeBSD-src-a9cca9c815fe1d2b280f4312a83866b0b14b57ce.tar.gz
PR: bin/9016
Fix bug with od/hd/hexdump. "*" lines are supposed to indicate one or duplicates of the previous line, but a small file with less then 16 characters of zeros in it will be falsy identified as a repeat of the (non-existant) previous line. i.e. the first line of output winds up being a "*". Added a bit of code to handle the degenerate 'there is no previous line' case for the first line.
Diffstat (limited to 'usr.bin/hexdump')
-rw-r--r--usr.bin/hexdump/display.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c
index 0a74542..b72da84 100644
--- a/usr.bin/hexdump/display.c
+++ b/usr.bin/hexdump/display.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)display.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: display.c,v 1.2 1997/07/10 06:48:12 charnier Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -234,6 +234,7 @@ get()
static u_char *curp, *savp;
register int n;
int need, nread;
+ int valid_save = 0;
u_char *tmpp;
if (!curp) {
@@ -244,6 +245,7 @@ get()
curp = savp;
savp = tmpp;
address += blocksize;
+ valid_save = 1;
}
for (need = blocksize, nread = 0;;) {
/*
@@ -254,7 +256,9 @@ get()
if (!length || ateof && !next((char **)NULL)) {
if (need == blocksize)
return((u_char *)NULL);
- if (vflag != ALL && !bcmp(curp, savp, nread)) {
+ if (vflag != ALL &&
+ valid_save &&
+ bcmp(curp, savp, nread) == 0) {
if (vflag != DUP)
(void)printf("*\n");
return((u_char *)NULL);
@@ -276,7 +280,8 @@ get()
length -= n;
if (!(need -= n)) {
if (vflag == ALL || vflag == FIRST ||
- bcmp(curp, savp, blocksize)) {
+ valid_save == 0 ||
+ bcmp(curp, savp, blocksize) != 0) {
if (vflag == DUP || vflag == FIRST)
vflag = WAIT;
return(curp);
OpenPOWER on IntegriCloud