cmMacroCommand: Declare arg variables where used and initialized.
Make the initialization by population with the expanded* content unconditional.
This commit is contained in:
parent
17b5ebd383
commit
081a13f7c0
|
@ -111,15 +111,10 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
||||||
argcDefStream << expandedArgs.size();
|
argcDefStream << expandedArgs.size();
|
||||||
std::string argcDef = argcDefStream.str();
|
std::string argcDef = argcDefStream.str();
|
||||||
|
|
||||||
// declare varuiables for ARGV ARGN but do not compute until needed
|
|
||||||
std::string argvDef;
|
|
||||||
std::string argnDef;
|
|
||||||
std::vector<std::string>::const_iterator eit
|
std::vector<std::string>::const_iterator eit
|
||||||
= expandedArgs.begin() + (this->Args.size() - 1);
|
= expandedArgs.begin() + (this->Args.size() - 1);
|
||||||
std::string expandedArgn = cmJoin(cmRange(eit, expandedArgs.end()), ";");
|
std::string expandedArgn = cmJoin(cmRange(eit, expandedArgs.end()), ";");
|
||||||
std::string expandedArgv = cmJoin(expandedArgs, ";");
|
std::string expandedArgv = cmJoin(expandedArgs, ";");
|
||||||
bool argnDefInitialized = false;
|
|
||||||
bool argvDefInitialized = false;
|
|
||||||
if(!this->Functions.empty())
|
if(!this->Functions.empty())
|
||||||
{
|
{
|
||||||
this->FilePath = this->Functions[0].FilePath;
|
this->FilePath = this->Functions[0].FilePath;
|
||||||
|
@ -166,8 +161,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
||||||
// repleace ARGN
|
// repleace ARGN
|
||||||
if (tmps.find("${ARGN}") != std::string::npos)
|
if (tmps.find("${ARGN}") != std::string::npos)
|
||||||
{
|
{
|
||||||
if (!argnDefInitialized)
|
std::string argnDef;
|
||||||
{
|
|
||||||
if (expandedArgs.size() > this->Args.size() - 1)
|
if (expandedArgs.size() > this->Args.size() - 1)
|
||||||
{
|
{
|
||||||
if (!argnDef.empty() && !expandedArgs.empty())
|
if (!argnDef.empty() && !expandedArgs.empty())
|
||||||
|
@ -176,8 +170,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
||||||
}
|
}
|
||||||
argnDef += expandedArgn;
|
argnDef += expandedArgn;
|
||||||
}
|
}
|
||||||
argnDefInitialized = true;
|
|
||||||
}
|
|
||||||
cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
|
cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,16 +179,12 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
||||||
{
|
{
|
||||||
char argvName[60];
|
char argvName[60];
|
||||||
|
|
||||||
// repleace ARGV, compute it only once
|
std::string argvDef;
|
||||||
if (!argvDefInitialized)
|
|
||||||
{
|
|
||||||
if (!argvDef.empty() && !expandedArgs.empty())
|
if (!argvDef.empty() && !expandedArgs.empty())
|
||||||
{
|
{
|
||||||
argvDef += ";";
|
argvDef += ";";
|
||||||
}
|
}
|
||||||
argvDef += expandedArgv;
|
argvDef += expandedArgv;
|
||||||
argvDefInitialized = true;
|
|
||||||
}
|
|
||||||
cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
|
cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
|
||||||
|
|
||||||
// also replace the ARGV1 ARGV2 ... etc
|
// also replace the ARGV1 ARGV2 ... etc
|
||||||
|
|
Loading…
Reference in New Issue