summaryrefslogtreecommitdiff
path: root/common/lib/libc/stdlib
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2015-11-12 17:23:51 +0000
committerchristos <christos@NetBSD.org>2015-11-12 17:23:51 +0000
commita7e8ac65dfcb32a4a91381da347692f61590c5dc (patch)
treeb2b7008f95a4c1b17a785bbcd15428e35078bd32 /common/lib/libc/stdlib
parent411f3e278e958dcd84e006605d0645201a34b203 (diff)
Recognize 0[bB] as binary (base 2)
Diffstat (limited to 'common/lib/libc/stdlib')
-rw-r--r--common/lib/libc/stdlib/_strtol.h10
-rw-r--r--common/lib/libc/stdlib/_strtoul.h10
2 files changed, 14 insertions, 6 deletions
diff --git a/common/lib/libc/stdlib/_strtol.h b/common/lib/libc/stdlib/_strtol.h
index 1901e560d22..ac7d9669f19 100644
--- a/common/lib/libc/stdlib/_strtol.h
+++ b/common/lib/libc/stdlib/_strtol.h
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtol.h,v 1.7 2013/05/17 12:55:56 joerg Exp $ */
+/* $NetBSD: _strtol.h,v 1.8 2015/11/12 17:23:51 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -105,8 +105,12 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr,
c = s[1];
s += 2;
base = 16;
- }
- if (base == 0)
+ } else if ((base == 0 || base == 2) &&
+ c == '0' && (*s == 'b' || *s == 'b')) {
+ c = s[1];
+ s += 2;
+ base = 2;
+ } else if (base == 0)
base = (c == '0' ? 8 : 10);
/*
diff --git a/common/lib/libc/stdlib/_strtoul.h b/common/lib/libc/stdlib/_strtoul.h
index 27e2e079d3a..6fe33d26c6a 100644
--- a/common/lib/libc/stdlib/_strtoul.h
+++ b/common/lib/libc/stdlib/_strtoul.h
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoul.h,v 1.7 2013/05/17 12:55:56 joerg Exp $ */
+/* $NetBSD: _strtoul.h,v 1.8 2015/11/12 17:23:51 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -102,8 +102,12 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr,
c = s[1];
s += 2;
base = 16;
- }
- if (base == 0)
+ } else if ((base == 0 || base == 2) &&
+ c == '0' && (*s == 'b' || *s == 'B')) {
+ c = s[1];
+ s += 2;
+ base = 2;
+ } else if (base == 0)
base = (c == '0' ? 8 : 10);
/*