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.
This commit is contained in:
parent
4ef875d707
commit
b001517f54
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user