summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-29 12:09:48 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-29 12:09:48 (GMT)
commit5d29506811c5b75ae48e12de6c317f6440874215 (patch)
tree5b3f133a47da91dbd8f1d74b2ae8715fb41700d6 /Source
parent48cd0f74059f243d57d7032578a474452265b546 (diff)
parent66c70cd9f1eb69b03cefe7fbe8e238aaa4630f47 (diff)
downloadCMake-5d29506811c5b75ae48e12de6c317f6440874215.zip
CMake-5d29506811c5b75ae48e12de6c317f6440874215.tar.gz
CMake-5d29506811c5b75ae48e12de6c317f6440874215.tar.bz2
Merge topic 'cmake_parse_arguments-PARSE_ARGV-multi-value'
66c70cd9 cmake_parse_arguments: Add additional unit tests 41291b20 cmake_parse_arguments: Fix PARSE_ARGV multi-value argument handling
Diffstat (limited to 'Source')
-rw-r--r--Source/cmParseArgumentsCommand.cxx25
1 files changed, 23 insertions, 2 deletions
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index e8de5b6..55d71ea 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -4,6 +4,19 @@
#include "cmAlgorithms.h"
+static std::string escape_arg(const std::string& arg)
+{
+ // replace ";" with "\;" so output argument lists will split correctly
+ std::string escapedArg;
+ for (size_t i = 0; i < arg.size(); ++i) {
+ if (arg[i] == ';') {
+ escapedArg += '\\';
+ }
+ escapedArg += arg[i];
+ }
+ return escapedArg;
+}
+
bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
@@ -165,10 +178,18 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
insideValues = NONE;
break;
case MULTI:
- multi[currentArgName].push_back(*argIter);
+ if (parseFromArgV) {
+ multi[currentArgName].push_back(escape_arg(*argIter));
+ } else {
+ multi[currentArgName].push_back(*argIter);
+ }
break;
default:
- unparsed.push_back(*argIter);
+ if (parseFromArgV) {
+ unparsed.push_back(escape_arg(*argIter));
+ } else {
+ unparsed.push_back(*argIter);
+ }
break;
}
}