summaryrefslogtreecommitdiff
path: root/Source/CursesDialog/cmCursesMainForm.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2004-06-23 10:13:02 -0400
committerBrad King <brad.king@kitware.com>2004-06-23 10:13:02 -0400
commit4eb0400c9807bd984a9983dc993dbd47275b4d65 (patch)
treecabf980b14e3e6c17e3b74c5829dff857194250b /Source/CursesDialog/cmCursesMainForm.cxx
parentf1842f913718f97cb53ff5e313ea0c99b97dc132 (diff)
downloadcmake-4eb0400c9807bd984a9983dc993dbd47275b4d65.tar.gz
ENH: Adding MODIFIED property to cache values that have been changed by the user.
Diffstat (limited to 'Source/CursesDialog/cmCursesMainForm.cxx')
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx45
1 files changed, 33 insertions, 12 deletions
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index ae89e07adf..aa8120353d 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -784,9 +784,7 @@ void cmCursesMainForm::RemoveEntry(const char* value)
// copy from the list box to the cache manager
void cmCursesMainForm::FillCacheManagerFromUI()
-{
- std::string tmpString;
-
+{
int size = m_Entries->size();
for(int i=0; i < size; i++)
{
@@ -795,17 +793,40 @@ void cmCursesMainForm::FillCacheManagerFromUI()
(*m_Entries)[i]->m_Key.c_str());
if (!it.IsAtEnd())
{
- tmpString = (*m_Entries)[i]->m_Entry->GetValue();
-
- // Remove trailing spaces, convert path to unix slashes
- std::string tmpSubString =
- tmpString.substr(0,tmpString.find_last_not_of(" ")+1);
- if ( it.GetType() == cmCacheManager::PATH ||
- it.GetType() == cmCacheManager::FILEPATH )
+ std::string oldValue = it.GetValue();
+ std::string newValue = (*m_Entries)[i]->m_Entry->GetValue();
+ std::string fixedOldValue;
+ std::string fixedNewValue;
+ this->FixValue(it.GetType(), oldValue, fixedOldValue);
+ this->FixValue(it.GetType(), newValue, fixedNewValue);
+
+ if(!(fixedOldValue == fixedNewValue))
{
- cmSystemTools::ConvertToUnixSlashes(tmpSubString);
+ // The user has changed the value. Mark it as modified.
+ it.SetProperty("MODIFIED", true);
}
- it.SetValue(tmpSubString.c_str());
+ it.SetValue(fixedNewValue.c_str());
+ }
+ }
+}
+
+void cmCursesMainForm::FixValue(cmCacheManager::CacheEntryType type,
+ const std::string& in, std::string& out) const
+{
+ out = in.substr(0,in.find_last_not_of(" ")+1);
+ if(type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH)
+ {
+ cmSystemTools::ConvertToUnixSlashes(out);
+ }
+ if(type == cmCacheManager::BOOL)
+ {
+ if(cmSystemTools::IsOff(out.c_str()))
+ {
+ out = "OFF";
+ }
+ else
+ {
+ out = "ON";
}
}
}