--- od.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/od.c b/od.c index 31f8179..9e382d1 100644 --- a/od.c +++ b/od.c _AT_@ -68,13 +68,13 @@ printchar(FILE *f, unsigned char c) } static void -od(FILE *in, char *in_name, FILE *out, char *out_name) +od(FILE *in, char *in_name, FILE *out, char *out_name, int lastarg) { - off_t addr; + static off_t addr = 0; size_t i, chunklen; unsigned char buf[BUFSIZ]; - for (addr = 0; (chunklen = fread(buf, 1, BUFSIZ, in)); ) { + for ( ; (chunklen = fread(buf, 1, BUFSIZ, in)); ) { for (i = 0; i < chunklen && (maxbytes == -1 || (addr - skip) < maxbytes); ++i, ++addr) { if (addr - skip < 0) _AT_@ -89,11 +89,13 @@ od(FILE *in, char *in_name, FILE *out, char *out_name) if (feof(in) || ferror(in) || ferror(out)) break; } - if (addr - skip > 0) - fputc('\n', out); - if (radix != 'n') { - printaddress(out, MAX(addr, skip)); - fputc('\n', out); + if (lastarg) { + if (addr - skip > 0) + fputc('\n', out); + if (radix != 'n') { + printaddress(out, MAX(addr, skip)); + fputc('\n', out); + } } } _AT_@ -139,7 +141,7 @@ main(int argc, char *argv[]) } ARGEND; if (!argc) { - od(stdin, "<stdin>", stdout, "<stdout>"); + od(stdin, "<stdin>", stdout, "<stdout>", 1); } else { for (; *argv; argc--, argv++) { if (!strcmp(*argv, "-")) { _AT_@ -150,7 +152,7 @@ main(int argc, char *argv[]) ret = 1; continue; } - od(fp, *argv, stdout, "<stdout>"); + od(fp, *argv, stdout, "<stdout>", *(argv + 1) ? 0 : 1); if (fp != stdin && fshut(fp, *argv)) ret = 1; } -- 1.9.1 --------------080308000700020208050102--Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Fri Oct 02 2015 - 17:12:14 CEST