sbase

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

commit e5c1f0f372c0759b6f376e76c94f052c78f74bcb
parent 28d9b18e4c852ba8d7caaaa8f84e47a78473ea0c
Author: sin <sin@2f30.org>
Date:   Fri, 30 Jan 2015 13:56:45 +0000

Add estrtonum() as well

Diffstat:
Mlibutil/strtonum.c | 12++++++++++++
Mutil.h | 1+
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/libutil/strtonum.c b/libutil/strtonum.c @@ -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 @@ -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 *);