mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-22 06:59:01 -06:00
Source: change parameters to std::string
This commit is contained in:
@@ -82,11 +82,11 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
|
||||
bool result = true;
|
||||
if (args.size() - count == 2) {
|
||||
cmSystemTools::MakeDirectory(args[1]);
|
||||
result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
|
||||
result = cmExecProgramCommand::RunCommand(command, output, retVal,
|
||||
args[1].c_str(), verbose);
|
||||
} else {
|
||||
result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
|
||||
nullptr, verbose);
|
||||
result = cmExecProgramCommand::RunCommand(command, output, retVal, nullptr,
|
||||
verbose);
|
||||
}
|
||||
if (!result) {
|
||||
retVal = -1;
|
||||
@@ -115,7 +115,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
bool cmExecProgramCommand::RunCommand(std::string command, std::string& output,
|
||||
int& retVal, const char* dir,
|
||||
bool verbose, Encoding encoding)
|
||||
{
|
||||
@@ -128,12 +128,11 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
// try to find the program, and if the program can not be
|
||||
// found use system to run the command as it must be a built in
|
||||
// shell command like echo or dir
|
||||
int count = 0;
|
||||
std::string shortCmd;
|
||||
if (command[0] == '\"') {
|
||||
if (!command.empty() && command[0] == '\"') {
|
||||
// count the number of quotes
|
||||
for (const char* s = command; *s != 0; ++s) {
|
||||
if (*s == '\"') {
|
||||
int count = 0;
|
||||
for (char c : command) {
|
||||
if (c == '\"') {
|
||||
count++;
|
||||
if (count > 2) {
|
||||
break;
|
||||
@@ -147,20 +146,21 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
if (count > 2) {
|
||||
cmsys::RegularExpression quoted("^\"([^\"]*)\"[ \t](.*)");
|
||||
if (quoted.find(command)) {
|
||||
std::string shortCmd;
|
||||
std::string cmd = quoted.match(1);
|
||||
std::string args = quoted.match(2);
|
||||
if (!cmSystemTools::FileExists(cmd)) {
|
||||
shortCmd = cmd;
|
||||
} else if (!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd)) {
|
||||
} else if (!cmSystemTools::GetShortPath(cmd, shortCmd)) {
|
||||
cmSystemTools::Error("GetShortPath failed for " + cmd);
|
||||
return false;
|
||||
}
|
||||
shortCmd += " ";
|
||||
shortCmd += args;
|
||||
|
||||
command = shortCmd.c_str();
|
||||
command = shortCmd;
|
||||
} else {
|
||||
cmSystemTools::Error("Could not parse command line with quotes ",
|
||||
cmSystemTools::Error("Could not parse command line with quotes " +
|
||||
command);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
|
||||
}
|
||||
cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1);
|
||||
const char* cmd[] = { command, 0 };
|
||||
const char* cmd[] = { command.c_str(), nullptr };
|
||||
cmsysProcess_SetCommand(cp, cmd);
|
||||
#else
|
||||
std::string commandInDir;
|
||||
@@ -197,7 +197,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
# ifndef __VMS
|
||||
commandInDir += " 2>&1";
|
||||
# endif
|
||||
command = commandInDir.c_str();
|
||||
command = commandInDir;
|
||||
if (verbose) {
|
||||
cmSystemTools::Stdout("running ");
|
||||
cmSystemTools::Stdout(command);
|
||||
@@ -205,7 +205,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
|
||||
}
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
const char* cmd[] = { "/bin/sh", "-c", command, nullptr };
|
||||
const char* cmd[] = { "/bin/sh", "-c", command.c_str(), nullptr };
|
||||
cmsysProcess_SetCommand(cp, cmd);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user