diff --git a/source/dub/internal/utils.d b/source/dub/internal/utils.d index 25e1018..b9ff4e3 100644 --- a/source/dub/internal/utils.d +++ b/source/dub/internal/utils.d @@ -614,6 +614,7 @@ */ string getModuleNameFromContent(string content) { import std.ascii: isAlpha, isAlphaNum; + import std.algorithm: among; import core.exception: RangeError; enum keyword = "module"; @@ -670,9 +671,9 @@ } } } - else if(isAlpha(ch) && foundKeyword) { + else if((isAlpha(ch) || ch == '_') && foundKeyword) { const start = i; - while(isAlphaNum(ch) || ch == '.') { + while(isAlphaNum(ch) || ch.among('.', '_')) { ++i; } return content[start .. i]; @@ -707,6 +708,8 @@ assert(getModuleNameFromContent("/+ /+ module foo; +/ module foo; +/ module bar;") == "bar"); assert(getModuleNameFromContent("/+ /+ module foo; +/ module foo; +/ module bar/++/;") == "bar"); assert(getModuleNameFromContent("/*\nmodule sometest;\n*/\n\nmodule fakemath;\n") == "fakemath"); + assert(getModuleNameFromContent("module foo_bar;") == "foo_bar"); + assert(getModuleNameFromContent("module _foo_bar;") == "_foo_bar"); } /**