From afb1f0ead09220cdb3d566b3fdb8ba0304c50f2b Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Fri, 10 Jun 2011 05:46:20 +0100 Subject: [PATCH] whoops, add strnum.c --- util/strnum.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 util/strnum.c diff --git a/util/strnum.c b/util/strnum.c new file mode 100644 index 0000000..14f2f88 --- /dev/null +++ b/util/strnum.c @@ -0,0 +1,20 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include "../util.h" + +long +strnum(const char *s, int base) +{ + char *end; + long n; + + n = strtol(s, &end, base); + if(*end != '\0') { + if(base == 0) + eprintf("%s: not a number\n", s); + else + eprintf("%s: not a base %d number\n", s, base); + } + return n; +}