From f0763c597396d2406f92116177c096c58fc59f44 Mon Sep 17 00:00:00 2001 From: spx Date: Sat, 27 Feb 2010 09:51:48 +0000 Subject: [PATCH] Changed the ConfigParser that it allows some inline comments which start with a semicolon. This change is for backward compatibility. --- Library/ConfigParser.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index d37f29b6..206d7043 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -647,19 +647,28 @@ std::vector CConfigParser::Tokenize(const std::wstring& str, const */ 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 (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; } } - std::wstring::size_type pos1 = string.find_first_not_of(L" \t\r\n"); - if (pos1 != std::wstring::npos) + if ((pos = string.find_first_not_of(L" \t\r\n")) != std::wstring::npos) { // 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; errno = 0;