Condense parsing of cache entries

If a cache line is being parsed, it shouldn't matter whether it has a
type or not; just parse it however possible.
This commit is contained in:
Ben Boeckel 2010-11-22 15:45:30 -05:00
parent 122ebf1297
commit 8b143fab66
4 changed files with 11 additions and 13 deletions

View File

@ -93,7 +93,7 @@ bool cmCacheManager::LoadCache(const char* path,
return this->LoadCache(path, internal, emptySet, emptySet); return this->LoadCache(path, internal, emptySet, emptySet);
} }
bool cmCacheManager::ParseEntry(const char* entry, static bool ParseEntryWithoutType(const char* entry,
std::string& var, std::string& var,
std::string& value) std::string& value)
{ {
@ -169,6 +169,11 @@ bool cmCacheManager::ParseEntry(const char* entry,
value.size() - 2); value.size() - 2);
} }
if (!flag)
{
return ParseEntryWithoutType(entry, var, value);
}
return flag; return flag;
} }
@ -253,8 +258,7 @@ bool cmCacheManager::LoadCache(const char* path,
} }
} }
e.SetProperty("HELPSTRING", helpString.c_str()); e.SetProperty("HELPSTRING", helpString.c_str());
if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type) || if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type))
cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value))
{ {
if ( excludes.find(entryKey) == excludes.end() ) if ( excludes.find(entryKey) == excludes.end() )
{ {

View File

@ -139,10 +139,6 @@ public:
std::string& value, std::string& value,
CacheEntryType& type); CacheEntryType& type);
static bool ParseEntry(const char* entry,
std::string& var,
std::string& value);
///! Get a value from the cache given a key ///! Get a value from the cache given a key
const char* GetCacheValue(const char* key) const; const char* GetCacheValue(const char* key) const;

View File

@ -175,8 +175,7 @@ void cmLoadCacheCommand::CheckLine(const char* line)
std::string var; std::string var;
std::string value; std::string value;
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
if(cmCacheManager::ParseEntry(line, var, value, type) || if(cmCacheManager::ParseEntry(line, var, value, type))
cmCacheManager::ParseEntry(line, var, value))
{ {
// Found a real entry. See if this one was requested. // Found a real entry. See if this one was requested.
if(this->VariablesToRead.find(var) != this->VariablesToRead.end()) if(this->VariablesToRead.find(var) != this->VariablesToRead.end())

View File

@ -362,8 +362,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
} }
std::string var, value; std::string var, value;
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type) || if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type))
cmCacheManager::ParseEntry(entry.c_str(), var, value))
{ {
this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(), this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
"No help, variable specified on the command line.", type); "No help, variable specified on the command line.", type);