mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
AK: Fix JsonParser kernel build (no floats/doubles in kernel code)
This commit is contained in:
parent
faddf3a1db
commit
e34fe556ca
Notes:
sideshowbarker
2024-07-19 08:08:35 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e34fe556cad
1 changed files with 6 additions and 2 deletions
|
@ -190,6 +190,8 @@ JsonValue JsonParser::parse_string()
|
|||
|
||||
JsonValue JsonParser::parse_number()
|
||||
{
|
||||
bool ok;
|
||||
JsonValue value;
|
||||
Vector<char, 128> number_buffer;
|
||||
Vector<char, 128> fraction_buffer;
|
||||
|
||||
|
@ -214,9 +216,8 @@ JsonValue JsonParser::parse_number()
|
|||
|
||||
StringView number_string(number_buffer.data(), number_buffer.size());
|
||||
StringView fraction_string(fraction_buffer.data(), fraction_buffer.size());
|
||||
bool ok;
|
||||
JsonValue value;
|
||||
|
||||
#ifndef KERNEL
|
||||
if (is_double) {
|
||||
int whole = number_string.to_uint(ok);
|
||||
if (!ok)
|
||||
|
@ -232,11 +233,14 @@ JsonValue JsonParser::parse_number()
|
|||
}
|
||||
value = JsonValue((double)whole + ((double)fraction / divider));
|
||||
} else {
|
||||
#endif
|
||||
value = JsonValue(number_string.to_uint(ok));
|
||||
if (!ok)
|
||||
value = JsonValue(number_string.to_int(ok));
|
||||
ASSERT(ok);
|
||||
#ifndef KERNEL
|
||||
}
|
||||
#endif
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue