diff --git a/src/helpers.cpp b/src/helpers.cpp index f4f3c409..4c1df9d0 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -34,16 +34,6 @@ using Global::Mpd; using Global::wFooter; using std::string; -namespace -{ - inline void remove_the_word(string &s) - { - size_t the_pos = s.find("the "); - if (the_pos == 0 && the_pos != string::npos) - s = s.substr(4); - } -} - bool ConnectToMPD() { if (!Mpd->Connect()) @@ -175,8 +165,8 @@ bool CaseInsensitiveSorting::operator()(string a, string b) ToLower(b); if (Config.ignore_leading_the) { - remove_the_word(a); - remove_the_word(b); + RemoveTheWord(a); + RemoveTheWord(b); } return a < b; } @@ -189,8 +179,8 @@ bool CaseInsensitiveSorting::operator()(Song *sa, Song *sb) ToLower(b); if (Config.ignore_leading_the) { - remove_the_word(a); - remove_the_word(b); + RemoveTheWord(a); + RemoveTheWord(b); } return a < b; } @@ -303,6 +293,13 @@ string GetLineValue(string &line, char a, char b, bool once) return ""; } +void RemoveTheWord(string &s) +{ + size_t the_pos = s.find("the "); + if (the_pos == 0 && the_pos != string::npos) + s = s.substr(4); +} + std::string ExtractTopDirectory(const std::string &s) { size_t slash = s.rfind("/"); diff --git a/src/helpers.h b/src/helpers.h index 2f2b3976..8e3c179c 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -63,6 +63,7 @@ std::string FindSharedDir(const std::string &, const std::string &); std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0); +void RemoveTheWord(std::string &s); std::string ExtractTopDirectory(const std::string &); const Buffer &ShowTag(const std::string &); diff --git a/src/playlist.cpp b/src/playlist.cpp index 475c5446..8f5383ad 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -275,6 +275,11 @@ bool Playlist::Sorting(MPD::Song *a, MPD::Song *b) std::string sb = (b->*(*SortDialog)[i].second)(); ToLower(sa); ToLower(sb); + if (Config.ignore_leading_the) + { + RemoveTheWord(sa); + RemoveTheWord(sb); + } if (sa != sb) return sa < sb; }