Skip to content

Commit 8ccfed2

Browse files
committed
node: s/-/_/ in add-on symbol name
Replace dashes with underscores. When loading foo-bar.node, look for foo_bar_module, not foo-bar_module. The latter is not a legal symbol name.
1 parent 7b2ef2d commit 8ccfed2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/node.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,13 @@ Handle<Value> DLOpen(const v8::Arguments& args) {
19331933
return ThrowException(exception);
19341934
}
19351935

1936+
/* Replace dashes with underscores. When loading foo-bar.node,
1937+
* look for foo_bar_module, not foo-bar_module.
1938+
*/
1939+
for (pos = symbol; *pos != '\0'; ++pos) {
1940+
if (*pos == '-') *pos = '_';
1941+
}
1942+
19361943
node_module_struct *mod;
19371944
if (uv_dlsym(&lib, symbol, reinterpret_cast<void**>(&mod))) {
19381945
char errmsg[1024];

0 commit comments

Comments
 (0)