diff options
author | Brad King <brad.king@kitware.com> | 2009-07-13 20:22:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-07-13 20:22:48 (GMT) |
commit | 3dd6f36d459571246ca12a27ad732a8109ac6916 (patch) | |
tree | 8f74befa1a121de7bb46f01884c7ef5e33d6c9dc /Source/cmSystemTools.cxx | |
parent | 18e639d48a658dff76f47e8fcb3815776ee35c33 (diff) | |
download | CMake-3dd6f36d459571246ca12a27ad732a8109ac6916.zip CMake-3dd6f36d459571246ca12a27ad732a8109ac6916.tar.gz CMake-3dd6f36d459571246ca12a27ad732a8109ac6916.tar.bz2 |
ENH: Add cmSystemTools::ParseUnixCommandLine
This method is a C++ wrapper around the KWSys System library function to
parse unix-style command lines.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index de5e31b..64d554b 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -448,6 +448,38 @@ void cmSystemTools::ParseWindowsCommandLine(const char* command, } } +//---------------------------------------------------------------------------- +class cmSystemToolsArgV +{ + char** ArgV; +public: + cmSystemToolsArgV(char** argv): ArgV(argv) {} + ~cmSystemToolsArgV() + { + for(char** arg = this->ArgV; arg && *arg; ++arg) + { + free(*arg); + } + free(this->ArgV); + } + void Store(std::vector<std::string>& args) const + { + for(char** arg = this->ArgV; arg && *arg; ++arg) + { + args.push_back(*arg); + } + } +}; + +//---------------------------------------------------------------------------- +void cmSystemTools::ParseUnixCommandLine(const char* command, + std::vector<std::string>& args) +{ + // Invoke the underlying parser. + cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0); + argv.Store(args); +} + std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg, int shell_flags) { |