[hackers] [sbase] Add estrtonum() as well || sin

From: <git_AT_suckless.org>
Date: Fri, 30 Jan 2015 15:07:38 +0100 (CET)

commit 67f65ae1aba4741dfba9e4bbb0cede2b132f2be3
Author: sin <sin_AT_2f30.org>
Date: Fri Jan 30 13:56:45 2015 +0000

    Add estrtonum() as well

diff --git a/libutil/strtonum.c b/libutil/strtonum.c
index 7d0b583..18eb8aa 100644
--- a/libutil/strtonum.c
+++ b/libutil/strtonum.c
_AT_@ -65,3 +65,15 @@ strtonum(const char *numstr, long long minval, long long maxval,
 
         return (ll);
 }
+
+long long
+estrtonum(const char *numstr, long long minval, long long maxval)
+{
+ const char *errstr;
+ long long ll;
+
+ ll = strtonum(numstr, minval, maxval, &errstr);
+ if (errstr)
+ eprintf("strtonum %s: invalid value\n", numstr);
+ return ll;
+}
diff --git a/util.h b/util.h
index 9d2c5dd..ca02be9 100644
--- a/util.h
+++ b/util.h
_AT_@ -59,4 +59,5 @@ void putword(const char *);
 void recurse(const char *, void (*)(const char *));
 #undef strtonum
 long long strtonum(const char *, long long, long long, const char **);
+long long estrtonum(const char *, long long, long long);
 size_t unescape(char *);
Received on Fri Jan 30 2015 - 15:07:38 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 30 2015 - 15:12:09 CET