tag editor: fix leading separator issue (#32)

This commit is contained in:
jgr
2015-03-24 02:39:59 +10:00
committed by Andrzej Rybczak
parent b63d646e48
commit bb4c0a9d4c
2 changed files with 8 additions and 2 deletions

1
NEWS
View File

@@ -1,6 +1,7 @@
ncmpcpp-0.6.4 (????-??-??)
* Fix title of a pop-up which shows during adding selected items to the current playlist.
* Correctly deal with leading separator while parsing filenames in tag editor.
ncmpcpp-0.6.3 (2015-03-02)

View File

@@ -1148,7 +1148,12 @@ std::string ParseFilename(MPD::MutableSong &s, std::string mask, bool preview)
std::vector< std::pair<char, std::string> > tags;
std::string file = s.getName().substr(0, s.getName().rfind("."));
for (size_t i = mask.find("%"); i != std::string::npos; i = mask.find("%"))
size_t i = mask.find("%");
if (!mask.substr(0, i).empty())
file = file.substr(i);
for (; i != std::string::npos; i = mask.find("%"))
{
tags.push_back(std::make_pair(mask.at(i+1), ""));
mask = mask.substr(i+2);
@@ -1156,7 +1161,7 @@ std::string ParseFilename(MPD::MutableSong &s, std::string mask, bool preview)
if (!mask.empty())
separators.push_back(mask.substr(0, i));
}
size_t i = 0;
i = 0;
for (auto it = separators.begin(); it != separators.end(); ++it, ++i)
{
size_t j = file.find(*it);