From 783b1a479dddb330cb4c32dda0ea5477474add42 Mon Sep 17 00:00:00 2001 From: davidot Date: Wed, 12 Oct 2022 02:23:50 +0200 Subject: LibJS: Make string_to_double use the new double parser --- Userland/Libraries/LibJS/Runtime/Value.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Userland/Libraries/LibJS') diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 5ed60fefd9..9ea8b4f4aa 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -549,12 +550,11 @@ Optional string_to_number(StringView string) return Value(bigint.to_double()); } - char* endptr; - auto parsed_double = strtod(text.characters(), &endptr); - if (*endptr) + auto maybe_double = text.to_double(AK::TrimWhitespace::No); + if (!maybe_double.has_value()) return js_nan(); - return Value(parsed_double); + return Value(*maybe_double); } // 7.1.4 ToNumber ( argument ), https://tc39.es/ecma262/#sec-tonumber -- cgit v1.2.3