From 5cf680997e31230988e7f6aaf4e35991972bb3b0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 28 Jul 2019 12:56:59 +0200 Subject: [PATCH] implement atoi36 with strtol --- src/util/base36.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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) {