From 6e1cdb789851051167e5021ec9a2a4484deaf234 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Fri, 10 Feb 2012 16:11:30 -0800 Subject: [PATCH] Make strtoi() do the right thing for base==16 Before, strtoi("11", 0, 16) returned 11. Now, strtoi("11", 0, 16) returns 17. BUG=none TEST=none --- common/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/util.c b/common/util.c index 885d830175..40908cc5ce 100644 --- a/common/util.c +++ b/common/util.c @@ -88,11 +88,11 @@ int strtoi(const char *nptr, char **endptr, int base) while((c = *nptr++) && isspace(c)) {} - if (c == '0' && *nptr == 'x' && (base == 0 || base == 16)) { + if (c == '0' && *nptr == 'x') { base = 16; c = nptr[1]; nptr += 2; - } else { + } else if (base == 0) { base = 10; if (c == '-') { neg = 1;