Skip to content

Commit 5814de0

Browse files
committed
fix parsing of OEM encoded description files
1 parent 82f2f52 commit 5814de0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

dmodel.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static void decodeBytes(const char *buf, size_t nBytes, std::wstring &result, bo
2323
}
2424

2525
static std::vector<char> convertToBytes(const std::wstring &text, bool bUtf8) {
26-
if (bUtf8)
26+
if (bUtf8)
2727
return ucs2utf(L"\xFEFF" + text);
2828
return ucs2oem(text);
2929
}
@@ -75,13 +75,16 @@ void DescrDb::load(const std::wstring &filename) {
7575
if (buf.empty())
7676
return;
7777

78+
bool bTagOemSafe = isStringOemSafe(Opt.TagMarker);
79+
7880
enum {FILENAME, QUOTE, SPACE, DESCR, TAGS} state = FILENAME;
7981
std::wstring item;
8082
ItemData data;
8183
std::wstring::const_iterator pItem = buf.begin(); //the beginning of currently parsed item
8284
std::wstring::const_iterator pMarker; //current matching character in marker
8385
for (std::wstring::const_iterator pBuf = buf.begin(); pBuf != buf.end(); ++pBuf) {
8486
wchar_t c = *pBuf;
87+
bool bMarkerChar;
8588
switch (state) {
8689
case FILENAME:
8790
switch (c) {
@@ -154,7 +157,13 @@ void DescrDb::load(const std::wstring &filename) {
154157
break;
155158
default:
156159
testMarkerChar:
157-
if (c == *pMarker) {
160+
if (m_bLoadedUtf8 || bTagOemSafe) {
161+
bMarkerChar = c == *pMarker;
162+
}
163+
else {
164+
bMarkerChar = ucs2oem(std::wstring(1, c)) == ucs2oem(std::wstring(1, *pMarker));
165+
}
166+
if (bMarkerChar) {
158167
if (++pMarker == Opt.TagMarker.end()) {
159168
data.text = std::wstring(pItem, pBuf - Opt.TagMarker.size() + 1);
160169
rtrim(data.text);

filetags.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@
317317
<ClCompile Include="folder.cpp" />
318318
<ClCompile Include="main.cpp" />
319319
<ClCompile Include="mix.cpp" />
320-
<ClCompile Include="panelnotifier.cpp" />
321320
<ClCompile Include="filetags.cpp" />
322321
<ClCompile Include="panel.cpp" />
323322
<ClCompile Include="panelitemslist.cpp" />
323+
<ClCompile Include="panelnotifier.cpp" />
324324
<ClCompile Include="tags.cpp" />
325325
<ClCompile Include="watchdir.cpp" />
326326
</ItemGroup>
@@ -331,11 +331,11 @@
331331
<ClInclude Include="folder.hpp" />
332332
<ClInclude Include="mapping.hpp" />
333333
<ClInclude Include="mix.hpp" />
334-
<ClCompile Include="panelnotifier.hpp" />
335334
<ClInclude Include="filetagslng.hpp" />
336335
<ClInclude Include="guid.hpp" />
337336
<ClInclude Include="panel.hpp" />
338337
<ClInclude Include="panelitemslist.hpp" />
338+
<ClInclude Include="panelnotifier.hpp" />
339339
<ClInclude Include="tags.hpp" />
340340
<ClInclude Include="version.hpp" />
341341
<ClInclude Include="watchdir.hpp" />

0 commit comments

Comments
 (0)