Reverted the changes from r209.

This commit is contained in:
Kimmo Pekkola
2009-09-04 16:37:51 +00:00
parent 8239919333
commit 4bf4e51126
16 changed files with 116 additions and 136 deletions

View File

@ -132,14 +132,27 @@ void CConfigParser::SetVariable(const std::wstring& strVariable, const std::wstr
**
**
*/
const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures, bool bReplaceDefValue)
const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures)
{
static std::wstring result;
result = GetValue(section, key, defValue);
if (result == defValue && bReplaceDefValue == false)
if (section == NULL)
{
return result;
section = L"";
}
if (key == NULL)
{
key = L"";
}
if (defValue == NULL)
{
defValue = L"";
}
result = GetValue(section, key, defValue);
if (result == defValue)
{
return result;
}
// Check Litestep vars
@ -445,7 +458,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile)
items[0] = 0;
int res = GetPrivateProfileString( NULL, NULL, NULL, items, size, iniFile.c_str());
if (res == 0) return; // File not found
if (res != size - 2) break; // Fits in the buffer
if (res < size - 2) break; // Fits in the buffer
delete [] items;
size *= 2;
@ -474,7 +487,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile)
{
items[0] = 0;
int res = GetPrivateProfileString((*iter).first.c_str(), NULL, NULL, items, size, iniFile.c_str());
if (res != size - 2) break; // Fits in the buffer
if (res < size - 2) break; // Fits in the buffer
delete [] items;
size *= 2;
@ -490,11 +503,11 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile)
{
buffer[0] = 0;
int res = GetPrivateProfileString((*iter).first.c_str(), strKey.c_str(), L"", buffer, bufferSize, iniFile.c_str());
if (res != size - 2) break; // Fits in the buffer
if (res < bufferSize - 2) break; // Fits in the buffer
delete [] buffer;
bufferSize *= 2;
buffer = new WCHAR[size];
buffer = new WCHAR[bufferSize];
};
SetValue((*iter).first, strKey, buffer);
@ -593,4 +606,3 @@ std::vector<std::wstring> CConfigParser::GetKeys(const std::wstring& strSection)
return std::vector<std::wstring>();
}