summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorSebastien Barre <sebastien.barre@kitware.com>2001-12-05 20:29:36 (GMT)
committerSebastien Barre <sebastien.barre@kitware.com>2001-12-05 20:29:36 (GMT)
commitecca17cfdd016e4ff6ff577824e6f1f44f8027fc (patch)
tree5368f10794d7ea3a9047ea2c03c119d588b07271 /Source/cmCacheManager.cxx
parente273223d6d881b9f9a84243ce7dcef4bbeeeebee (diff)
downloadCMake-ecca17cfdd016e4ff6ff577824e6f1f44f8027fc.zip
CMake-ecca17cfdd016e4ff6ff577824e6f1f44f8027fc.tar.gz
CMake-ecca17cfdd016e4ff6ff577824e6f1f44f8027fc.tar.bz2
Add single quotes feature.
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx51
1 files changed, 43 insertions, 8 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index c3af5e4..a8ea49a 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -127,21 +127,34 @@ bool cmCacheManager::ParseEntry(const char* entry,
cmRegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
// input line is: "key":type=value
cmRegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
+ bool flag = false;
if(regQuoted.find(entry))
{
var = regQuoted.match(1);
type = cmCacheManager::StringToType(regQuoted.match(2).c_str());
value = regQuoted.match(3);
- return true;
+ flag = true;
}
else if (reg.find(entry))
{
var = reg.match(1);
type = cmCacheManager::StringToType(reg.match(2).c_str());
value = reg.match(3);
- return true;
+ flag = true;
}
- return false;
+
+ // 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::LoadCache(const char* path,
@@ -365,8 +378,19 @@ bool cmCacheManager::SaveCache(const char* path)
key = i->first;
}
fout << key.c_str() << ":"
- << cmCacheManagerTypes[t] << "="
- << ce.m_Value << "\n\n";
+ << cmCacheManagerTypes[t] << "=";
+ // if value has trailing space or tab, enclose it in single quotes
+ if (ce.m_Value.size() &&
+ (ce.m_Value[ce.m_Value.size() - 1] == ' ' ||
+ ce.m_Value[ce.m_Value.size() - 1] == '\t'))
+ {
+ fout << '\'' << ce.m_Value << '\'';
+ }
+ else
+ {
+ fout << ce.m_Value;
+ }
+ fout << "\n\n";
}
}
@@ -398,8 +422,19 @@ bool cmCacheManager::SaveCache(const char* path)
key = i->first;
}
fout << key.c_str() << ":"
- << cmCacheManagerTypes[t] << "="
- << ce.m_Value << "\n";
+ << cmCacheManagerTypes[t] << "=";
+ // if value has trailing space or tab, enclose it in single quotes
+ if (ce.m_Value.size() &&
+ (ce.m_Value[ce.m_Value.size() - 1] == ' ' ||
+ ce.m_Value[ce.m_Value.size() - 1] == '\t'))
+ {
+ fout << '\'' << ce.m_Value << '\'';
+ }
+ else
+ {
+ fout << ce.m_Value;
+ }
+ fout << "\n";
}
}
fout << "\n";
@@ -408,7 +443,7 @@ bool cmCacheManager::SaveCache(const char* path)
cacheFile.c_str());
cmSystemTools::RemoveFile(tempFile.c_str());
return true;
-}
+ }
void cmCacheManager::OutputHelpString(std::ofstream& fout,
const std::string& helpString)