mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-26 03:32:17 +00:00
bdk: strtol: support unsigned 32bit hex
If base is 16 and input is not negative allow unsigned 32bit parsing. This allows parsing numbers of up to 4294967295 in that case.
This commit is contained in:
parent
dab5eb9aa0
commit
c7333e710c
1 changed files with 4 additions and 3 deletions
|
@ -102,6 +102,7 @@ u64 sqrt64(u64 num)
|
|||
return square_root;
|
||||
}
|
||||
|
||||
#define TULONG_MAX ((unsigned long)((unsigned long)(~0L)))
|
||||
#define TLONG_MAX ((long)(((unsigned long)(~0L)) >> 1))
|
||||
#define TLONG_MIN ((long)(~TLONG_MAX))
|
||||
#define ISSPACE(ch) ((ch >= '\t' && ch <= '\r') || (ch == ' '))
|
||||
|
@ -162,7 +163,7 @@ long strtol(const char *nptr, char **endptr, register int base)
|
|||
* Set any if any `digits' consumed; make it negative to indicate
|
||||
* overflow.
|
||||
*/
|
||||
cutoff = neg ? -(unsigned long)TLONG_MIN : TLONG_MAX;
|
||||
cutoff = neg ? -(unsigned long)TLONG_MIN : (base == 16 ? TULONG_MAX : TLONG_MAX);
|
||||
cutlim = cutoff % (unsigned long)base;
|
||||
cutoff /= (unsigned long)base;
|
||||
for (acc = 0, any = 0;; c = *s++) {
|
||||
|
|
Loading…
Reference in a new issue