[hackers] [sbase] Convert tail(1) to use size_t || FRIGN
commit fbed17362d8255c30ca0bf5477e86c38e44b6dc2
Author: FRIGN <dev_AT_frign.de>
Date: Mon Feb 9 15:30:23 2015 +0100
Convert tail(1) to use size_t
diff --git a/tail.c b/tail.c
index b97ed5c..760d676 100644
--- a/tail.c
+++ b/tail.c
_AT_@ -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>
_AT_@ -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;
_AT_@ -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;
_AT_@ -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':
_AT_@ -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;
Received on Mon Feb 09 2015 - 16:25:08 CET
This archive was generated by hypermail 2.3.0
: Mon Feb 09 2015 - 16:36:13 CET