ENH: Add cmSystemTools::ParseUnixCommandLine
This method is a C++ wrapper around the KWSys System library function to parse unix-style command lines.
This commit is contained in:
parent
18e639d48a
commit
3dd6f36d45
|
@ -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,
|
std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg,
|
||||||
int shell_flags)
|
int shell_flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -239,6 +239,10 @@ public:
|
||||||
static void ParseWindowsCommandLine(const char* command,
|
static void ParseWindowsCommandLine(const char* command,
|
||||||
std::vector<std::string>& args);
|
std::vector<std::string>& args);
|
||||||
|
|
||||||
|
/** Parse arguments out of a unix command line string. */
|
||||||
|
static void ParseUnixCommandLine(const char* command,
|
||||||
|
std::vector<std::string>& args);
|
||||||
|
|
||||||
/** Compute an escaped version of the given argument for use in a
|
/** Compute an escaped version of the given argument for use in a
|
||||||
windows shell. See kwsys/System.h.in for details. */
|
windows shell. See kwsys/System.h.in for details. */
|
||||||
static std::string EscapeWindowsShellArgument(const char* arg,
|
static std::string EscapeWindowsShellArgument(const char* arg,
|
||||||
|
|
Loading…
Reference in New Issue