mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
LibC: Make strtoull accept the '0x' prefix when base 16 is specified
Dr.POSIX says it should be.
This commit is contained in:
parent
5729e76c7d
commit
0bf496f864
1 changed files with 8 additions and 0 deletions
|
@ -991,6 +991,14 @@ unsigned long long strtoull(const char* str, char** endptr, int base)
|
|||
char* parse_ptr = const_cast<char*>(str);
|
||||
strtons(parse_ptr, &parse_ptr);
|
||||
|
||||
if (base == 16) {
|
||||
// Dr. POSIX: "If the value of base is 16, the characters 0x or 0X may optionally precede
|
||||
// the sequence of letters and digits, following the sign if present."
|
||||
if (*parse_ptr == '0') {
|
||||
if (tolower(*(parse_ptr + 1)) == 'x')
|
||||
parse_ptr += 2;
|
||||
}
|
||||
}
|
||||
// Parse base
|
||||
if (base == 0) {
|
||||
if (*parse_ptr == '0') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue