Add estrtonum() as well

This commit is contained in:
sin 2015-01-30 13:56:45 +00:00
parent 28d9b18e4c
commit e5c1f0f372
2 changed files with 13 additions and 0 deletions

View File

@ -65,3 +65,15 @@ strtonum(const char *numstr, long long minval, long long maxval,
return (ll); 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;
}

1
util.h
View File

@ -59,4 +59,5 @@ void putword(const char *);
void recurse(const char *, void (*)(const char *)); void recurse(const char *, void (*)(const char *));
#undef strtonum #undef strtonum
long long strtonum(const char *, long long, long long, const char **); long long strtonum(const char *, long long, long long, const char **);
long long estrtonum(const char *, long long, long long);
size_t unescape(char *); size_t unescape(char *);