Commit 44dd9af2 authored by Max Kellermann's avatar Max Kellermann

lib/upnp/Util: pass single delimiter character to stringToTokens()

parent d3013d4f
...@@ -180,7 +180,7 @@ UpnpDatabase::ReturnSong(const LightSong *_song) const ...@@ -180,7 +180,7 @@ UpnpDatabase::ReturnSong(const LightSong *_song) const
const LightSong * const LightSong *
UpnpDatabase::GetSong(const char *uri) const UpnpDatabase::GetSong(const char *uri) const
{ {
auto vpath = stringToTokens(uri, "/"); auto vpath = stringToTokens(uri, '/');
if (vpath.size() < 2) if (vpath.size() < 2)
throw DatabaseError(DatabaseErrorCode::NOT_FOUND, throw DatabaseError(DatabaseErrorCode::NOT_FOUND,
"No such song"); "No such song");
...@@ -577,7 +577,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection, ...@@ -577,7 +577,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
VisitSong visit_song, VisitSong visit_song,
VisitPlaylist visit_playlist) const VisitPlaylist visit_playlist) const
{ {
auto vpath = stringToTokens(selection.uri, "/"); auto vpath = stringToTokens(selection.uri, '/');
if (vpath.empty()) { if (vpath.empty()) {
for (const auto &server : discovery->GetDirectories()) { for (const auto &server : discovery->GetDirectories()) {
if (visit_directory) { if (visit_directory) {
......
...@@ -71,11 +71,11 @@ path_getfather(const std::string &s) ...@@ -71,11 +71,11 @@ path_getfather(const std::string &s)
std::list<std::string> std::list<std::string>
stringToTokens(const std::string &str, stringToTokens(const std::string &str,
const char *delims) const char delim)
{ {
std::list<std::string> tokens; std::list<std::string> tokens;
std::string::size_type startPos = str.find_first_not_of(delims, 0); std::string::size_type startPos = str.find_first_not_of(delim, 0);
// Skip initial delims, return empty if this eats all. // Skip initial delims, return empty if this eats all.
if (startPos == std::string::npos) if (startPos == std::string::npos)
...@@ -83,7 +83,7 @@ stringToTokens(const std::string &str, ...@@ -83,7 +83,7 @@ stringToTokens(const std::string &str,
while (startPos < str.size()) { while (startPos < str.size()) {
// Find next delimiter or end of string (end of token) // Find next delimiter or end of string (end of token)
auto pos = str.find_first_of(delims, startPos); auto pos = str.find_first_of(delim, startPos);
// Add token to the vector and adjust start // Add token to the vector and adjust start
if (pos == std::string::npos) { if (pos == std::string::npos) {
......
...@@ -33,8 +33,7 @@ path_getfather(const std::string &s); ...@@ -33,8 +33,7 @@ path_getfather(const std::string &s);
gcc_pure gcc_pure
std::list<std::string> std::list<std::string>
stringToTokens(const std::string &str, stringToTokens(const std::string &str, char delim);
const char *delims = "/");
template <class T> template <class T>
bool bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment