aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/locale/wcstoul.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/locale/wcstoul.c')
-rw-r--r--lib/libc/locale/wcstoul.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libc/locale/wcstoul.c b/lib/libc/locale/wcstoul.c
index 12f65c577605..b4fa4d439e10 100644
--- a/lib/libc/locale/wcstoul.c
+++ b/lib/libc/locale/wcstoul.c
@@ -34,9 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <ctype.h>
#include <errno.h>
#include <limits.h>
@@ -74,11 +71,21 @@ wcstoul_l(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr,
c = *s++;
}
if ((base == 0 || base == 16) &&
- c == L'0' && (*s == L'x' || *s == L'X')) {
+ c == L'0' && (*s == L'x' || *s == L'X') &&
+ ((s[1] >= L'0' && s[1] <= L'9') ||
+ (s[1] >= L'A' && s[1] <= L'F') ||
+ (s[1] >= L'a' && s[1] <= L'f'))) {
c = s[1];
s += 2;
base = 16;
}
+ if ((base == 0 || base == 2) &&
+ c == L'0' && (*s == L'b' || *s == L'B') &&
+ (s[1] >= L'0' && s[1] <= L'1')) {
+ c = s[1];
+ s += 2;
+ base = 2;
+ }
if (base == 0)
base = c == L'0' ? 8 : 10;
acc = any = 0;