sbase

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

commit 78f33ff069d916d409c4457e61f86490684daeaf
parent 080a1ee8333718a0b09cfbb8de12c34dfe4b4363
Author: FRIGN <dev@frign.de>
Date:   Mon,  9 Feb 2015 15:30:23 +0100

Convert tail(1) to use size_t

Diffstat:
Mtail.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tail.c b/tail.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include <limits.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -11,7 +12,7 @@ static int fflag = 0; static void -dropinit(FILE *fp, const char *str, long n) +dropinit(FILE *fp, const char *str, size_t n) { char *buf = NULL; size_t size = 0; @@ -26,7 +27,7 @@ dropinit(FILE *fp, const char *str, long n) } static void -taketail(FILE *fp, const char *str, long n) +taketail(FILE *fp, const char *str, size_t n) { char **ring = NULL; long i, j; @@ -64,7 +65,7 @@ main(int argc, char *argv[]) size_t n = 10, tmpsize; int ret = 0, newline, many; char *lines, *tmp; - void (*tail)(FILE *, const char *, long) = taketail; + void (*tail)(FILE *, const char *, size_t) = taketail; ARGBEGIN { case 'f': @@ -72,7 +73,7 @@ main(int argc, char *argv[]) break; case 'n': lines = EARGF(usage()); - n = estrtonum(lines, 0, LONG_MAX); + n = estrtonum(lines, 0, MIN(LLONG_MAX, SIZE_MAX)); if (lines[0] == '+') tail = dropinit; break;