- Now able to use single quote as quotes in Substitute. Reverted r510, r511.

- [WebParser] Updated PCRE library 6.4 to 8.10.
This commit is contained in:
spx 2010-08-18 07:28:55 +00:00
parent 67e5d4142d
commit 46b19fbd73
3 changed files with 178 additions and 166 deletions

View File

@ -153,6 +153,13 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
std::wstring subs; std::wstring subs;
subs = parser.ReadString(section, L"Substitute", L""); subs = parser.ReadString(section, L"Substitute", L"");
if (!subs.empty() &&
(subs[0] != L'\"' || subs[subs.length() - 1] != L'\'') &&
(subs[0] != L'\'' || subs[subs.length() - 1] != L'\"'))
{
// Add quotes since they are removed by the GetProfileString
subs = L"\"" + subs + L"\"";
}
if (!ParseSubstitute(subs)) if (!ParseSubstitute(subs))
{ {
DebugLog(L"Incorrect substitute string: %s", subs.c_str()); DebugLog(L"Incorrect substitute string: %s", subs.c_str());
@ -217,9 +224,6 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
{ {
if (buffer.empty()) return true; if (buffer.empty()) return true;
// Add quotes since they are removed by the GetProfileString
buffer = L"\"" + buffer + L"\"";
std::wstring word1; std::wstring word1;
std::wstring word2; std::wstring word2;
std::wstring sep; std::wstring sep;
@ -263,13 +267,15 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer)
std::wstring::size_type notwhite = buffer.find_first_not_of(L" \t\n"); std::wstring::size_type notwhite = buffer.find_first_not_of(L" \t\n");
buffer.erase(0, notwhite); buffer.erase(0, notwhite);
if (buffer[0] == L'\"') if (buffer[0] == L'\"' || buffer[0] == L'\'')
{ {
WCHAR quote = buffer[0];
end = 1; // Skip the '"' end = 1; // Skip the '"'
// Quotes around the word // Quotes around the word
while (buffer[end] != L'\"' && end < buffer.size()) ++end; while (buffer[end] != quote && end < buffer.size()) ++end;
if (buffer[end] == L'\"') if (buffer[end] == quote)
{ {
ret = buffer.substr(1, end - 1); ret = buffer.substr(1, end - 1);
buffer.erase(0, end + 1); buffer.erase(0, end + 1);
@ -299,8 +305,6 @@ std::wstring CMeasure::ExtractWord(std::wstring& buffer)
} }
} }
while ((pos = ret.find(L"#QUOT#", pos)) != std::wstring::npos) ret.replace(pos, 6, L"\"");
return ret; return ret;
} }

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,7 @@
#include <vector> #include <vector>
#include <Wininet.h> #include <Wininet.h>
#include <shlwapi.h> #include <shlwapi.h>
#include "pcre-6.4/pcre.h" #include "pcre-8.10/pcre.h"
#include "..\..\Library\Export.h" // Rainmeter's exported functions #include "..\..\Library\Export.h" // Rainmeter's exported functions
/* The exported functions */ /* The exported functions */