diff options
author | Brad King <brad.king@kitware.com> | 2006-05-23 16:51:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-05-23 16:51:26 (GMT) |
commit | 9a74185695ef8312310576d6716d1626ed75a944 (patch) | |
tree | 03dc7bdabc81328d4028c1db3ada4f8a49f25ac9 /Source/cmMakefile.cxx | |
parent | 13a68cd97888d451d9f40b61891709af1648432b (diff) | |
download | CMake-9a74185695ef8312310576d6716d1626ed75a944.zip CMake-9a74185695ef8312310576d6716d1626ed75a944.tar.gz CMake-9a74185695ef8312310576d6716d1626ed75a944.tar.bz2 |
BUG: Fix REMOVE_DEFINITIONS command to not remove substrings.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index da86aea..fc92d45 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -36,6 +36,8 @@ #include <cmsys/RegularExpression.hxx> +#include <ctype.h> // for isspace + // default is not to be building executables cmMakefile::cmMakefile() { @@ -803,7 +805,29 @@ void cmMakefile::AddDefineFlag(const char* flag) void cmMakefile::RemoveDefineFlag(const char* flag) { - cmSystemTools::ReplaceString(this->DefineFlags, flag, " "); + // Check the length of the flag to remove. + std::string::size_type len = strlen(flag); + if(len < 1) + { + return; + } + + // Remove all instances of the flag that are surrounded by + // whitespace or the beginning/end of the string. + for(std::string::size_type lpos = this->DefineFlags.find(flag, 0); + lpos != std::string::npos; lpos = this->DefineFlags.find(flag, lpos)) + { + std::string::size_type rpos = lpos + len; + if((lpos <= 0 || isspace(this->DefineFlags[lpos-1])) && + (rpos >= this->DefineFlags.size() || isspace(this->DefineFlags[rpos]))) + { + this->DefineFlags.erase(lpos, len); + } + else + { + ++lpos; + } + } } void cmMakefile::AddLinkLibrary(const char* lib, |