summaryrefslogtreecommitdiffstats
path: root/Source/cmStringCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-02-12 16:53:04 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-02-12 16:53:04 (GMT)
commite6ae3c6ae0540de51b3d615aea3abd49ccc70a34 (patch)
tree09f74e0bf09b27dd51e95530cbee7783db3301bd /Source/cmStringCommand.cxx
parentfc7e15691a870f8f5e199e615279c7eb4dba8f6f (diff)
parent7c3f637680ac0cdb6cec5e75ba4a9b188de5017b (diff)
downloadCMake-e6ae3c6ae0540de51b3d615aea3abd49ccc70a34.zip
CMake-e6ae3c6ae0540de51b3d615aea3abd49ccc70a34.tar.gz
CMake-e6ae3c6ae0540de51b3d615aea3abd49ccc70a34.tar.bz2
Merge topic 'use-cmRange'
7c3f6376 Convert loop into two algorithms. 8a399c8c Convert loop to the common pattern. abfca975 Move loop inside of condition. 0b61b86d Handle last element outside of the loop. e21f7829 cmTarget: Use a sorted vector in place of a set. 559dc155 cmSet: Replace loop with cmJoin. 0ea71932 cmFindBase: Replace loop with cmJoin on range. 9380e85f Convert loops to cmJoin algorithm with cmRange. bb10012f cmStringCommand: Accumulate with cmJoin and range adaptors. 0c12f1ea cmAlgorithms: Add a range adaptor and API for adjusting a range. 27c6f017 Use cmJoin to accumulate string ranges. 4e78ebbd cmAlgorithms: Add a Range container and adaptor method. 89102249 Replace common loop pattern with cmJoin 7b8725bf Convert loops populating maybe-empty content into the common pattern. 7ee56f03 Convert loops into the commonly used pattern. 0a4e5674 cmMacroCommand: Remove counting variable. ...
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;