diff options
author | cjihrig <cjihrig@gmail.com> | 2020-12-07 23:46:58 -0500 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2021-02-11 19:09:53 +0100 |
commit | b0d67426af62e5004cd940962bd76f02f408cb7e (patch) | |
tree | dc10f8046aa94dea2b3223f0af23603ea9df3208 | |
parent | c8a658ac53c9c44c0dc6ce8e8f0fa839a21e7b73 (diff) | |
download | node-new-b0d67426af62e5004cd940962bd76f02f408cb7e.tar.gz |
deps: workaround stod() limitations on SmartOS
std::stod() on SmartOS does not currently handle hex strings. This
commit provides a workaround based on strtol() until proper stod()
support is available.
PR-URL: https://github.com/nodejs/node/pull/36139
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
-rw-r--r-- | common.gypi | 2 | ||||
-rw-r--r-- | deps/v8/src/torque/torque-parser.cc | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/common.gypi b/common.gypi index 5e6383ab3c..ba6b791a6c 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.8', + 'v8_embedder_string': '-node.9', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/torque/torque-parser.cc b/deps/v8/src/torque/torque-parser.cc index b3ff1538b2..d71d204b92 100644 --- a/deps/v8/src/torque/torque-parser.cc +++ b/deps/v8/src/torque/torque-parser.cc @@ -1830,7 +1830,17 @@ base::Optional<ParseResult> MakeNumberLiteralExpression( // Meanwhile, we type it as constexpr float64 when out of int32 range. double value = 0; try { +#if defined(V8_OS_SOLARIS) + // stod() on Solaris does not currently support hex strings. Use strtol() + // specifically for hex literals until stod() support is available. + if (number.find("0x") || number.find("0X")) { + value = static_cast<double>(strtol(number.c_str(), nullptr, 0)); + } else { + value = std::stod(number); + } +#else value = std::stod(number); +#endif // !defined(V8_OS_SOLARIS) } catch (const std::out_of_range&) { Error("double literal out-of-range").Throw(); } |