summaryrefslogtreecommitdiffstats
path: root/Source/cmStringCommand.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-02-10 21:23:41 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-02-11 21:57:56 (GMT)
commitbb10012fea677fd8aa1bbefd06061efcb7ec1955 (patch)
tree9e733b9d37d7a9f557ea9963b5a94a87f0b0396e /Source/cmStringCommand.cxx
parent0c12f1ea0da0a5822a7a69b4ff77b45732c72466 (diff)
downloadCMake-bb10012fea677fd8aa1bbefd06061efcb7ec1955.zip
CMake-bb10012fea677fd8aa1bbefd06061efcb7ec1955.tar.gz
CMake-bb10012fea677fd8aa1bbefd06061efcb7ec1955.tar.bz2
cmStringCommand: Accumulate with cmJoin and range adaptors.
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r--Source/cmStringCommand.cxx42
1 files changed, 11 insertions, 31 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 3e606d7..edc6afc 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -303,13 +303,6 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
std::string regex = args[2];
std::string outvar = args[3];
- // Concatenate all the last arguments together.
- std::string input = args[4];
- for(unsigned int i=5; i < args.size(); ++i)
- {
- input += args[i];
- }
-
this->Makefile->ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
@@ -321,6 +314,9 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
return false;
}
+ // Concatenate all the last arguments together.
+ std::string input = cmJoin(cmRange(args).advance(4), std::string());
+
// Scan through the input for all matches.
std::string output;
if(re.find(input.c_str()))
@@ -352,13 +348,6 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
std::string regex = args[2];
std::string outvar = args[3];
- // Concatenate all the last arguments together.
- std::string input = args[4];
- for(unsigned int i=5; i < args.size(); ++i)
- {
- input += args[i];
- }
-
this->Makefile->ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
@@ -371,6 +360,9 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
return false;
}
+ // Concatenate all the last arguments together.
+ std::string input = cmJoin(cmRange(args).advance(4), std::string());
+
// Scan through the input for all matches.
std::string output;
const char* p = input.c_str();
@@ -456,13 +448,6 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
l = r;
}
- // Concatenate all the last arguments together.
- std::string input = args[5];
- for(unsigned int i=6; i < args.size(); ++i)
- {
- input += args[i];
- }
-
this->Makefile->ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
@@ -475,6 +460,9 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
return false;
}
+ // Concatenate all the last arguments together.
+ std::string input = cmJoin(cmRange(args).advance(5), std::string());
+
// Scan through the input for all matches.
std::string output;
std::string::size_type base = 0;
@@ -673,11 +661,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const&
const std::string& replaceExpression = args[2];
const std::string& variableName = args[3];
- std::string input = args[4];
- for(unsigned int i=5; i < args.size(); ++i)
- {
- input += args[i];
- }
+ std::string input = cmJoin(cmRange(args).advance(4), std::string());
cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(),
replaceExpression.c_str());
@@ -756,11 +740,7 @@ bool cmStringCommand
}
std::string const& variableName = args[1];
- std::string value;
- for(unsigned int i = 2; i < args.size(); ++i)
- {
- value += args[i];
- }
+ std::string value = cmJoin(cmRange(args).advance(2), std::string());
this->Makefile->AddDefinition(variableName, value.c_str());
return true;