libc/stdlib: Refine octal check of lib_checkbase()
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
02f1503f9f
commit
9320638848
|
@ -69,21 +69,21 @@ int lib_checkbase(int base, FAR const char **pptr)
|
|||
|
||||
if (*ptr == '0')
|
||||
{
|
||||
if (ptr[1] != '\0')
|
||||
{
|
||||
/* Assume octal */
|
||||
/* Assume octal */
|
||||
|
||||
if (lib_isbasedigit(ptr[1], 8, NULL))
|
||||
{
|
||||
base = 8;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* Check for hexadecimal */
|
||||
/* Check for hexadecimal */
|
||||
|
||||
if ((*ptr == 'X' || *ptr == 'x') &&
|
||||
lib_isbasedigit(ptr[1], 16, NULL))
|
||||
{
|
||||
base = 16;
|
||||
ptr++;
|
||||
}
|
||||
else if ((ptr[1] == 'X' || ptr[1] == 'x') &&
|
||||
lib_isbasedigit(ptr[2], 16, NULL))
|
||||
{
|
||||
base = 16;
|
||||
ptr += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue