aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2016-10-10 18:44:18 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2016-10-10 18:44:18 -0700
commita6f8650edbd13023b271dd8cb10b3538121d7a35 (patch)
tree1ee94321a8ceb42487867cd9a84ea2cb97c38c4b
parent49972f472a29e3a57102d49e4d8da16d067a97cf (diff)
downloadvcpkg-a6f8650edbd13023b271dd8cb10b3538121d7a35.tar.gz
vcpkg-a6f8650edbd13023b271dd8cb10b3538121d7a35.zip
[post-build-lint] Look no further than newline when detecting "machine" line
-rw-r--r--toolsrc/src/post_build_lint.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp
index 8c47869a8..1905b48f9 100644
--- a/toolsrc/src/post_build_lint.cpp
+++ b/toolsrc/src/post_build_lint.cpp
@@ -281,7 +281,9 @@ namespace vcpkg
static lint_status check_architecture(const std::string& expected_architecture, const std::vector<fs::path>& files)
{
// static const std::regex machine_regex = std::regex(R"###([0-9A-F]+ machine \([^)]+\))###");
- static const std::string machine_string_scan = "machine ("; // Parenthesis is there to avoid some other occurrences of the word "machine"
+
+ // Parenthesis is there to avoid some other occurrences of the word "machine". Those don't match the expected regex.
+ static const std::string machine_string_scan = "machine (";
std::vector<file_and_arch> binaries_with_invalid_architecture;
std::set<fs::path> binaries_with_no_architecture(files.cbegin(), files.cend());
@@ -296,11 +298,13 @@ namespace vcpkg
for (size_t start, end, idx = s.find(machine_string_scan); idx != std::string::npos; idx = s.find(machine_string_scan, end))
{
- // Skip the space directly in front of "machine" and find the previous one. Get the index of the char after it
- start = s.find_last_of(' ', idx - 2) + 1;
+ // Skip the space directly in front of "machine" and find the previous one. Get the index of the char after it.
+ // Go no further than a newline
+ start = std::max(s.find_last_of('\n', idx - 2) + 1, s.find_last_of(' ', idx - 2) + 1);
// Find the first close-parenthesis. Get the index of the char after it
- end = s.find_first_of(')', idx) + 1;
+ // Go no futher than a newline
+ end = std::min(s.find_first_of('\n', idx) + 1, s.find_first_of(')', idx) + 1);
std::string machine_line(s.substr(start, end - start));