macro: Add extra indentation to placeholder substitution code
The next commit will make this block conditional so pre-indent it to clarify the simplicity of the change.
This commit is contained in:
parent
8a6e82724c
commit
999abb993e
@ -140,75 +140,75 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
|||||||
// Set the FilePath on the arguments to match the function since it is
|
// Set the FilePath on the arguments to match the function since it is
|
||||||
// not stored and the original values may be freed
|
// not stored and the original values may be freed
|
||||||
k->FilePath = this->FilePath.c_str();
|
k->FilePath = this->FilePath.c_str();
|
||||||
tmps = k->Value;
|
tmps = k->Value;
|
||||||
// replace formal arguments
|
// replace formal arguments
|
||||||
for (unsigned int j = 1; j < this->Args.size(); ++j)
|
for (unsigned int j = 1; j < this->Args.size(); ++j)
|
||||||
{
|
|
||||||
variable = "${";
|
|
||||||
variable += this->Args[j];
|
|
||||||
variable += "}";
|
|
||||||
cmSystemTools::ReplaceString(tmps, variable.c_str(),
|
|
||||||
expandedArgs[j-1].c_str());
|
|
||||||
}
|
|
||||||
// replace argc
|
|
||||||
cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str());
|
|
||||||
|
|
||||||
// repleace ARGN
|
|
||||||
if (tmps.find("${ARGN}") != std::string::npos)
|
|
||||||
{
|
|
||||||
if (!argnDefInitialized)
|
|
||||||
{
|
{
|
||||||
std::vector<std::string>::const_iterator eit;
|
variable = "${";
|
||||||
std::vector<std::string>::size_type cnt = 0;
|
variable += this->Args[j];
|
||||||
for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit )
|
variable += "}";
|
||||||
|
cmSystemTools::ReplaceString(tmps, variable.c_str(),
|
||||||
|
expandedArgs[j-1].c_str());
|
||||||
|
}
|
||||||
|
// replace argc
|
||||||
|
cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str());
|
||||||
|
|
||||||
|
// repleace ARGN
|
||||||
|
if (tmps.find("${ARGN}") != std::string::npos)
|
||||||
|
{
|
||||||
|
if (!argnDefInitialized)
|
||||||
{
|
{
|
||||||
if ( cnt >= this->Args.size()-1 )
|
std::vector<std::string>::const_iterator eit;
|
||||||
|
std::vector<std::string>::size_type cnt = 0;
|
||||||
|
for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
|
||||||
{
|
{
|
||||||
if ( argnDef.size() > 0 )
|
if ( cnt >= this->Args.size()-1 )
|
||||||
{
|
{
|
||||||
argnDef += ";";
|
if ( argnDef.size() > 0 )
|
||||||
|
{
|
||||||
|
argnDef += ";";
|
||||||
|
}
|
||||||
|
argnDef += *eit;
|
||||||
}
|
}
|
||||||
argnDef += *eit;
|
cnt ++;
|
||||||
}
|
}
|
||||||
cnt ++;
|
argnDefInitialized = true;
|
||||||
}
|
}
|
||||||
argnDefInitialized = true;
|
cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
|
||||||
}
|
}
|
||||||
cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the current argument of the current function has ${ARGV in it
|
// if the current argument of the current function has ${ARGV in it
|
||||||
// then try replacing ARGV values
|
// then try replacing ARGV values
|
||||||
if (tmps.find("${ARGV") != std::string::npos)
|
if (tmps.find("${ARGV") != std::string::npos)
|
||||||
{
|
|
||||||
char argvName[60];
|
|
||||||
|
|
||||||
// repleace ARGV, compute it only once
|
|
||||||
if (!argvDefInitialized)
|
|
||||||
{
|
{
|
||||||
std::vector<std::string>::const_iterator eit;
|
char argvName[60];
|
||||||
for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit )
|
|
||||||
|
// repleace ARGV, compute it only once
|
||||||
|
if (!argvDefInitialized)
|
||||||
{
|
{
|
||||||
if ( argvDef.size() > 0 )
|
std::vector<std::string>::const_iterator eit;
|
||||||
|
for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
|
||||||
{
|
{
|
||||||
argvDef += ";";
|
if ( argvDef.size() > 0 )
|
||||||
|
{
|
||||||
|
argvDef += ";";
|
||||||
|
}
|
||||||
|
argvDef += *eit;
|
||||||
}
|
}
|
||||||
argvDef += *eit;
|
argvDefInitialized = true;
|
||||||
}
|
}
|
||||||
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
|
||||||
for (unsigned int t = 0; t < expandedArgs.size(); ++t)
|
for (unsigned int t = 0; t < expandedArgs.size(); ++t)
|
||||||
{
|
{
|
||||||
sprintf(argvName,"${ARGV%i}",t);
|
sprintf(argvName,"${ARGV%i}",t);
|
||||||
cmSystemTools::ReplaceString(tmps, argvName,
|
cmSystemTools::ReplaceString(tmps, argvName,
|
||||||
expandedArgs[t].c_str());
|
expandedArgs[t].c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
arg.Value = tmps;
|
arg.Value = tmps;
|
||||||
arg.Delim = k->Delim;
|
arg.Delim = k->Delim;
|
||||||
arg.FilePath = k->FilePath;
|
arg.FilePath = k->FilePath;
|
||||||
arg.Line = k->Line;
|
arg.Line = k->Line;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user