sbase

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

commit afb1f0ead09220cdb3d566b3fdb8ba0304c50f2b
parent ba456787cbaf1c90cdda268c86ee1b26a774eeff
Author: Connor Lane Smith <cls@lubutu.com>
Date:   Fri, 10 Jun 2011 05:46:20 +0100

whoops, add strnum.c
Diffstat:
Autil/strnum.c | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/util/strnum.c b/util/strnum.c @@ -0,0 +1,20 @@ +/* See LICENSE file for copyright and license details. */ +#include <stdio.h> +#include <stdlib.h> +#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; +}