[hackers] [sbase] Fix multiple file handling || FRIGN

From: <git_AT_suckless.org>
Date: Mon, 26 Oct 2015 17:53:33 +0100 (CET)

commit 91ab4e80b92637f2f95f61c73a6c848a35ddddea
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Mon Oct 26 17:21:15 2015 +0100
Commit: sin <sin_AT_2f30.org>
CommitDate: Mon Oct 26 16:53:28 2015 +0000

    Fix multiple file handling
    
    1) Fix skip overflow for negative numbers
    2) Print proper trailing lines and addresses according to the last
       element.

diff --git a/od.c b/od.c
index 8277597..1debe04 100644
--- a/od.c
+++ b/od.c
_AT_@ -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))
_AT_@ -153,9 +153,10 @@ od(FILE *fp, char *fname, int last)
                         }
                 }
         }
- if (lineoff)
+ if (lineoff && last)
                 printline(line, lineoff, addr - lineoff);
- printline((unsigned char *)"", 0, addr);
+ if (last)
+ printline((unsigned char *)"", 0, addr);
 }
 
 static int
Received on Mon Oct 26 2015 - 17:53:33 CET

This archive was generated by hypermail 2.3.0 : Mon Oct 26 2015 - 18:00:12 CET