diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2008-05-20 15:30:30 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2008-05-20 15:30:30 (GMT) |
commit | fd0e8b3a56bb04398d8e9e0ec478103fa9a548c2 (patch) | |
tree | cdec12f722c94e5a661ca1b0286d508e9241ceca /Source | |
parent | 71bfea5ab7c1a24f5235a3bf49ee8ed90de64218 (diff) | |
download | CMake-fd0e8b3a56bb04398d8e9e0ec478103fa9a548c2.zip CMake-fd0e8b3a56bb04398d8e9e0ec478103fa9a548c2.tar.gz CMake-fd0e8b3a56bb04398d8e9e0ec478103fa9a548c2.tar.bz2 |
BUG: fix bugs in new style list command that handles empty stuff
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmListCommand.cxx | 81 |
1 files changed, 24 insertions, 57 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index b815f2f..e81cbe7 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -212,13 +212,12 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) std::string value; size_t cc; + const char* sep = ""; for ( cc = 2; cc < args.size()-1; cc ++ ) { int item = atoi(args[cc].c_str()); - if (value.size()) - { - value += ";"; - } + value += sep; + sep = ";"; size_t nitem = varArgsExpanded.size(); if ( item < 0 ) { @@ -260,12 +259,11 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args) std::string listString; this->GetListString(listString, listName.c_str()); size_t cc; + const char* sep = ""; for ( cc = 2; cc < args.size(); ++ cc ) { - if ( listString.size() ) - { - listString += ";"; - } + listString += sep; + sep = ";"; listString += args[cc]; } @@ -358,13 +356,12 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args) } std::string value; + const char* sep = ""; for ( cc = 0; cc < varArgsExpanded.size(); cc ++ ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += varArgsExpanded[cc]; + sep = ";"; } this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -408,13 +405,12 @@ bool cmListCommand } std::string value; + const char* sep = ""; for ( cc = 0; cc < varArgsExpanded.size(); cc ++ ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += varArgsExpanded[cc]; + sep = ";"; } this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -442,13 +438,12 @@ bool cmListCommand std::string value; std::vector<std::string>::reverse_iterator it; + const char* sep = ""; for ( it = varArgsExpanded.rbegin(); it != varArgsExpanded.rend(); ++ it ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += it->c_str(); + sep = ";"; } this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -478,26 +473,10 @@ bool cmListCommand std::string value; -#if 0 - // Fast version, but does not keep the ordering - - std::set<std::string> unique(varArgsExpanded.begin(), varArgsExpanded.end()); - std::set<std::string>::iterator it; - for ( it = unique.begin(); it != unique.end(); ++ it ) - { - if (value.size()) - { - value += ";"; - } - value += it->c_str(); - } - -#else - - // Slower version, keep the ordering std::set<std::string> unique; std::vector<std::string>::iterator it; + const char* sep = ""; for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it ) { if (unique.find(*it) != unique.end()) @@ -505,14 +484,10 @@ bool cmListCommand continue; } unique.insert(*it); - - if (value.size()) - { - value += ";"; - } + value += sep; value += it->c_str(); + sep = ";"; } -#endif this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -542,19 +517,12 @@ bool cmListCommand std::string value; std::vector<std::string>::iterator it; + const char* sep = ""; for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it ) { - if(value.size() == 0 && - this->Makefile->GetPolicyStatus(cmPolicies::CMP0007) == - cmPolicies::NEW) - { - value += ";"; - } - if (value.size()) - { - value += ";"; - } + value += sep; value += it->c_str(); + sep = ";"; } this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -604,6 +572,7 @@ bool cmListCommand::HandleRemoveAtCommand( } std::string value; + const char* sep = ""; for ( cc = 0; cc < varArgsExpanded.size(); ++ cc ) { size_t kk; @@ -618,11 +587,9 @@ bool cmListCommand::HandleRemoveAtCommand( if ( !found ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += varArgsExpanded[cc]; + sep = ";"; } } |