diff --git a/src/util/base36.c b/src/util/base36.c index 3fc0b354f..ec41991d8 100644 --- a/src/util/base36.c +++ b/src/util/base36.c @@ -21,12 +21,20 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "log.h" #include +#include #include #include +#define USE_STRTOL +#ifdef USE_STRTOL +int atoi36(const char *str) +{ + assert(str); + return (int)strtol(str, NULL, 36); +} +#else int atoi36(const char *str) { - /* cannot use strtol, because invalid strings will cause crash */ const unsigned char *s = (const unsigned char *)str; int i = 0, sign = 1; assert(s); @@ -51,6 +59,7 @@ int atoi36(const char *str) return 0; return i * sign; } +#endif const char *itoab_r(int i, int base, char *s, size_t len) {