From 8ccfed2edceb9b4c216ce885d76fa03537e3eb5e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 18 Dec 2012 09:56:57 +0100 Subject: [PATCH] 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. --- src/node.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/node.cc b/src/node.cc index a74d80e6ff5..6341ec3f7b7 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1933,6 +1933,13 @@ Handle DLOpen(const v8::Arguments& args) { return ThrowException(exception); } + /* Replace dashes with underscores. When loading foo-bar.node, + * look for foo_bar_module, not foo-bar_module. + */ + for (pos = symbol; *pos != '\0'; ++pos) { + if (*pos == '-') *pos = '_'; + } + node_module_struct *mod; if (uv_dlsym(&lib, symbol, reinterpret_cast(&mod))) { char errmsg[1024];