summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2003-08-01 18:10:26 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2003-08-01 18:10:26 (GMT)
commit2f98c791fae6f46af4463e9eed5d5a674d6f1ddb (patch)
treeb2022ff1d3310b88ee917368a444bceafd4c3beb /Source/cmCacheManager.cxx
parent7d33e05a15bfb56c8dfba4731c2008567f244972 (diff)
downloadCMake-2f98c791fae6f46af4463e9eed5d5a674d6f1ddb.zip
CMake-2f98c791fae6f46af4463e9eed5d5a674d6f1ddb.tar.gz
CMake-2f98c791fae6f46af4463e9eed5d5a674d6f1ddb.tar.bz2
ENH: Allow specifying cmake variables on the command line without specifying the type Bug #118 - Specifying cache entries with -D should not need the type
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 8d30fd0..4f272c9 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -81,6 +81,42 @@ bool cmCacheManager::LoadCache(const char* path,
bool cmCacheManager::ParseEntry(const char* entry,
std::string& var,
+ std::string& value)
+{
+ // input line is: key:type=value
+ cmsys::RegularExpression reg("^([^:]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
+ // input line is: "key":type=value
+ cmsys::RegularExpression regQuoted("^\"([^\"]*)\"=(.*[^\t ]|[\t ]*)[\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 char* entry,
+ std::string& var,
std::string& value,
CacheEntryType& type)
{