diff options
-rw-r--r-- | Source/cmCacheManager.cxx | 86 | ||||
-rw-r--r-- | Source/cmCacheManager.h | 6 | ||||
-rw-r--r-- | Source/cmState.cxx | 84 | ||||
-rw-r--r-- | Source/cmState.h | 6 | ||||
-rw-r--r-- | Source/cmake.cxx | 4 |
5 files changed, 93 insertions, 93 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index bfa60b3..ce8af55 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -27,90 +27,6 @@ cmCacheManager::cmCacheManager() this->CacheMinorVersion = 0; } -static bool ParseEntryWithoutType(const std::string& entry, - std::string& var, - std::string& value) -{ - // input line is: key=value - static cmsys::RegularExpression reg( - "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - // input line is: "key"=value - static cmsys::RegularExpression regQuoted( - "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - bool flag = false; - if(regQuoted.find(entry)) - { - var = regQuoted.match(1); - value = regQuoted.match(2); - flag = true; - } - else if (reg.find(entry)) - { - var = reg.match(1); - value = reg.match(2); - flag = true; - } - - // if value is enclosed in single quotes ('foo') then remove them - // it is used to enclose trailing space or tab - if (flag && - value.size() >= 2 && - value[0] == '\'' && - value[value.size() - 1] == '\'') - { - value = value.substr(1, - value.size() - 2); - } - - return flag; -} - -bool cmCacheManager::ParseEntry(const std::string& entry, - std::string& var, - std::string& value, - cmState::CacheEntryType& type) -{ - // input line is: key:type=value - static cmsys::RegularExpression reg( - "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - // input line is: "key":type=value - static cmsys::RegularExpression regQuoted( - "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - bool flag = false; - if(regQuoted.find(entry)) - { - var = regQuoted.match(1); - type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str()); - value = regQuoted.match(3); - flag = true; - } - else if (reg.find(entry)) - { - var = reg.match(1); - type = cmState::StringToCacheEntryType(reg.match(2).c_str()); - value = reg.match(3); - flag = true; - } - - // if value is enclosed in single quotes ('foo') then remove them - // it is used to enclose trailing space or tab - if (flag && - value.size() >= 2 && - value[0] == '\'' && - value[value.size() - 1] == '\'') - { - value = value.substr(1, - value.size() - 2); - } - - if (!flag) - { - return ParseEntryWithoutType(entry, var, value); - } - - return flag; -} - void cmCacheManager::CleanCMakeFiles(const std::string& path) { std::string glob = path; @@ -187,7 +103,7 @@ bool cmCacheManager::LoadCache(const std::string& path, } } e.SetProperty("HELPSTRING", helpString.c_str()); - if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type)) + if(cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type)) { if ( excludes.find(entryKey) == excludes.end() ) { diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 2440066..6f063eb 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -121,12 +121,6 @@ public: int GetSize() { return static_cast<int>(this->Cache.size()); } - ///! Break up a line like VAR:type="value" into var, type and value - static bool ParseEntry(const std::string& entry, - std::string& var, - std::string& value, - cmState::CacheEntryType& type); - ///! Get a value from the cache given a key const char* GetInitializedCacheValue(const std::string& key) const; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 3aad7f5..c5bbf42 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1769,3 +1769,87 @@ bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) { return lhs.Position != rhs.Position; } + +static bool ParseEntryWithoutType(const std::string& entry, + std::string& var, + std::string& value) +{ + // input line is: key=value + static cmsys::RegularExpression reg( + "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + // input line is: "key"=value + static cmsys::RegularExpression regQuoted( + "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + bool flag = false; + if(regQuoted.find(entry)) + { + var = regQuoted.match(1); + value = regQuoted.match(2); + flag = true; + } + else if (reg.find(entry)) + { + var = reg.match(1); + value = reg.match(2); + flag = true; + } + + // if value is enclosed in single quotes ('foo') then remove them + // it is used to enclose trailing space or tab + if (flag && + value.size() >= 2 && + value[0] == '\'' && + value[value.size() - 1] == '\'') + { + value = value.substr(1, + value.size() - 2); + } + + return flag; +} + +bool cmState::ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + CacheEntryType& type) +{ + // input line is: key:type=value + static cmsys::RegularExpression reg( + "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + // input line is: "key":type=value + static cmsys::RegularExpression regQuoted( + "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + bool flag = false; + if(regQuoted.find(entry)) + { + var = regQuoted.match(1); + type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str()); + value = regQuoted.match(3); + flag = true; + } + else if (reg.find(entry)) + { + var = reg.match(1); + type = cmState::StringToCacheEntryType(reg.match(2).c_str()); + value = reg.match(3); + flag = true; + } + + // if value is enclosed in single quotes ('foo') then remove them + // it is used to enclose trailing space or tab + if (flag && + value.size() >= 2 && + value[0] == '\'' && + value[value.size() - 1] == '\'') + { + value = value.substr(1, + value.size() - 2); + } + + if (!flag) + { + return ParseEntryWithoutType(entry, var, value); + } + + return flag; +} diff --git a/Source/cmState.h b/Source/cmState.h index 4c32831..fbc9275 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -242,6 +242,12 @@ public: void RemoveCacheEntryProperty(std::string const& key, std::string const& propertyName); + ///! Break up a line like VAR:type="value" into var, type and value + static bool ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + CacheEntryType& type); + Snapshot Reset(); // Define a property void DefineProperty(const std::string& name, cmProperty::ScopeType scope, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b90ac69..b1c2709 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -216,7 +216,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } std::string var, value; cmState::CacheEntryType type = cmState::UNINITIALIZED; - if(cmCacheManager::ParseEntry(entry, var, value, type)) + if(cmState::ParseCacheEntry(entry, var, value, type)) { // The value is transformed if it is a filepath for example, so // we can't compare whether the value is already in the cache until @@ -1722,7 +1722,7 @@ bool cmake::ParseCacheEntry(const std::string& entry, std::string& value, cmState::CacheEntryType& type) { - return cmCacheManager::ParseEntry(entry, var, value, type); + return cmState::ParseCacheEntry(entry, var, value, type); } int cmake::LoadCache() |