Strip the string that user answers
This commit is contained in:
parent
a4b076811c
commit
8491551d6a
|
@ -39,9 +39,20 @@ void cmakewizard::AskUser(const char* key, cmCacheManager::CacheIterator& iter)
|
|||
char buffer[4096];
|
||||
buffer[0] = 0;
|
||||
fgets(buffer, sizeof(buffer)-1, stdin);
|
||||
if(buffer[0])
|
||||
char ch = 0;
|
||||
|
||||
if(strlen(buffer) > 0)
|
||||
{
|
||||
std::string sbuffer = buffer;
|
||||
std::string::size_type pos = sbuffer.find_last_not_of(" \n\r\t");
|
||||
std::string value = "";
|
||||
if ( pos != std::string::npos )
|
||||
{
|
||||
value = sbuffer.substr(0, pos+1);
|
||||
}
|
||||
|
||||
if ( value.size() > 0 )
|
||||
{
|
||||
std::string value = buffer;
|
||||
if(iter.GetType() == cmCacheManager::PATH ||
|
||||
iter.GetType() == cmCacheManager::FILEPATH)
|
||||
{
|
||||
|
@ -56,6 +67,7 @@ void cmakewizard::AskUser(const char* key, cmCacheManager::CacheIterator& iter)
|
|||
}
|
||||
iter.SetValue(value.c_str());
|
||||
}
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue