diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 708d7bcd..9a22b25e 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -1137,14 +1137,15 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR config, int for ( ; iter != sections.end(); ++iter) { std::unordered_set foundKeys; - bool isVariables = (_wcsicmp((*iter).c_str(), L"Variables") == 0); - bool isMetadata = (config == NULL && _wcsicmp((*iter).c_str(), L"Metadata") == 0); + const WCHAR* sectionName = (*iter).c_str(); + bool isVariables = (_wcsicmp(sectionName, L"Variables") == 0); + bool isMetadata = (config == NULL && _wcsicmp(sectionName, L"Metadata") == 0); // Read all "key=value" from the section do { items[0] = 0; - DWORD res = GetPrivateProfileSection((*iter).c_str(), items, itemsSize, iniRead.c_str()); + DWORD res = GetPrivateProfileSection(sectionName, items, itemsSize, iniRead.c_str()); if (res < itemsSize - 2) // Fits in the buffer { epos = items + res; diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index b5ecfa9e..a63d84a7 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -73,15 +73,15 @@ void CDialogAbout::Open(const WCHAR* name) if (name) { - if (_wcsnicmp(name, L"Measures", 8) == 0) + if (_wcsicmp(name, L"Measures") == 0) { tab = 1; } - else if (_wcsnicmp(name, L"Plugins", 7) == 0) + else if (_wcsicmp(name, L"Plugins") == 0) { tab = 2; } - else if (_wcsnicmp(name, L"Version", 7) == 0) + else if (_wcsicmp(name, L"Version") == 0) { tab = 3; } diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index f02730e7..8113860d 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -72,11 +72,11 @@ void CDialogManage::Open(const WCHAR* name) if (name) { - if (_wcsnicmp(name, L"Themes", 6) == 0) + if (_wcsicmp(name, L"Themes") == 0) { tab = 1; } - else if (_wcsnicmp(name, L"Settings", 8) == 0) + else if (_wcsicmp(name, L"Settings") == 0) { tab = 2; } diff --git a/Library/MeasureNet.cpp b/Library/MeasureNet.cpp index 3580d5a5..41fd6d67 100644 --- a/Library/MeasureNet.cpp +++ b/Library/MeasureNet.cpp @@ -591,7 +591,7 @@ void CMeasureNet::ReadStats(const WCHAR* iniFile, std::wstring& statsDate) CConfigParser parser; parser.Initialize(iniFile, NULL, NULL, L"Statistics"); - std::wstring date = parser.ReadString(L"Statistics", L"Since", L"", false); + const std::wstring& date = parser.ReadString(L"Statistics", L"Since", L"", false); if (!date.empty()) { statsDate = date; diff --git a/Library/MeasureRegistry.cpp b/Library/MeasureRegistry.cpp index 5dee4317..a09a7260 100644 --- a/Library/MeasureRegistry.cpp +++ b/Library/MeasureRegistry.cpp @@ -119,38 +119,39 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadConfig(parser, section); - const std::wstring& keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER"); - if (_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0) + const WCHAR* keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER").c_str(); + if (_wcsicmp(keyname, L"HKEY_CLASSES_ROOT") == 0) { m_HKey = HKEY_CLASSES_ROOT; } - else if (_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_CONFIG") == 0) + else if (_wcsicmp(keyname, L"HKEY_CURRENT_CONFIG") == 0) { m_HKey = HKEY_CURRENT_CONFIG; } - else if (_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_USER") == 0) + else if (_wcsicmp(keyname, L"HKEY_CURRENT_USER") == 0) { m_HKey = HKEY_CURRENT_USER; } - else if (_wcsicmp(keyname.c_str(), L"HKEY_LOCAL_MACHINE") == 0) + else if (_wcsicmp(keyname, L"HKEY_LOCAL_MACHINE") == 0) { m_HKey = HKEY_LOCAL_MACHINE; } - else if (_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0) + else if (_wcsicmp(keyname, L"HKEY_CLASSES_ROOT") == 0) { m_HKey = HKEY_CLASSES_ROOT; } - else if (_wcsicmp(keyname.c_str(), L"HKEY_PERFORMANCE_DATA") == 0) + else if (_wcsicmp(keyname, L"HKEY_PERFORMANCE_DATA") == 0) { m_HKey = HKEY_PERFORMANCE_DATA; } - else if (_wcsicmp(keyname.c_str(), L"HKEY_DYN_DATA") == 0) + else if (_wcsicmp(keyname, L"HKEY_DYN_DATA") == 0) { m_HKey = HKEY_DYN_DATA; } else { - std::wstring error = L"HKEY=" + keyname; + std::wstring error = L"HKEY="; + error += keyname; error += L" is not valid in ["; error += m_Name; error += L"]"; diff --git a/Library/MeasureScript.cpp b/Library/MeasureScript.cpp index d3e55ef4..bb470459 100644 --- a/Library/MeasureScript.cpp +++ b/Library/MeasureScript.cpp @@ -134,7 +134,7 @@ void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section) // Read common configs CMeasure::ReadConfig(parser, section); - std::wstring file = parser.ReadString(section, L"ScriptFile", L""); + const std::wstring& file = parser.ReadString(section, L"ScriptFile", L""); if (!file.empty()) { @@ -185,7 +185,7 @@ void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section) const char* strKey = lua_tostring(L, -1); std::wstring wstrKey = ConvertToWide(strKey); - std::wstring wstrValue = parser.ReadString(section, wstrKey.c_str(), L""); + const std::wstring& wstrValue = parser.ReadString(section, wstrKey.c_str(), L""); if (!wstrValue.empty()) { diff --git a/Library/MeasureTime.cpp b/Library/MeasureTime.cpp index 93ac4e41..af33286c 100644 --- a/Library/MeasureTime.cpp +++ b/Library/MeasureTime.cpp @@ -127,11 +127,12 @@ bool CMeasureTime::Update() FileTimeToSystemTime(&ftToday, &sysToday); - if (_wcsicmp(L"locale-time", m_Format.c_str()) == 0) + const WCHAR* format = m_Format.c_str(); + if (_wcsicmp(L"locale-time", format) == 0) { GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH); } - else if (_wcsicmp(L"locale-date", m_Format.c_str()) == 0) + else if (_wcsicmp(L"locale-date", format) == 0) { GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH); } @@ -148,7 +149,7 @@ bool CMeasureTime::Update() today.tm_yday = GetYearDay(sysToday.wYear, sysToday.wMonth, sysToday.wDay); today.tm_year = sysToday.wYear - 1900; - TimeToString(tmpSz, MAX_LINE_LENGTH, m_Format.c_str(), &today); + TimeToString(tmpSz, MAX_LINE_LENGTH, format, &today); } m_Value = wcstod(tmpSz, NULL); @@ -197,17 +198,18 @@ const WCHAR* CMeasureTime::GetStringValue(AUTOSCALE autoScale, double scale, int // Create the string if (!m_Format.empty()) { - if (_wcsicmp(L"locale-time", m_Format.c_str()) == 0) + const WCHAR* format = m_Format.c_str(); + if (_wcsicmp(L"locale-time", format) == 0) { GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH); } - else if (_wcsicmp(L"locale-date", m_Format.c_str()) == 0) + else if (_wcsicmp(L"locale-date", format) == 0) { GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH); } else { - TimeToString(tmpSz, MAX_LINE_LENGTH, m_Format.c_str(), &today); + TimeToString(tmpSz, MAX_LINE_LENGTH, format, &today); } } else @@ -230,8 +232,8 @@ void CMeasureTime::ReadConfig(CConfigParser& parser, const WCHAR* section) m_Format = parser.ReadString(section, L"Format", L""); - std::wstring timezone = parser.ReadString(section, L"TimeZone", L"local"); - if (_wcsicmp(L"local", timezone.c_str()) == 0) + const WCHAR* timezone = parser.ReadString(section, L"TimeZone", L"local").c_str(); + if (_wcsicmp(L"local", timezone) == 0) { SYSTEMTIME sysLocalTime, sysUTCTime; GetLocalTime(&sysLocalTime); @@ -251,7 +253,7 @@ void CMeasureTime::ReadConfig(CConfigParser& parser, const WCHAR* section) } else { - double zone = wcstod(timezone.c_str(), NULL); + double zone = wcstod(timezone, NULL); bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1); struct tm* today; diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 141c6234..c7f9bbc1 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -467,10 +467,11 @@ void CMeter::BindMeasure(const std::list& measures) } // Go through the list and check it there is a measure for us + const WCHAR* measure = m_MeasureName.c_str(); std::list::const_iterator i = measures.begin(); for ( ; i != measures.end(); ++i) { - if (_wcsicmp((*i)->GetName(), m_MeasureName.c_str()) == 0) + if (_wcsicmp((*i)->GetName(), measure) == 0) { m_Measure = (*i); return; @@ -757,29 +758,30 @@ void CMeter::UpdateToolTip() if (!m_ToolTipIcon.empty()) { - if (_wcsicmp(m_ToolTipIcon.c_str(), L"INFO") == 0) + const WCHAR* tipIcon = m_ToolTipIcon.c_str(); + if (_wcsicmp(tipIcon, L"INFO") == 0) { hIcon = (HICON)TTI_INFO; } - else if (_wcsicmp(m_ToolTipIcon.c_str(), L"WARNING") == 0) + else if (_wcsicmp(tipIcon, L"WARNING") == 0) { hIcon = (HICON)TTI_WARNING; } - else if (_wcsicmp(m_ToolTipIcon.c_str(), L"ERROR") == 0) + else if (_wcsicmp(tipIcon, L"ERROR") == 0) { hIcon = (HICON)TTI_ERROR; } - else if (_wcsicmp(m_ToolTipIcon.c_str(), L"QUESTION") == 0) + else if (_wcsicmp(tipIcon, L"QUESTION") == 0) { hIcon = LoadIcon(NULL, IDI_QUESTION); } - else if (_wcsicmp(m_ToolTipIcon.c_str(), L"SHIELD") == 0) + else if (_wcsicmp(tipIcon, L"SHIELD") == 0) { hIcon = LoadIcon(NULL, IDI_SHIELD); } else { - hIcon = (HICON)LoadImage(NULL, m_ToolTipIcon.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE); + hIcon = (HICON)LoadImage(NULL, tipIcon, IMAGE_ICON, 0, 0, LR_LOADFROMFILE); destroy = true; } } diff --git a/Library/MeterBar.cpp b/Library/MeterBar.cpp index 9f307e06..62cfc647 100644 --- a/Library/MeterBar.cpp +++ b/Library/MeterBar.cpp @@ -119,18 +119,19 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section) m_Flip = parser.ReadInt(section, L"Flip", 0) == 1; - const std::wstring& orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL"); - if (_wcsicmp(L"VERTICAL", orientation.c_str()) == 0) + const WCHAR* orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL").c_str(); + if (_wcsicmp(L"VERTICAL", orientation) == 0) { m_Orientation = VERTICAL; } - else if (_wcsicmp(L"HORIZONTAL", orientation.c_str()) == 0) + else if (_wcsicmp(L"HORIZONTAL", orientation) == 0) { m_Orientation = HORIZONTAL; } else { - std::wstring error = L"BarOrientation=" + orientation; + std::wstring error = L"BarOrientation="; + error += orientation; error += L" is not valid in ["; error += m_Name; error += L"]"; diff --git a/Library/MeterBitmap.cpp b/Library/MeterBitmap.cpp index 10e322f1..bd1b66de 100644 --- a/Library/MeterBitmap.cpp +++ b/Library/MeterBitmap.cpp @@ -196,22 +196,23 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section) m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0); - const std::wstring& align = parser.ReadString(section, L"BitmapAlign", L"LEFT"); - if (_wcsicmp(align.c_str(), L"LEFT") == 0) + const WCHAR* align = parser.ReadString(section, L"BitmapAlign", L"LEFT").c_str(); + if (_wcsicmp(align, L"LEFT") == 0) { m_Align = ALIGN_LEFT; } - else if (_wcsicmp(align.c_str(), L"RIGHT") == 0) + else if (_wcsicmp(align, L"RIGHT") == 0) { m_Align = ALIGN_RIGHT; } - else if (_wcsicmp(align.c_str(), L"CENTER") == 0) + else if (_wcsicmp(align, L"CENTER") == 0) { m_Align = ALIGN_CENTER; } else { - std::wstring error = L"BitmapAlign=" + align; + std::wstring error = L"BitmapAlign="; + error += align; error += L" is not valid in ["; error += m_Name; error += L"]"; diff --git a/Library/MeterHistogram.cpp b/Library/MeterHistogram.cpp index 1070e91a..a0798145 100644 --- a/Library/MeterHistogram.cpp +++ b/Library/MeterHistogram.cpp @@ -515,10 +515,11 @@ void CMeterHistogram::BindMeasure(const std::list& measures) if (!m_SecondaryMeasureName.empty()) { // Go through the list and check it there is a secondary measure for us + const WCHAR* name = m_SecondaryMeasureName.c_str(); std::list::const_iterator i = measures.begin(); for ( ; i != measures.end(); ++i) { - if (_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0) + if (_wcsicmp((*i)->GetName(), name) == 0) { m_SecondaryMeasure = (*i); CMeter::SetAllMeasures(m_SecondaryMeasure); diff --git a/Library/MeterImage.cpp b/Library/MeterImage.cpp index b4b5f40d..9012d04a 100644 --- a/Library/MeterImage.cpp +++ b/Library/MeterImage.cpp @@ -373,10 +373,11 @@ void CMeterImage::BindMeasure(const std::list& measures) for (; j != m_MeasureNames.end(); ++j) { // Go through the list and check it there is a secondary measures for us + const WCHAR* name = (*j).c_str(); std::list::const_iterator i = measures.begin(); for ( ; i != measures.end(); ++i) { - if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0) + if (_wcsicmp((*i)->GetName(), name) == 0) { m_Measures.push_back(*i); break; diff --git a/Library/MeterLine.cpp b/Library/MeterLine.cpp index de805c2a..8b780e03 100644 --- a/Library/MeterLine.cpp +++ b/Library/MeterLine.cpp @@ -362,10 +362,11 @@ void CMeterLine::BindMeasure(const std::list& measures) for (; j != m_MeasureNames.end(); ++j) { // Go through the list and check it there is a secondary measure for us + const WCHAR* name = (*j).c_str(); std::list::const_iterator i = measures.begin(); for ( ; i != measures.end(); ++i) { - if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0) + if (_wcsicmp((*i)->GetName(), name) == 0) { m_Measures.push_back(*i); break; diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index b80b73ea..95b1db03 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -362,96 +362,100 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section) } m_Scale = wcstod(scale.c_str(), NULL); - const std::wstring& align = parser.ReadString(section, L"StringAlign", L"LEFT"); - if (_wcsicmp(align.c_str(), L"LEFT") == 0) + const WCHAR* align = parser.ReadString(section, L"StringAlign", L"LEFT").c_str(); + if (_wcsicmp(align, L"LEFT") == 0) { m_Align = ALIGN_LEFT; } - else if (_wcsicmp(align.c_str(), L"RIGHT") == 0) + else if (_wcsicmp(align, L"RIGHT") == 0) { m_Align = ALIGN_RIGHT; } - else if (_wcsicmp(align.c_str(), L"CENTER") == 0) + else if (_wcsicmp(align, L"CENTER") == 0) { m_Align = ALIGN_CENTER; } else { - std::wstring error = L"StringAlign=" + align; + std::wstring error = L"StringAlign="; + error += align; error += L" is not valid in ["; error += m_Name; error += L"]"; throw CError(error); } - const std::wstring& stringCase = parser.ReadString(section, L"StringCase", L"NONE"); - if (_wcsicmp(stringCase.c_str(), L"NONE") == 0) + const WCHAR* stringCase = parser.ReadString(section, L"StringCase", L"NONE").c_str(); + if (_wcsicmp(stringCase, L"NONE") == 0) { m_textCase = TEXTCASE_NONE; } - else if (_wcsicmp(stringCase.c_str(), L"UPPER") == 0) + else if (_wcsicmp(stringCase, L"UPPER") == 0) { m_textCase = TEXTCASE_UPPER; } - else if (_wcsicmp(stringCase.c_str(), L"LOWER") == 0) + else if (_wcsicmp(stringCase, L"LOWER") == 0) { m_textCase = TEXTCASE_LOWER; } - else if (_wcsicmp(stringCase.c_str(), L"PROPER") == 0) + else if (_wcsicmp(stringCase, L"PROPER") == 0) { m_textCase = TEXTCASE_PROPER; } else { - std::wstring error = L"StringCase=" + stringCase; + std::wstring error = L"StringCase="; + error += stringCase; error += L" is not valid in ["; error += m_Name; error += L"]"; throw CError(error); } - const std::wstring& style = parser.ReadString(section, L"StringStyle", L"NORMAL"); - if (_wcsicmp(style.c_str(), L"NORMAL") == 0) + const WCHAR* style = parser.ReadString(section, L"StringStyle", L"NORMAL").c_str(); + if (_wcsicmp(style, L"NORMAL") == 0) { m_Style = NORMAL; } - else if (_wcsicmp(style.c_str(), L"BOLD") == 0) + else if (_wcsicmp(style, L"BOLD") == 0) { m_Style = BOLD; } - else if (_wcsicmp(style.c_str(), L"ITALIC") == 0) + else if (_wcsicmp(style, L"ITALIC") == 0) { m_Style = ITALIC; } - else if (_wcsicmp(style.c_str(), L"BOLDITALIC") == 0) + else if (_wcsicmp(style, L"BOLDITALIC") == 0) { m_Style = BOLDITALIC; } else { - std::wstring error = L"StringStyle=" + style; + std::wstring error = L"StringStyle="; + error += style; error += L" is not valid in ["; error += m_Name; error += L"]"; throw CError(error); } - const std::wstring& effect = parser.ReadString(section, L"StringEffect", L"NONE"); - if (_wcsicmp(effect.c_str(), L"NONE") == 0) + const WCHAR* effect = parser.ReadString(section, L"StringEffect", L"NONE").c_str(); + if (_wcsicmp(effect, L"NONE") == 0) { m_Effect = EFFECT_NONE; } - else if (_wcsicmp(effect.c_str(), L"SHADOW") == 0) + else if (_wcsicmp(effect, L"SHADOW") == 0) { m_Effect = EFFECT_SHADOW; } - else if (_wcsicmp(effect.c_str(), L"BORDER") == 0) + else if (_wcsicmp(effect, L"BORDER") == 0) { m_Effect = EFFECT_BORDER; } else { - std::wstring error = L"StringEffect=" + effect; + std::wstring error = L"StringEffect="; + error += effect; error += L" is not valid in ["; error += m_Name; error += L"]"; @@ -682,10 +686,11 @@ void CMeterString::BindMeasure(const std::list& measures) for (; j != m_MeasureNames.end(); ++j) { // Go through the list and check it there is a secondary measures for us + const WCHAR* name = (*j).c_str(); std::list::const_iterator i = measures.begin(); for ( ; i != measures.end(); ++i) { - if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0) + if (_wcsicmp((*i)->GetName(), name) == 0) { m_Measures.push_back(*i); break; diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index b4a2c807..457bdf53 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -1109,7 +1109,7 @@ void CMeterWindow::ResizeBlur(const WCHAR* arg, int mode) { WCHAR* parseSz = _wcsdup(arg); double val; - int type, x, y, w, h; + int type, x, y, w = 0, h = 0; WCHAR* token = wcstok(parseSz, L","); if (token) @@ -1155,7 +1155,7 @@ void CMeterWindow::ResizeBlur(const WCHAR* arg, int mode) case 1: tempRegion = CreateRectRgn(x, y, w, h); break; - + case 2: token = wcstok(NULL, L","); if (token) @@ -2084,7 +2084,7 @@ bool CMeterWindow::ReadSkin() SetWindowSizeVariables(0, 0); // Global settings - std::wstring group = m_Parser.ReadString(L"Rainmeter", L"Group", L""); + const std::wstring& group = m_Parser.ReadString(L"Rainmeter", L"Group", L""); if (!group.empty()) { m_ConfigGroup += L"|"; @@ -2160,7 +2160,7 @@ bool CMeterWindow::ReadSkin() { if (0 != m_Parser.ReadInt(L"Rainmeter", L"Blur", 0)) { - std::wstring blurRegion = m_Parser.ReadString(L"Rainmeter", L"BlurRegion", L"", false); + std::wstring& blurRegion = (std::wstring&)m_Parser.ReadString(L"Rainmeter", L"BlurRegion", L"", false); if (!blurRegion.empty()) { @@ -2192,7 +2192,7 @@ bool CMeterWindow::ReadSkin() } // Checking for localfonts - std::wstring localFont = m_Parser.ReadString(L"Rainmeter", L"LocalFont", L""); + std::wstring& localFont = (std::wstring&)m_Parser.ReadString(L"Rainmeter", L"LocalFont", L""); // If there is a local font we want to load it if (!localFont.empty()) { @@ -4981,27 +4981,25 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam) return TRUE; // This meterwindow has been deactivated } - std::wstring str = (const WCHAR*)pCopyDataStruct->lpData; + const WCHAR* str = (const WCHAR*)pCopyDataStruct->lpData; - if (_wcsnicmp(L"PLAY ", str.c_str(), 5) == 0 || - _wcsnicmp(L"PLAYLOOP ", str.c_str(), 9) == 0 || - _wcsnicmp(L"PLAYSTOP", str.c_str(), 8) == 0) + if (_wcsnicmp(L"PLAY ", str, 5) == 0 || + _wcsnicmp(L"PLAYLOOP ", str, 9) == 0 || + _wcsnicmp(L"PLAYSTOP", str, 8) == 0) { // Audio commands are special cases. - m_Rainmeter->ExecuteCommand(str.c_str(), this); + m_Rainmeter->ExecuteCommand(str, this); return TRUE; } - std::wstring bang; - std::wstring arg; + std::wstring bang, arg; // Find the first space - std::wstring::size_type pos = str.find(' '); - if (pos != std::wstring::npos) + const WCHAR* pos = wcschr(str, L' '); + if (pos) { - bang.assign(str, 0, pos); - str.erase(0, pos + 1); - arg = str; + bang.assign(str, 0, pos - str); + arg = pos + 1; } else { @@ -5116,10 +5114,11 @@ std::wstring CMeterWindow::GetSkinRootPath() CMeter* CMeterWindow::GetMeter(const std::wstring& meterName) { + const WCHAR* name = meterName.c_str(); std::list::const_iterator j = m_Meters.begin(); for ( ; j != m_Meters.end(); ++j) { - if (_wcsicmp((*j)->GetName(), meterName.c_str()) == 0) + if (_wcsicmp((*j)->GetName(), name) == 0) { return (*j); } @@ -5129,10 +5128,11 @@ CMeter* CMeterWindow::GetMeter(const std::wstring& meterName) CMeasure* CMeterWindow::GetMeasure(const std::wstring& measureName) { + const WCHAR* name = measureName.c_str(); std::list::const_iterator i = m_Measures.begin(); for ( ; i != m_Measures.end(); ++i) { - if (_wcsicmp((*i)->GetName(), measureName.c_str()) == 0) + if (_wcsicmp((*i)->GetName(), name) == 0) { return (*i); } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index bf02ade1..5d91d99f 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1209,10 +1209,10 @@ bool CRainmeter::DeactivateConfig(CMeterWindow* meterWindow, int configIndex, bo else if (configIndex == -1 && meterWindow) { // Deactivate the config by using the meter window's config name - const std::wstring skinConfig = meterWindow->GetSkinName(); + const WCHAR* skinConfig = meterWindow->GetSkinName().c_str(); for (size_t i = 0, isize = m_ConfigStrings.size(); i < isize; ++i) { - if (_wcsicmp(skinConfig.c_str(), m_ConfigStrings[i].config.c_str()) == 0) + if (_wcsicmp(skinConfig, m_ConfigStrings[i].config.c_str()) == 0) { m_ConfigStrings[i].active = 0; break; @@ -1356,10 +1356,11 @@ bool CRainmeter::DeleteMeterWindow(CMeterWindow* meterWindow, bool bLater) CMeterWindow* CRainmeter::GetMeterWindow(const std::wstring& config) { + const WCHAR* configName = config.c_str(); std::map::const_iterator iter = m_Meters.begin(); for (; iter != m_Meters.end(); ++iter) { - if (_wcsicmp((*iter).first.c_str(), config.c_str()) == 0) + if (_wcsicmp((*iter).first.c_str(), configName) == 0) { return (*iter).second; } @@ -1397,15 +1398,17 @@ CMeterWindow* CRainmeter::GetMeterWindowByINI(const std::wstring& ini_searching) std::pair CRainmeter::GetMeterWindowIndex(const std::wstring& config, const std::wstring& iniFile) { + const WCHAR* configName = config.c_str(); std::pair indexes; for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i) { - if (_wcsicmp(m_ConfigStrings[i].config.c_str(), config.c_str()) == 0) + if (_wcsicmp(m_ConfigStrings[i].config.c_str(), configName) == 0) { + const WCHAR* iniFileName = iniFile.c_str(); for (int j = 0, jsize = (int)m_ConfigStrings[i].iniFiles.size(); j < jsize; ++j) { - if (_wcsicmp(m_ConfigStrings[i].iniFiles[j].c_str(), iniFile.c_str()) == 0) + if (_wcsicmp(m_ConfigStrings[i].iniFiles[j].c_str(), iniFileName) == 0) { indexes = std::make_pair(i, j); return indexes; @@ -2200,7 +2203,7 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile) m_DisableVersionCheck = 0!=parser.ReadInt(L"Rainmeter", L"DisableVersionCheck", 0); - std::wstring area = parser.ReadString(L"Rainmeter", L"DesktopWorkArea", L""); + const std::wstring& area = parser.ReadString(L"Rainmeter", L"DesktopWorkArea", L""); if (!area.empty()) { m_DesktopWorkAreas[0] = parser.ParseRECT(area.c_str()); @@ -2210,7 +2213,7 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile) for (UINT i = 1; i <= CSystem::GetMonitorCount(); ++i) { _snwprintf_s(buffer, _TRUNCATE, L"DesktopWorkArea@%i", i); - area = parser.ReadString(L"Rainmeter", buffer, L""); + const std::wstring& area = parser.ReadString(L"Rainmeter", buffer, L""); if (!area.empty()) { m_DesktopWorkAreas[i] = parser.ParseRECT(area.c_str()); @@ -2224,7 +2227,7 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile) for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i) { - int active = parser.ReadInt(m_ConfigStrings[i].config.c_str(), L"Active", 0); + int active = parser.ReadInt(m_ConfigStrings[i].config.c_str(), L"Active", 0); // Make sure there is a ini file available if (active > 0 && active <= (int)m_ConfigStrings[i].iniFiles.size()) @@ -2363,6 +2366,7 @@ void CRainmeter::LoadTheme(const std::wstring& name) PreserveSetting(backup, L"Logging"); PreserveSetting(backup, L"DisableVersionCheck"); PreserveSetting(backup, L"Language"); + PreserveSetting(backup, L"NormalStayDesktop"); PreserveSetting(backup, L"TrayExecuteL", false); PreserveSetting(backup, L"TrayExecuteM", false); PreserveSetting(backup, L"TrayExecuteR", false); @@ -2923,10 +2927,11 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con // Add the variants menu if (variantsMenu) { + const WCHAR* skin = skinName.c_str(); for (int i = 0, isize = (int)m_ConfigStrings.size(); i < isize; ++i) { const CONFIG& config = m_ConfigStrings[i]; - if (_wcsicmp(config.config.c_str(), skinName.c_str()) == 0) + if (_wcsicmp(config.config.c_str(), skin) == 0) { for (int j = 0, jsize = (int)config.iniFiles.size(); j < jsize; ++j) { diff --git a/Library/System.h b/Library/System.h index 087bf53c..ad6fafec 100644 --- a/Library/System.h +++ b/Library/System.h @@ -91,7 +91,6 @@ public: private: static void CALLBACK MyWinEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime); static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - static BOOL DwmIsCompositionEnabled(); static void SetMultiMonitorInfo(); static void ClearMultiMonitorInfo() { c_Monitors.monitors.clear(); } diff --git a/Library/TintedImage.cpp b/Library/TintedImage.cpp index 2586f154..8af30acd 100644 --- a/Library/TintedImage.cpp +++ b/Library/TintedImage.cpp @@ -585,7 +585,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) m_Crop.X = m_Crop.Y = m_Crop.Width = m_Crop.Height = -1; m_CropMode = CROPMODE_TL; - std::wstring crop = parser.ReadString(section, m_ConfigArray[ConfigIndexImageCrop], L""); + const std::wstring& crop = parser.ReadString(section, m_ConfigArray[ConfigIndexImageCrop], L""); if (!crop.empty()) { if (wcschr(crop.c_str(), L',')) @@ -712,20 +712,20 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section) m_NeedsTinting = (oldGreyScale != m_GreyScale || !CompareColorMatrix(&oldColorMatrix, m_ColorMatrix)); - std::wstring flip = parser.ReadString(section, m_ConfigArray[ConfigIndexImageFlip], L"NONE"); - if (_wcsicmp(flip.c_str(), L"NONE") == 0) + const WCHAR* flip = parser.ReadString(section, m_ConfigArray[ConfigIndexImageFlip], L"NONE").c_str(); + if (_wcsicmp(flip, L"NONE") == 0) { m_Flip = RotateNoneFlipNone; } - else if (_wcsicmp(flip.c_str(), L"HORIZONTAL") == 0) + else if (_wcsicmp(flip, L"HORIZONTAL") == 0) { m_Flip = RotateNoneFlipX; } - else if (_wcsicmp(flip.c_str(), L"VERTICAL") == 0) + else if (_wcsicmp(flip, L"VERTICAL") == 0) { m_Flip = RotateNoneFlipY; } - else if (_wcsicmp(flip.c_str(), L"BOTH") == 0) + else if (_wcsicmp(flip, L"BOTH") == 0) { m_Flip = RotateNoneFlipXY; } diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index ae904f4e..25c0fd61 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -292,7 +292,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser) m_TrayIconEnabled = 0!=parser.ReadInt(L"Rainmeter", L"TrayIcon", 1); if (m_TrayIconEnabled) { - std::wstring measureName = parser.ReadString(L"TrayMeasure", L"Measure", L""); + const std::wstring& measureName = parser.ReadString(L"TrayMeasure", L"Measure", L""); if (!measureName.empty()) { @@ -317,18 +317,18 @@ void CTrayWindow::ReadConfig(CConfigParser& parser) Rainmeter->SetCurrentParser(oldParser); } - std::wstring type = parser.ReadString(L"TrayMeasure", L"TrayMeter", m_Measure ? L"HISTOGRAM" : L"NONE"); - if (_wcsicmp(type.c_str(), L"NONE") == 0) + const WCHAR* type = parser.ReadString(L"TrayMeasure", L"TrayMeter", m_Measure ? L"HISTOGRAM" : L"NONE").c_str(); + if (_wcsicmp(type, L"NONE") == 0) { // Use main icon } - else if (_wcsicmp(type.c_str(), L"HISTOGRAM") == 0) + else if (_wcsicmp(type, L"HISTOGRAM") == 0) { m_MeterType = TRAY_METER_TYPE_HISTOGRAM; m_TrayColor1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color(0, 100, 0)); m_TrayColor2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color(0, 255, 0)); } - else if (_wcsicmp(type.c_str(), L"BITMAP") == 0) + else if (_wcsicmp(type, L"BITMAP") == 0) { m_MeterType = TRAY_METER_TYPE_BITMAP; @@ -338,26 +338,22 @@ void CTrayWindow::ReadConfig(CConfigParser& parser) if (!imageName.empty()) { imageName.insert(0, Rainmeter->GetSkinPath()); - if (imageName.size() > 3) + if (_wcsicmp(imageName.c_str() + (imageName.size() - 4), L".ico") == 0) { - std::wstring extension = imageName.substr(imageName.size() - 3); - if (extension == L"ico" || extension == L"ICO") + int count = 1; + HICON hIcon = NULL; + + // Load the icons + do { - int count = 1; - HICON hIcon = NULL; + WCHAR buffer[MAX_PATH]; + _snwprintf_s(buffer, _TRUNCATE, imageName.c_str(), count++); - // Load the icons - do - { - WCHAR buffer[MAX_PATH]; - _snwprintf_s(buffer, _TRUNCATE, imageName.c_str(), count++); - - hIcon = (HICON)LoadImage(NULL, buffer, IMAGE_ICON, TRAYICON_SIZE, TRAYICON_SIZE, LR_LOADFROMFILE); - if (hIcon) m_TrayIcons.push_back(hIcon); - if (imageName == buffer) break; - } - while(hIcon != NULL); + hIcon = (HICON)LoadImage(NULL, buffer, IMAGE_ICON, TRAYICON_SIZE, TRAYICON_SIZE, LR_LOADFROMFILE); + if (hIcon) m_TrayIcons.push_back(hIcon); + if (imageName == buffer) break; } + while(hIcon != NULL); } if (m_TrayIcons.empty()) @@ -377,7 +373,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser) } else { - LogWithArgs(LOG_ERROR, L"No such TrayMeter: %s", type.c_str()); + LogWithArgs(LOG_ERROR, L"No such TrayMeter: %s", type); } AddTrayIcon();