diff options
author | chriseth <chris@ethereum.org> | 2017-01-12 19:02:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-12 19:02:30 +0800 |
commit | 74d74fb00bc159076d8322c5780894b1c2d68791 (patch) | |
tree | 9405b030e69a9c03a20981e0f8953640af0c83db /libsolidity/interface/CompilerStack.cpp | |
parent | b983c7492f7c22a441ef360809085ab2a00150c0 (diff) | |
parent | b6508ca992531154a572320bf8bb117e3b9294b9 (diff) | |
download | dexon-solidity-74d74fb00bc159076d8322c5780894b1c2d68791.tar.gz dexon-solidity-74d74fb00bc159076d8322c5780894b1c2d68791.tar.zst dexon-solidity-74d74fb00bc159076d8322c5780894b1c2d68791.zip |
Merge pull request #1548 from VoR0220/remappingBugFix
Remapping bug fix
Diffstat (limited to 'libsolidity/interface/CompilerStack.cpp')
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index ee55f41a..a31df584 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -509,23 +509,32 @@ string CompilerStack::applyRemapping(string const& _path, string const& _context }; size_t longestPrefix = 0; - string longestPrefixTarget; + size_t longestContext = 0; + string bestMatchTarget; + for (auto const& redir: m_remappings) { - // Skip if we already have a closer match. - if (longestPrefix > 0 && redir.prefix.length() <= longestPrefix) + string context = sanitizePath(redir.context); + string prefix = sanitizePath(redir.prefix); + + // Skip if current context is closer + if (context.length() < longestContext) continue; // Skip if redir.context is not a prefix of _context - if (!isPrefixOf(redir.context, _context)) + if (!isPrefixOf(context, _context)) + continue; + // Skip if we already have a closer prefix match. + if (prefix.length() < longestPrefix && context.length() == longestContext) continue; // Skip if the prefix does not match. - if (!isPrefixOf(redir.prefix, _path)) + if (!isPrefixOf(prefix, _path)) continue; - longestPrefix = redir.prefix.length(); - longestPrefixTarget = redir.target; + longestContext = context.length(); + longestPrefix = prefix.length(); + bestMatchTarget = sanitizePath(redir.target); } - string path = longestPrefixTarget; + string path = bestMatchTarget; path.append(_path.begin() + longestPrefix, _path.end()); return path; } |