Fix multiple file handling
1) Fix skip overflow for negative numbers 2) Print proper trailing lines and addresses according to the last element.
This commit is contained in:
parent
1e4ab5ec9a
commit
91ab4e80b9
7
od.c
7
od.c
@ -134,7 +134,7 @@ od(FILE *fp, char *fname, int last)
|
|||||||
static off_t addr;
|
static off_t addr;
|
||||||
size_t buflen;
|
size_t buflen;
|
||||||
|
|
||||||
while (skip - addr) {
|
while (skip - addr > 0) {
|
||||||
buflen = fread(buf, 1, MIN(skip - addr, BUFSIZ), fp);
|
buflen = fread(buf, 1, MIN(skip - addr, BUFSIZ), fp);
|
||||||
addr += buflen;
|
addr += buflen;
|
||||||
if (feof(fp) || ferror(fp))
|
if (feof(fp) || ferror(fp))
|
||||||
@ -153,9 +153,10 @@ od(FILE *fp, char *fname, int last)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lineoff)
|
if (lineoff && last)
|
||||||
printline(line, lineoff, addr - lineoff);
|
printline(line, lineoff, addr - lineoff);
|
||||||
printline((unsigned char *)"", 0, addr);
|
if (last)
|
||||||
|
printline((unsigned char *)"", 0, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user