mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- Additional fix for r502. Functions/Measures/Counter in Formula are now case-insensitive in MeasureCalc.
- "[Measure]" is now case-insensitive in DynamicVariables.
This commit is contained in:
parent
99508e090b
commit
3d33a16f9f
@ -504,12 +504,12 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result)
|
|||||||
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.begin() + pos + 1, result.begin() + end);
|
||||||
|
|
||||||
std::map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.find(var);
|
CMeasure* measure = GetMeasure(var);
|
||||||
if (iter != m_Measures.end())
|
if (measure)
|
||||||
{
|
{
|
||||||
std::wstring value = (*iter).second->GetStringValue(false, 1, 5, false);
|
std::wstring value = measure->GetStringValue(false, 1, 5, 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(result.begin() + pos, result.begin() + end + 1, value);
|
||||||
start = pos + value.length();
|
start = pos + value.length();
|
||||||
@ -612,6 +612,20 @@ void CConfigParser::AddMeasure(CMeasure* pMeasure)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMeasure* CConfigParser::GetMeasure(const std::wstring& name)
|
||||||
|
{
|
||||||
|
std::map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.begin();
|
||||||
|
for ( ; iter != m_Measures.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (wcsicmp((*iter).first.c_str(), name.c_str()) == 0)
|
||||||
|
{
|
||||||
|
return (*iter).second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
double CConfigParser::ReadFloat(LPCTSTR section, LPCTSTR key, double defValue)
|
double CConfigParser::ReadFloat(LPCTSTR section, LPCTSTR key, double defValue)
|
||||||
{
|
{
|
||||||
TCHAR buffer[256];
|
TCHAR buffer[256];
|
||||||
|
@ -70,6 +70,7 @@ private:
|
|||||||
void ReadVariables();
|
void ReadVariables();
|
||||||
bool ReplaceVariables(std::wstring& result);
|
bool ReplaceVariables(std::wstring& result);
|
||||||
bool ReplaceMeasures(std::wstring& result);
|
bool ReplaceMeasures(std::wstring& result);
|
||||||
|
CMeasure* GetMeasure(const std::wstring& name);
|
||||||
|
|
||||||
void ReadIniFile(const std::vector<std::wstring>& iniFileMappings, const std::wstring& strFileName, int depth = 0);
|
void ReadIniFile(const std::vector<std::wstring>& iniFileMappings, const std::wstring& strFileName, int depth = 0);
|
||||||
void SetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strValue);
|
void SetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strValue);
|
||||||
|
@ -141,7 +141,6 @@ void CMeasureCalc::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
|||||||
** FormulaReplace
|
** FormulaReplace
|
||||||
**
|
**
|
||||||
** This replaces the word Random in m_Formula with a random number
|
** This replaces the word Random in m_Formula with a random number
|
||||||
** and all cases of counter with Counter
|
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
void CMeasureCalc::FormulaReplace()
|
void CMeasureCalc::FormulaReplace()
|
||||||
@ -151,7 +150,7 @@ void CMeasureCalc::FormulaReplace()
|
|||||||
m_Formula = m_FormulaHolder;
|
m_Formula = m_FormulaHolder;
|
||||||
std::wstring::size_type loc = 0;
|
std::wstring::size_type loc = 0;
|
||||||
|
|
||||||
while ((loc = m_Formula.find_first_of(L"RrCc", loc)) != std::wstring::npos)
|
while ((loc = m_Formula.find_first_of(L"Rr", loc)) != std::wstring::npos)
|
||||||
{
|
{
|
||||||
if (wcsnicmp(L"Random", m_Formula.c_str() + loc, 6) == 0)
|
if (wcsnicmp(L"Random", m_Formula.c_str() + loc, 6) == 0)
|
||||||
{
|
{
|
||||||
@ -165,11 +164,6 @@ void CMeasureCalc::FormulaReplace()
|
|||||||
m_Formula.replace(loc, 6, buffer);
|
m_Formula.replace(loc, 6, buffer);
|
||||||
loc += wcslen(buffer);
|
loc += wcslen(buffer);
|
||||||
}
|
}
|
||||||
else if (wcsnicmp(L"Counter", m_Formula.c_str() + loc, 7) == 0)
|
|
||||||
{
|
|
||||||
m_Formula.replace(loc, 7, L"Counter");
|
|
||||||
loc += 7;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++loc;
|
++loc;
|
||||||
|
@ -108,7 +108,7 @@ int StrMap_LenIndexOf( hqStrMap* strmap, const char *str, size_t len, void **dat
|
|||||||
char *Rec = strmap->FList;
|
char *Rec = strmap->FList;
|
||||||
for (i=0; i<strmap->FCount; i++) {
|
for (i=0; i<strmap->FCount; i++) {
|
||||||
int recLen = *(int*)(Rec + sizeof(char*));
|
int recLen = *(int*)(Rec + sizeof(char*));
|
||||||
if (recLen==len && strncmp( str, *(char**)Rec, recLen )==0 ) {
|
if (recLen==len && strnicmp( str, *(char**)Rec, recLen )==0 ) {
|
||||||
*data = (Rec + sizeof(char*) + sizeof(int));
|
*data = (Rec + sizeof(char*) + sizeof(int));
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user