[hackers] [sbase] Convert tail(1) to use size_t || FRIGN

From: <git_AT_suckless.org>
Date: Tue, 24 Mar 2015 23:53:38 +0100 (CET)

commit 78f33ff069d916d409c4457e61f86490684daeaf
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 Tue Mar 24 2015 - 23:53:38 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 25 2015 - 00:08:35 CET