Skip to content

Commit

Permalink
fixup! FileReader: Normalize base path and strip it from normalized s…
Browse files Browse the repository at this point in the history
…ource paths
  • Loading branch information
cameel committed Jul 12, 2021
1 parent 76a250f commit 0d67e71
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions libsolidity/interface/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,28 +142,13 @@ boost::filesystem::path FileReader::normalizeCLIPathForVFS(boost::filesystem::pa
// If the path is on the same drive as the working dir, for portability we prefer not to
// include the root name. Do this only for non-UNC paths - my experiments show that on Windows
// when the working dir is an UNC path, / does not not actually refer to the root of the UNC path.
// For UNC paths only normalize the root name to start with //.
boost::filesystem::path normalizedRootPath = normalizedPath.root_path();
if (!isUNCPath(normalizedPath))
{
boost::filesystem::path workingDirRootPath = canonicalWorkDir.root_path();
if (normalizedRootPath == workingDirRootPath)
normalizedRootPath = "/";
}
else
{
solAssert(
boost::starts_with(normalizedPath.root_name().string(), "//") ||
boost::starts_with(normalizedPath.root_name().string(), "\\\\"),
""
);

string rootName = normalizedPath.root_name().string();
boost::filesystem::path normalizedRootPath =
normalizedPath.root_directory().string() +
"//" +
(rootName.size() > 2 ? rootName.substr(2, string::npos) : "");
}

boost::filesystem::path normalizedPathNoDotDot = normalizedPath;
if (dotDotPrefix.empty())
Expand All @@ -174,6 +159,7 @@ boost::filesystem::path FileReader::normalizeCLIPathForVFS(boost::filesystem::pa

// NOTE: On Windows lexically_normal() converts all separators to forward slashes. Convert them back.
// Separators do not affect path comparison but remain in internal representation returned by native().
// This will also normalize the root name to start with // in UNC paths.
normalizedPathNoDotDot = normalizedPathNoDotDot.generic_string();

// For some reason boost considers "/." different than "/" even though for other directories
Expand Down

0 comments on commit 0d67e71

Please sign in to comment.