run_compile_commands: Avoid extra stl vector conversion

The Sun compiler does not provide the proper vector constructor to
initialize it from an iterator pair of a non-matching type.  Extend the
ParseUnixCommandLine API to provide a vector of the proper type so no
conversion is needed.
This commit is contained in:
Brad King 2011-05-18 09:44:28 -04:00
parent 7c5be5114c
commit c45c60b24f
3 changed files with 20 additions and 3 deletions

View File

@ -440,6 +440,13 @@ public:
args.push_back(*arg);
}
}
void Store(std::vector<cmStdString>& args) const
{
for(char** arg = this->ArgV; arg && *arg; ++arg)
{
args.push_back(*arg);
}
}
};
//----------------------------------------------------------------------------
@ -451,6 +458,15 @@ void cmSystemTools::ParseUnixCommandLine(const char* command,
argv.Store(args);
}
//----------------------------------------------------------------------------
void cmSystemTools::ParseUnixCommandLine(const char* command,
std::vector<cmStdString>& 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)
{

View File

@ -237,6 +237,8 @@ public:
/** Parse arguments out of a unix command line string. */
static void ParseUnixCommandLine(const char* command,
std::vector<std::string>& args);
static void ParseUnixCommandLine(const char* command,
std::vector<cmStdString>& args);
/** Compute an escaped version of the given argument for use in a
windows shell. See kwsys/System.h.in for details. */

View File

@ -127,9 +127,8 @@ int main ()
it = parser.GetTranslationUnits().begin(),
end = parser.GetTranslationUnits().end(); it != end; ++it)
{
std::vector<std::string> std_command;
cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), std_command);
std::vector<cmStdString> command(std_command.begin(), std_command.end());
std::vector<cmStdString> command;
cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command);
if (!cmSystemTools::RunSingleCommand(
command, 0, 0, it->at("directory").c_str()))
{