diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-02-11 18:10:19 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-02-11 21:58:33 (GMT) |
commit | 081a13f7c011d0ebd28caebfedee1e3e3f7602c9 (patch) | |
tree | 9127064806a543ced2523a33ce337e1004c0c3a1 /Source/cmMacroCommand.cxx | |
parent | 17b5ebd383df4c0c731b5c687ccaa3608b2d188f (diff) | |
download | CMake-081a13f7c011d0ebd28caebfedee1e3e3f7602c9.zip CMake-081a13f7c011d0ebd28caebfedee1e3e3f7602c9.tar.gz CMake-081a13f7c011d0ebd28caebfedee1e3e3f7602c9.tar.bz2 |
cmMacroCommand: Declare arg variables where used and initialized.
Make the initialization by population with the expanded* content
unconditional.
Diffstat (limited to 'Source/cmMacroCommand.cxx')
-rw-r--r-- | Source/cmMacroCommand.cxx | 30 |
1 files 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<std::string>::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 |