Changed the ConfigParser that it allows some inline comments which start with a semicolon. This change is for backward compatibility.

This commit is contained in:
spx 2010-02-27 09:51:48 +00:00
parent 406793c6bb
commit f0763c5973

View File

@ -647,19 +647,28 @@ std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const
*/ */
double CConfigParser::ParseDouble(const std::wstring& string, double defValue, bool rejectExp) double CConfigParser::ParseDouble(const std::wstring& string, double defValue, bool rejectExp)
{ {
std::wstring::size_type pos;
// Ignore inline comments which start with ';'
if ((pos = string.find_first_of(L';')) != std::wstring::npos)
{
std::wstring temp(string, 0, pos);
return ParseDouble(temp, defValue, rejectExp);
}
if (rejectExp) if (rejectExp)
{ {
if (string.find_last_of(L"dDeE") != std::wstring::npos) // contains exponent part // Reject if the given string includes the exponential part
if (string.find_last_of(L"dDeE") != std::wstring::npos)
{ {
return defValue; return defValue;
} }
} }
std::wstring::size_type pos1 = string.find_first_not_of(L" \t\r\n"); if ((pos = string.find_first_not_of(L" \t\r\n")) != std::wstring::npos)
if (pos1 != std::wstring::npos)
{ {
// Trim white-space // Trim white-space
std::wstring temp(string, pos1, string.find_last_not_of(L" \t\r\n") - pos1 + 1); std::wstring temp(string, pos, string.find_last_not_of(L" \t\r\n") - pos + 1);
WCHAR* end = NULL; WCHAR* end = NULL;
errno = 0; errno = 0;