summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-01-13 15:27:49 +0100
committerMarc Chevrier <marc.chevrier@gmail.com>2021-01-13 15:27:49 +0100
commit76f0bcdfb6e04f1f6089ea693d69b642bbf26e82 (patch)
tree08ee286265df549fac25cee13c2c590135ecfd8c /Source
parent3ad1ee81445d4ce4388bcde7222a676725aebcd6 (diff)
downloadcmake-76f0bcdfb6e04f1f6089ea693d69b642bbf26e82.tar.gz
cmake_path: various updates
To follow discussions in #21385 and !5682: * Fix bug in cmCMakePath::IsSuffix() method * cmake_path(HASH) always normalized paths (NORMALIZE option removed)
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCMakePath.cxx3
-rw-r--r--Source/cmCMakePathCommand.cxx18
2 files changed, 6 insertions, 15 deletions
diff --git a/Source/cmCMakePath.cxx b/Source/cmCMakePath.cxx
index b8215dfcfe..73321c68c0 100644
--- a/Source/cmCMakePath.cxx
+++ b/Source/cmCMakePath.cxx
@@ -88,7 +88,8 @@ bool cmCMakePath::IsPrefix(const cmCMakePath& path) const
++prefix_it;
++path_it;
}
- return prefix_it == prefix_end;
+ return (prefix_it == prefix_end) ||
+ (prefix_it->empty() && path_it != path_end);
}
std::string cmCMakePath::FormatPath(std::string path, format fmt)
diff --git a/Source/cmCMakePathCommand.cxx b/Source/cmCMakePathCommand.cxx
index e9bf84ab24..5662a2f5a2 100644
--- a/Source/cmCMakePathCommand.cxx
+++ b/Source/cmCMakePathCommand.cxx
@@ -929,17 +929,8 @@ bool HandleIsPrefixCommand(std::vector<std::string> const& args,
bool HandleHashCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
- if (args.size() < 3 || args.size() > 4) {
- status.SetError("HASH must be called with two or three arguments.");
- return false;
- }
-
- static NormalizeParser const parser;
-
- const auto arguments = parser.Parse(args);
-
- if (parser.GetInputs().size() != 1) {
- status.SetError("HASH called with unexpected arguments.");
+ if (args.size() != 3) {
+ status.SetError("HASH must be called with two arguments.");
return false;
}
@@ -948,15 +939,14 @@ bool HandleHashCommand(std::vector<std::string> const& args,
return false;
}
- const auto& output = parser.GetInputs().front();
+ const auto& output = args[2];
if (output.empty()) {
status.SetError("Invalid name for output variable.");
return false;
}
- auto hash = hash_value(arguments.Normalize ? cmCMakePath(inputPath).Normal()
- : cmCMakePath(inputPath));
+ auto hash = hash_value(cmCMakePath(inputPath).Normal());
std::ostringstream out;
out << std::setbase(16) << hash;