From 081a13f7c011d0ebd28caebfedee1e3e3f7602c9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 11 Feb 2015 19:10:19 +0100 Subject: cmMacroCommand: Declare arg variables where used and initialized. Make the initialization by population with the expanded* content unconditional. --- Source/cmMacroCommand.cxx | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index de52fc9..f7daa76 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -111,15 +111,10 @@ 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; std::vector::const_iterator eit = expandedArgs.begin() + (this->Args.size() - 1); std::string expandedArgn = cmJoin(cmRange(eit, expandedArgs.end()), ";"); std::string expandedArgv = cmJoin(expandedArgs, ";"); - bool argnDefInitialized = false; - bool argvDefInitialized = false; if(!this->Functions.empty()) { this->FilePath = this->Functions[0].FilePath; @@ -166,17 +161,14 @@ bool cmMacroHelperCommand::InvokeInitialPass // repleace ARGN 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()) - { - argnDef += ";"; - } - argnDef += expandedArgn; + argnDef += ";"; } - argnDefInitialized = true; + argnDef += expandedArgn; } cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str()); } @@ -187,16 +179,12 @@ bool cmMacroHelperCommand::InvokeInitialPass { char argvName[60]; - // repleace ARGV, compute it only once - if (!argvDefInitialized) + std::string argvDef; + if (!argvDef.empty() && !expandedArgs.empty()) { - if (!argvDef.empty() && !expandedArgs.empty()) - { - argvDef += ";"; - } - argvDef += expandedArgv; - argvDefInitialized = true; + argvDef += ";"; } + argvDef += expandedArgv; cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str()); // also replace the ARGV1 ARGV2 ... etc -- cgit v0.12