Fix small issue in strings(1) loop

It wouldn't print the len'th character.
This commit is contained in:
FRIGN 2015-02-17 18:10:22 +01:00
parent aa6ac30b81
commit 439bf8a157

View File

@ -21,23 +21,23 @@ strings(FILE *fp, const char *fname, size_t len)
off += bread; off += bread;
if (r == Runeerror) if (r == Runeerror)
continue; continue;
else if (!isprintrune(r)) { if (!isprintrune(r)) {
if (i > len) if (i > len)
putchar('\n'); putchar('\n');
i = 0; i = 0;
continue; continue;
} }
if (i < len) { if (i <= len) {
rbuf[i++] = r; rbuf[i++] = r;
continue; if (i < len)
} else if (i > len) { continue;
} else {
efputrune(&r, stdout, "<stdout>"); efputrune(&r, stdout, "<stdout>");
continue; continue;
} }
printf(format, (long)off - i); printf(format, (long)off - i);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++)
efputrune(rbuf + i, stdout, "<stdout>"); efputrune(rbuf + i, stdout, "<stdout>");
}
i++; i++;
} }
free(rbuf); free(rbuf);