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
5
od.c
5
od.c
|
@ -134,7 +134,7 @@ od(FILE *fp, char *fname, int last)
|
|||
static off_t addr;
|
||||
size_t buflen;
|
||||
|
||||
while (skip - addr) {
|
||||
while (skip - addr > 0) {
|
||||
buflen = fread(buf, 1, MIN(skip - addr, BUFSIZ), fp);
|
||||
addr += buflen;
|
||||
if (feof(fp) || ferror(fp))
|
||||
|
@ -153,8 +153,9 @@ od(FILE *fp, char *fname, int last)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (lineoff)
|
||||
if (lineoff && last)
|
||||
printline(line, lineoff, addr - lineoff);
|
||||
if (last)
|
||||
printline((unsigned char *)"", 0, addr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user