|
|
@@ -84,10 +84,6 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
|
|
std::vector<std::string> expandedArgs;
|
|
|
this->Makefile->ExpandArguments(args, expandedArgs);
|
|
|
|
|
|
- std::string tmps;
|
|
|
- cmListFileArgument arg;
|
|
|
- std::string variable;
|
|
|
-
|
|
|
// make sure the number of arguments passed is at least the number
|
|
|
// required by the signature
|
|
|
if (expandedArgs.size() < this->Args.size() - 1)
|
|
|
@@ -111,11 +107,24 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
|
|
argcDefStream << expandedArgs.size();
|
|
|
std::string argcDef = argcDefStream.str();
|
|
|
|
|
|
- // declare varuiables for ARGV ARGN but do not compute until needed
|
|
|
- std::string argvDef;
|
|
|
- std::string argnDef;
|
|
|
- bool argnDefInitialized = false;
|
|
|
- bool argvDefInitialized = false;
|
|
|
+ std::vector<std::string>::const_iterator eit
|
|
|
+ = expandedArgs.begin() + (this->Args.size() - 1);
|
|
|
+ std::string expandedArgn = cmJoin(cmRange(eit, expandedArgs.end()), ";");
|
|
|
+ std::string expandedArgv = cmJoin(expandedArgs, ";");
|
|
|
+ std::vector<std::string> variables;
|
|
|
+ variables.reserve(this->Args.size() - 1);
|
|
|
+ for (unsigned int j = 1; j < this->Args.size(); ++j)
|
|
|
+ {
|
|
|
+ variables.push_back("${" + this->Args[j] + "}");
|
|
|
+ }
|
|
|
+ std::vector<std::string> argVs;
|
|
|
+ argVs.reserve(expandedArgs.size());
|
|
|
+ char argvName[60];
|
|
|
+ for (unsigned int j = 0; j < expandedArgs.size(); ++j)
|
|
|
+ {
|
|
|
+ sprintf(argvName,"${ARGV%i}",j);
|
|
|
+ argVs.push_back(argvName);
|
|
|
+ }
|
|
|
if(!this->Functions.empty())
|
|
|
{
|
|
|
this->FilePath = this->Functions[0].FilePath;
|
|
|
@@ -140,73 +149,35 @@ bool cmMacroHelperCommand::InvokeInitialPass
|
|
|
// Set the FilePath on the arguments to match the function since it is
|
|
|
// not stored and the original values may be freed
|
|
|
k->FilePath = this->FilePath.c_str();
|
|
|
- if(k->Delim == cmListFileArgument::Bracket)
|
|
|
- {
|
|
|
- arg.Value = k->Value;
|
|
|
- }
|
|
|
- else
|
|
|
+
|
|
|
+ cmListFileArgument arg;
|
|
|
+ arg.Value = k->Value;
|
|
|
+ if(k->Delim != cmListFileArgument::Bracket)
|
|
|
{
|
|
|
- tmps = k->Value;
|
|
|
// replace formal arguments
|
|
|
- for (unsigned int j = 1; j < this->Args.size(); ++j)
|
|
|
+ for (unsigned int j = 0; j < variables.size(); ++j)
|
|
|
{
|
|
|
- variable = "${";
|
|
|
- variable += this->Args[j];
|
|
|
- variable += "}";
|
|
|
- cmSystemTools::ReplaceString(tmps, variable.c_str(),
|
|
|
- expandedArgs[j-1].c_str());
|
|
|
+ cmSystemTools::ReplaceString(arg.Value, variables[j].c_str(),
|
|
|
+ expandedArgs[j].c_str());
|
|
|
}
|
|
|
// replace argc
|
|
|
- cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str());
|
|
|
+ cmSystemTools::ReplaceString(arg.Value, "${ARGC}",argcDef.c_str());
|
|
|
|
|
|
- // repleace ARGN
|
|
|
- if (tmps.find("${ARGN}") != std::string::npos)
|
|
|
- {
|
|
|
- if (!argnDefInitialized)
|
|
|
- {
|
|
|
- if (expandedArgs.size() > this->Args.size() - 1)
|
|
|
- {
|
|
|
- if (!argnDef.empty() && !expandedArgs.empty())
|
|
|
- {
|
|
|
- argnDef += ";";
|
|
|
- }
|
|
|
- std::vector<std::string>::const_iterator eit
|
|
|
- = expandedArgs.begin() + (this->Args.size() - 1);
|
|
|
- argnDef += cmJoin(cmRange(eit, expandedArgs.end()), ";");
|
|
|
- }
|
|
|
- argnDefInitialized = true;
|
|
|
- }
|
|
|
- cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str());
|
|
|
- }
|
|
|
+ cmSystemTools::ReplaceString(arg.Value, "${ARGN}",
|
|
|
+ expandedArgn.c_str());
|
|
|
+ cmSystemTools::ReplaceString(arg.Value, "${ARGV}",
|
|
|
+ expandedArgv.c_str());
|
|
|
|
|
|
// if the current argument of the current function has ${ARGV in it
|
|
|
// then try replacing ARGV values
|
|
|
- if (tmps.find("${ARGV") != std::string::npos)
|
|
|
+ if (arg.Value.find("${ARGV") != std::string::npos)
|
|
|
{
|
|
|
- char argvName[60];
|
|
|
-
|
|
|
- // repleace ARGV, compute it only once
|
|
|
- if (!argvDefInitialized)
|
|
|
- {
|
|
|
- if (!argvDef.empty() && !expandedArgs.empty())
|
|
|
- {
|
|
|
- argvDef += ";";
|
|
|
- }
|
|
|
- argvDef += cmJoin(expandedArgs, ";");
|
|
|
- argvDefInitialized = true;
|
|
|
- }
|
|
|
- cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str());
|
|
|
-
|
|
|
- // also replace the ARGV1 ARGV2 ... etc
|
|
|
for (unsigned int t = 0; t < expandedArgs.size(); ++t)
|
|
|
{
|
|
|
- sprintf(argvName,"${ARGV%i}",t);
|
|
|
- cmSystemTools::ReplaceString(tmps, argvName,
|
|
|
+ cmSystemTools::ReplaceString(arg.Value, argVs[t].c_str(),
|
|
|
expandedArgs[t].c_str());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- arg.Value = tmps;
|
|
|
}
|
|
|
arg.Delim = k->Delim;
|
|
|
arg.FilePath = k->FilePath;
|