5 #include "lib/strntol.h"
7 long strntol(const char *str, size_t sz, char **end, int base)
9 /* Expect that digit representation of LONG_MAX/MIN
10 * not greater than this buffer */
13 const char *beg = str;
15 /* Catch up leading spaces */
16 for (; beg && sz && *beg == ' '; beg++, sz--)
19 if (!sz || sz >= sizeof(buf)) {
27 ret = strtol(buf, end, base);
28 if (ret == LONG_MIN || ret == LONG_MAX)
31 *end = (char *)str + (*end - buf);