1
0
mirror of git://git.suckless.org/sbase synced 2024-12-23 15:34:38 +00:00
sbase/util/estrtol.c
2013-03-05 21:46:48 +01:00

27 lines
417 B
C

/* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "../util.h"
long
estrtol(const char *s, int base)
{
char *end;
long n;
errno = 0;
n = strtol(s, &end, base);
if(*end != '\0' || errno != 0) {
if(base == 0) {
eprintf("%s: not an integer\n", s);
} else {
eprintf("%s: not a base %d integer\n", s, base);
}
}
return n;
}