From 44dd9af27659dbf44831a2fa099505219adb7ad6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 23 Jan 2017 19:34:55 +0100 Subject: [PATCH] lib/upnp/Util: pass single delimiter character to stringToTokens() --- src/db/plugins/upnp/UpnpDatabasePlugin.cxx | 4 ++-- src/lib/upnp/Util.cxx | 6 +++--- src/lib/upnp/Util.hxx | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index 45a402e0d..4dbfe30c6 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -180,7 +180,7 @@ UpnpDatabase::ReturnSong(const LightSong *_song) const const LightSong * UpnpDatabase::GetSong(const char *uri) const { - auto vpath = stringToTokens(uri, "/"); + auto vpath = stringToTokens(uri, '/'); if (vpath.size() < 2) throw DatabaseError(DatabaseErrorCode::NOT_FOUND, "No such song"); @@ -577,7 +577,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection, VisitSong visit_song, VisitPlaylist visit_playlist) const { - auto vpath = stringToTokens(selection.uri, "/"); + auto vpath = stringToTokens(selection.uri, '/'); if (vpath.empty()) { for (const auto &server : discovery->GetDirectories()) { if (visit_directory) { diff --git a/src/lib/upnp/Util.cxx b/src/lib/upnp/Util.cxx index f433af6f1..61c11719d 100644 --- a/src/lib/upnp/Util.cxx +++ b/src/lib/upnp/Util.cxx @@ -71,11 +71,11 @@ path_getfather(const std::string &s) std::list stringToTokens(const std::string &str, - const char *delims) + const char delim) { std::list 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. if (startPos == std::string::npos) @@ -83,7 +83,7 @@ stringToTokens(const std::string &str, while (startPos < str.size()) { // 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 if (pos == std::string::npos) { diff --git a/src/lib/upnp/Util.hxx b/src/lib/upnp/Util.hxx index 4123a076d..b935611ec 100644 --- a/src/lib/upnp/Util.hxx +++ b/src/lib/upnp/Util.hxx @@ -33,8 +33,7 @@ path_getfather(const std::string &s); gcc_pure std::list -stringToTokens(const std::string &str, - const char *delims = "/"); +stringToTokens(const std::string &str, char delim); template bool