Merge pull request #135 from mknos/str2i64_forever

Str2I64(): rewrite radix detection loop as while
This commit is contained in:
Arsenic Blood 2023-10-31 13:16:56 -04:00 committed by GitHub
commit ea49d4aaf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,10 +15,8 @@ I64 Str2I64(U8 *st, I64 radix=10, U8 **_end_ptr=NULL)
st++;
if (*st == '+' || *st == '-')
neg = *st++ == '-';
while (TRUE)
switch (*st)
while (*st == '0')
{
case '0':
st++;
ch = ToUpper(*st);
if (ch >= 'B' && (radix <= 10 || ch > 'A' + radix - 11))
@ -29,10 +27,7 @@ I64 Str2I64(U8 *st, I64 radix=10, U8 **_end_ptr=NULL)
case 'D': radix = 10; st++; break;
case 'X': radix = 16; st++; break;
}
default:
goto ai_cont;
}
ai_cont:
while (ch = ToUpper(*st++))
{
if (radix > 10)