Minor tweaks.

This commit is contained in:
spx 2011-07-12 13:37:31 +00:00
parent c776cff348
commit 6ceacb0d98
4 changed files with 13 additions and 13 deletions

View File

@ -469,13 +469,13 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
end = result.find(L'#', pos + 1); end = result.find(L'#', pos + 1);
if (end != std::wstring::npos) if (end != std::wstring::npos)
{ {
std::wstring strVariable(result.begin() + pos + 1, result.begin() + end); std::wstring strVariable = result.substr(pos + 1, end - (pos + 1));
std::wstring strValue; std::wstring strValue;
if (GetVariable(strVariable, strValue)) if (GetVariable(strVariable, strValue))
{ {
// Variable found, replace it with the value // Variable found, replace it with the value
result.replace(result.begin() + pos, result.begin() + end + 1, strValue); result.replace(pos, end - pos + 1, strValue);
start = pos + strValue.length(); start = pos + strValue.length();
replaced = true; replaced = true;
} }
@ -493,7 +493,7 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
{ {
loop = false; loop = false;
} }
} while(loop); } while (loop);
return replaced; return replaced;
} }
@ -526,7 +526,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result)
pos2 = result.find(L'[', pos + 1); pos2 = result.find(L'[', pos + 1);
if (pos2 == std::wstring::npos || end < pos2) if (pos2 == std::wstring::npos || end < pos2)
{ {
std::wstring var(result.begin() + pos + 1, result.begin() + end); std::wstring var = result.substr(pos + 1, end - (pos + 1));
CMeasure* measure = GetMeasure(var); CMeasure* measure = GetMeasure(var);
if (measure) if (measure)
@ -534,7 +534,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result)
std::wstring value = measure->GetStringValue(AUTOSCALE_OFF, 1, -1, false); std::wstring value = measure->GetStringValue(AUTOSCALE_OFF, 1, -1, false);
// Measure found, replace it with the value // Measure found, replace it with the value
result.replace(result.begin() + pos, result.begin() + end + 1, value); result.replace(pos, end - pos + 1, value);
start = pos + value.length(); start = pos + value.length();
replaced = true; replaced = true;
} }
@ -557,7 +557,7 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result)
{ {
loop = false; loop = false;
} }
} while(loop); } while (loop);
} }
return replaced; return replaced;

View File

@ -213,10 +213,10 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
pos = str.find(m_Substitute[i], start); pos = str.find(m_Substitute[i], start);
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
{ {
str.replace(str.begin() + pos, str.begin() + pos + m_Substitute[i].size(), m_Substitute[i + 1]); str.replace(pos, m_Substitute[i].length(), m_Substitute[i + 1]);
start = pos + m_Substitute[i + 1].size(); start = pos + m_Substitute[i + 1].length();
} }
} while(pos != std::wstring::npos); } while (pos != std::wstring::npos);
} }
} }

View File

@ -625,11 +625,11 @@ bool CMeter::ReplaceMeasures(const std::vector<std::wstring>& stringValues, std:
pos = str.find(buffer, start); pos = str.find(buffer, start);
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
{ {
str.replace(str.begin() + pos, str.begin() + pos + wcslen(buffer), stringValues[i - 1]); str.replace(pos, wcslen(buffer), stringValues[i - 1]);
start = pos + stringValues[i - 1].length(); start = pos + stringValues[i - 1].length();
replaced = true; replaced = true;
} }
} while(pos != std::wstring::npos); } while (pos != std::wstring::npos);
} }
} }

View File

@ -97,7 +97,7 @@ std::vector<std::wstring> CRainmeter::ParseString(LPCTSTR str)
size_t pos = result[i].find(L"\""); size_t pos = result[i].find(L"\"");
while (pos != std::wstring::npos) while (pos != std::wstring::npos)
{ {
result[i].erase(result[i].begin() + pos, result[i].begin() + pos + 1); result[i].erase(pos, 1);
pos = result[i].find(L"\""); pos = result[i].find(L"\"");
} }
} }
@ -2245,7 +2245,7 @@ void CRainmeter::CreateDefaultConfigFile(const std::wstring& strFile)
size_t pos = strFile.find_last_of(L'\\'); size_t pos = strFile.find_last_of(L'\\');
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
{ {
std::wstring strPath(strFile.begin(), strFile.begin() + pos); std::wstring strPath(strFile, 0, pos);
CreateDirectory(strPath.c_str(), NULL); CreateDirectory(strPath.c_str(), NULL);
} }