mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
Merge pull request #135 from mknos/str2i64_forever
Str2I64(): rewrite radix detection loop as while
This commit is contained in:
commit
ea49d4aaf2
1 changed files with 13 additions and 18 deletions
|
@ -15,24 +15,19 @@ I64 Str2I64(U8 *st, I64 radix=10, U8 **_end_ptr=NULL)
|
||||||
st++;
|
st++;
|
||||||
if (*st == '+' || *st == '-')
|
if (*st == '+' || *st == '-')
|
||||||
neg = *st++ == '-';
|
neg = *st++ == '-';
|
||||||
while (TRUE)
|
while (*st == '0')
|
||||||
switch (*st)
|
{
|
||||||
{
|
st++;
|
||||||
case '0':
|
ch = ToUpper(*st);
|
||||||
st++;
|
if (ch >= 'B' && (radix <= 10 || ch > 'A' + radix - 11))
|
||||||
ch = ToUpper(*st);
|
switch (ch)
|
||||||
if (ch >= 'B' && (radix <= 10 || ch > 'A' + radix - 11))
|
{
|
||||||
switch (ch)
|
case 'B': radix = 2; st++; break;
|
||||||
{
|
case 'O': radix = 8; st++; break;
|
||||||
case 'B': radix = 2; st++; break;
|
case 'D': radix = 10; st++; break;
|
||||||
case 'O': radix = 8; st++; break;
|
case 'X': radix = 16; st++; break;
|
||||||
case 'D': radix = 10; st++; break;
|
}
|
||||||
case 'X': radix = 16; st++; break;
|
}
|
||||||
}
|
|
||||||
default:
|
|
||||||
goto ai_cont;
|
|
||||||
}
|
|
||||||
ai_cont:
|
|
||||||
while (ch = ToUpper(*st++))
|
while (ch = ToUpper(*st++))
|
||||||
{
|
{
|
||||||
if (radix > 10)
|
if (radix > 10)
|
||||||
|
|
Loading…
Reference in a new issue