sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit ad442060b822ade3cd1f7d7dac3daf29fb954f38
parent a2be57eca8b81efad54b9dcab48c4717f15b6ebd
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Thu May 26 16:29:22 -0100

tail cleanup
Diffstat:
tail.c | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/tail.c b/tail.c @@ -9,14 +9,13 @@ static void dropinit(FILE *, const char *, long); static void taketail(FILE *, const char *, long); -static void (*tail)(FILE *, const char *, long) = taketail; - int main(int argc, char *argv[]) { char *end, c; long n = 10; FILE *fp; + void (*tail)(FILE *, const char *, long) = taketail; while((c = getopt(argc, argv, "n:")) != -1) switch(c) { @@ -67,6 +66,8 @@ taketail(FILE *fp, const char *str, long n) eprintf("calloc:"); for(i = j = 0; afgets(&ring[i], &size[i], fp); i = j = (i+1)%n) ; + if(ferror(fp)) + eprintf("%s: read error:", str); do { if(ring[j]) { @@ -76,7 +77,4 @@ taketail(FILE *fp, const char *str, long n) } while((j = (j+1)%n) != i); free(ring); free(size); - - if(ferror(fp)) - eprintf("%s: read error:", str); }