diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index 6e1a148b..baa73525 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -101,28 +101,11 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me SetBuiltInVariable(L"CURRENTPATH", CRainmeter::ExtractPath(m_Filename)); SetBuiltInVariable(L"ADDONSPATH", pRainmeter->GetAddonPath()); SetBuiltInVariable(L"CRLF", L"\n"); - - if (meterWindow) - { - const std::wstring& config = meterWindow->GetSkinName(); - std::wstring path = pRainmeter->GetSkinPath(); - - std::wstring::size_type loc; - if ((loc = config.find_first_of(L'\\')) != std::wstring::npos) - { - path += config.substr(0, loc + 1); - } - else - { - path += config; - path += L"\\"; - } - SetBuiltInVariable(L"ROOTCONFIGPATH", path); - } } if (meterWindow) { SetBuiltInVariable(L"CURRENTCONFIG", meterWindow->GetSkinName()); + SetBuiltInVariable(L"ROOTCONFIGPATH", meterWindow->GetSkinRootPath()); } } @@ -604,10 +587,8 @@ const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCT std::wstring::size_type pos = (*iter).find_first_not_of(L" \t\r\n"); if (pos != std::wstring::npos) { - std::wstring::size_type lastPos = (*iter).find_last_not_of(L" \t\r\n"); - // Trim white-space - std::wstring strSection((*iter), pos, lastPos - pos + 1); + std::wstring strSection((*iter), pos, (*iter).find_last_not_of(L" \t\r\n") - pos + 1); const std::wstring& strStyle = GetValue(strSection, key, strDefault); diff --git a/Library/Group.cpp b/Library/Group.cpp index faeeceb6..3bfade87 100644 --- a/Library/Group.cpp +++ b/Library/Group.cpp @@ -66,10 +66,8 @@ std::wstring CGroup::CreateGroup(const std::wstring& str) std::wstring::size_type pos = str.find_first_not_of(L" \t\r\n"); if (pos != std::wstring::npos) { - std::wstring::size_type lastPos = str.find_last_not_of(L" \t\r\n"); - // Trim white-space - strTmp.assign(str, pos, lastPos - pos + 1); + strTmp.assign(str, pos, str.find_last_not_of(L" \t\r\n") - pos + 1); // Convert to lower std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower); diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index be006e82..c5d1709a 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -335,8 +335,9 @@ HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR sz std::wstring args; std::wstring command = szCommand; - size_t notwhite = command.find_first_not_of(L" \t\n"); + size_t notwhite = command.find_first_not_of(L" \t\r\n"); command.erase(0, notwhite); + if (command.empty()) return NULL; size_t quotePos = command.find(L"\""); if (quotePos == 0) diff --git a/Library/MeasurePlugin.cpp b/Library/MeasurePlugin.cpp index 0eaf1c58..93c30b19 100644 --- a/Library/MeasurePlugin.cpp +++ b/Library/MeasurePlugin.cpp @@ -130,7 +130,8 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section) pos = m_PluginName.rfind(L'\\'); if (pos != std::wstring::npos) { - std::wstring pluginName = Rainmeter->GetPath() + m_PluginName.substr(pos + 1); + std::wstring pluginName = Rainmeter->GetPath(); + pluginName.append(m_PluginName, pos + 1, m_PluginName.length() - (pos + 1)); err = 0; m_Plugin = CSystem::RmLoadLibrary(pluginName.c_str(), &err); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index b2fa75c4..5a792a0b 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -5072,17 +5072,41 @@ void CMeterWindow::SetWindowSizeVariables(int w, int h) */ std::wstring CMeterWindow::MakePathAbsolute(const std::wstring& path) { + std::wstring absolute; + if (path.empty() || path.find(L":\\") != std::wstring::npos || path.find(L":/") != std::wstring::npos || (path.length() >= 2 && (path[0] == L'\\' || path[0] == L'/') && (path[1] == L'\\' || path[1] == L'/'))) // UNC { - return path; // It's already absolute path (or it's empty) + absolute = path; // It's already absolute path (or it's empty) + } + else + { + absolute = m_SkinPath; + absolute += m_SkinName; + absolute += L"\\"; + absolute += path; } - std::wstring root = m_SkinPath + m_SkinName; - root += L"\\"; + return absolute; +} - return root + path; +std::wstring CMeterWindow::GetSkinRootPath() +{ + std::wstring path = m_Rainmeter->GetSkinPath(); + + std::wstring::size_type loc; + if ((loc = m_SkinName.find_first_of(L'\\')) != std::wstring::npos) + { + path.append(m_SkinName, 0, loc + 1); + } + else + { + path += m_SkinName; + path += L"\\"; + } + + return path; } @@ -5096,7 +5120,6 @@ CMeter* CMeterWindow::GetMeter(const std::wstring& meterName) return (*j); } } - return NULL; } diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 37948339..e2054b3b 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -200,6 +200,7 @@ public: const std::wstring& GetSkinAuthor() { return m_Author; } const std::wstring& GetSkinName() { return m_SkinName; } const std::wstring& GetSkinIniFile() { return m_SkinIniFile; } + std::wstring GetSkinRootPath(); std::list& GetMeasures() { return m_Measures; } std::list& GetMeters() { return m_Meters; } diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 59219a93..be2a4b04 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -3098,7 +3098,7 @@ BOOL CRainmeter::ExecuteBang(const std::wstring& bang, const std::wstring& arg, std::wstring command = arg.substr(start + 1, end - (start + 1)); // trim leading whitespace - std::wstring::size_type notwhite = command.find_first_not_of(L" \t\n"); + std::wstring::size_type notwhite = command.find_first_not_of(L" \t\r\n"); command.erase(0, notwhite); ExecuteCommand(command.c_str(), meterWindow); }