diff options
author | Brad King <brad.king@kitware.com> | 2013-01-23 20:11:09 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-01-23 20:11:09 (GMT) |
commit | e7be8be8c0213060fd2ba2cc7b4ef060d94094b6 (patch) | |
tree | 0c7d059d9021ea891dbd247097dc36d1641a6b8b | |
parent | 95f88fd2a186270b49d58ed0064e0790953f9bc9 (diff) | |
parent | f447db7f102519e09258f0bd06668a9ae572ec68 (diff) | |
download | CMake-e7be8be8c0213060fd2ba2cc7b4ef060d94094b6.zip CMake-e7be8be8c0213060fd2ba2cc7b4ef060d94094b6.tar.gz CMake-e7be8be8c0213060fd2ba2cc7b4ef060d94094b6.tar.bz2 |
Merge topic 'xcode-duplicate-flags-13354'
f447db7 XCode generator won't infinitely parse compiler flags (bug #13354).
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2cfe4da..0681ce5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1367,16 +1367,18 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } //---------------------------------------------------------------------------- -// This function removes each occurence of the flag and returns the last one +// This function removes each occurrence of the flag and returns the last one // (i.e., the dominant flag in GCC) std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, std::string& flags) { std::string retFlag; - std::string::size_type pos = flags.rfind(flag); + std::string::size_type lastOccurancePos = flags.rfind(flag); bool saved = false; - while(pos != flags.npos) + while(lastOccurancePos != flags.npos) { + //increment pos, we use lastOccurancePos to reduce search space on next inc + std::string::size_type pos = lastOccurancePos; if(pos == 0 || flags[pos-1]==' ') { while(pos < flags.size() && flags[pos] != ' ') @@ -1388,9 +1390,12 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, flags[pos] = ' '; pos++; } - } saved = true; - pos = flags.rfind(flag); + } + //decrement lastOccurancePos while making sure we don't loop around + //and become a very large positive number since size_type is unsigned + lastOccurancePos = lastOccurancePos == 0 ? 0 : lastOccurancePos-1; + lastOccurancePos = flags.rfind(flag,lastOccurancePos); } return retFlag; } |