Recognize 0[bB] as binary (base 2)

This commit is contained in:
christos 2015-11-12 17:23:51 +00:00
parent 6c340bb484
commit 557b696a7a
2 changed files with 14 additions and 6 deletions

View File

@ -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);
/*

View File

@ -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);
/*