summaryrefslogtreecommitdiffstats
path: root/Source/cmcldeps.cxx
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2020-03-18 17:32:08 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2020-03-23 18:47:46 (GMT)
commit59d572bb4a943ef4bf90a415a0d19f1f0771190b (patch)
tree9f34aaa05f7c50ebcb16c48282fc2ad5b096c748 /Source/cmcldeps.cxx
parent206a65c3b8156acc0677a9adb2ab149021f25c20 (diff)
downloadCMake-59d572bb4a943ef4bf90a415a0d19f1f0771190b.zip
CMake-59d572bb4a943ef4bf90a415a0d19f1f0771190b.tar.gz
CMake-59d572bb4a943ef4bf90a415a0d19f1f0771190b.tar.bz2
replace private startsWith() implementation with cmHasPrefix()
Diffstat (limited to 'Source/cmcldeps.cxx')
-rw-r--r--Source/cmcldeps.cxx12
1 files changed, 4 insertions, 8 deletions
diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index caf6453..fd2dd33 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -25,6 +25,7 @@
#include "cmsys/Encoding.hxx"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
// We don't want any wildcard expansion.
@@ -81,11 +82,6 @@ static void replaceAll(std::string& str, const std::string& search,
}
}
-bool startsWith(const std::string& str, const std::string& what)
-{
- return str.compare(0, what.size(), what) == 0;
-}
-
// Strips one argument from the cmdline and returns it. "surrounding quotes"
// are removed from the argument if there were any.
static std::string getArg(std::string& cmdline)
@@ -169,7 +165,7 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile,
// build.ninja file. Therefore we need to canonicalize the path to use
// backward slashes and relativize the path to the build directory.
replaceAll(tmp, "/", "\\");
- if (startsWith(tmp, cwd))
+ if (cmHasPrefix(tmp, cwd))
tmp = tmp.substr(cwd.size());
escapePath(tmp);
fprintf(out, "%s \\\n", tmp.c_str());
@@ -221,13 +217,13 @@ static int process(const std::string& srcfilename, const std::string& dfile,
std::vector<std::string> includes;
bool isFirstLine = true; // cl prints always first the source filename
while (std::getline(ss, line)) {
- if (startsWith(line, prefix)) {
+ if (cmHasPrefix(line, prefix)) {
std::string inc = trimLeadingSpace(line.substr(prefix.size()).c_str());
if (inc.back() == '\r') // blech, stupid \r\n
inc = inc.substr(0, inc.size() - 1);
includes.push_back(inc);
} else {
- if (!isFirstLine || !startsWith(line, srcfilename)) {
+ if (!isFirstLine || !cmHasPrefix(line, srcfilename)) {
if (!quiet || exit_code != 0) {
fprintf(stdout, "%s\n", line.c_str());
}