diff options
Diffstat (limited to 'lib/libc/iconv/_strtol.h')
-rw-r--r-- | lib/libc/iconv/_strtol.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/libc/iconv/_strtol.h b/lib/libc/iconv/_strtol.h index dee7bab733e8..94a13c56db98 100644 --- a/lib/libc/iconv/_strtol.h +++ b/lib/libc/iconv/_strtol.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ /* $NetBSD: _strtol.h,v 1.2 2009/05/20 22:03:29 christos Exp $ */ /*- @@ -84,11 +83,21 @@ _FUNCNAME(const char *nptr, char **endptr, int base) c = *s++; } if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { + c == '0' && (*s == 'x' || *s == 'X') && + ((s[1] >= '0' && s[1] <= '9') || + (s[1] >= 'A' && s[1] <= 'F') || + (s[1] >= 'a' && s[1] <= 'f'))) { c = s[1]; s += 2; base = 16; } + if ((base == 0 || base == 2) && + c == '0' && (*s == 'b' || *s == 'B') && + (s[1] >= '0' && s[1] <= '1')) { + c = s[1]; + s += 2; + base = 2; + } if (base == 0) base = (c == '0' ? 8 : 10); |