Skip to content

Commit df69e2c

Browse files
authored
Move jstoi_s to liblegacy.js (#24132)
This function was added alongside `jstoi_q` in #10457, but its documentation is wrong. `Number("123abc")` does not throw, it returns NaN. This function never had any internal usage within emscripten.
1 parent 11423cc commit df69e2c

6 files changed

+10
-9
lines changed

src/lib/libcore.js

-5
Original file line numberDiff line numberDiff line change
@@ -1642,11 +1642,6 @@ addToLibrary({
16421642
$jstoi_q__docs: '/** @suppress {checkTypes} */',
16431643
$jstoi_q: (str) => parseInt(str),
16441644

1645-
// Converts a JS string to an integer base-10, with signaling error
1646-
// handling (throws a JS exception on error). E.g. jstoi_s("123abc")
1647-
// throws an exception.
1648-
$jstoi_s: 'Number',
1649-
16501645
#if LINK_AS_CXX
16511646
// libunwind
16521647

src/lib/liblegacy.js

+6
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ legacyFuncs = {
116116
// Legacy names for runtime `out`/`err` symbols.
117117
$print: 'out',
118118
$printErr: 'err',
119+
120+
// Converts a JS string to an integer base-10. Despite _s, which
121+
// suggests signaling error handling, this returns NaN on error.
122+
// (This was a mistake in the original implementation, and kept
123+
// to avoid breakage.)
124+
$jstoi_s: 'Number',
119125
};
120126

121127
if (WARN_DEPRECATED && !INCLUDE_FULL_LIBRARY) {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7805
1+
7806
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6123
1+
6119
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16149
1+
16141
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
49919
1+
49906

0 commit comments

Comments
 (0)