aboutsummaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-22 20:24:55 +0100
committerMax Kellermann <max@duempel.org>2014-01-22 20:24:55 +0100
commit02f2171010accc1e9473e2a12a51d79782ee0f52 (patch)
treeb35f530de3bc5674721c4e30f2e39500aa2d3f16 /src/db
parenta5e7d0a90fc13ee4b81128483931ccc3bf65d84c (diff)
downloadmpd-02f2171010accc1e9473e2a12a51d79782ee0f52.tar.gz
mpd-02f2171010accc1e9473e2a12a51d79782ee0f52.tar.xz
mpd-02f2171010accc1e9473e2a12a51d79782ee0f52.zip
db/upnp/Util: pass char* to csvToStrings()
Diffstat (limited to 'src/db')
-rw-r--r--src/db/upnp/ContentDirectoryService.cxx2
-rw-r--r--src/db/upnp/Util.cxx15
-rw-r--r--src/db/upnp/Util.hxx3
3 files changed, 12 insertions, 8 deletions
diff --git a/src/db/upnp/ContentDirectoryService.cxx b/src/db/upnp/ContentDirectoryService.cxx
index d49a6b6fd..b666716f7 100644
--- a/src/db/upnp/ContentDirectoryService.cxx
+++ b/src/db/upnp/ContentDirectoryService.cxx
@@ -249,7 +249,7 @@ ContentDirectoryService::getSearchCapabilities(UpnpClient_Handle hdl,
if (!tbuf.compare("*")) {
result.insert(result.end(), "*");
} else if (!tbuf.empty()) {
- if (!csvToStrings(tbuf, result)) {
+ if (!csvToStrings(tbuf.c_str(), result)) {
error.Set(upnp_domain, "Bad response");
return false;
}
diff --git a/src/db/upnp/Util.cxx b/src/db/upnp/Util.cxx
index ddc54bbe0..df731f94d 100644
--- a/src/db/upnp/Util.cxx
+++ b/src/db/upnp/Util.cxx
@@ -139,14 +139,17 @@ stringToTokens(const std::string &str,
template <class T>
bool
-csvToStrings(const std::string &s, T &tokens)
+csvToStrings(const char *s, T &tokens)
{
std::string current;
tokens.clear();
enum states {TOKEN, ESCAPE};
states state = TOKEN;
- for (unsigned int i = 0; i < s.length(); i++) {
- switch (s[i]) {
+
+ while (*s != 0) {
+ const char ch = *s++;
+
+ switch (ch) {
case ',':
switch(state) {
case TOKEN:
@@ -179,7 +182,7 @@ csvToStrings(const std::string &s, T &tokens)
case TOKEN:
break;
}
- current += s[i];
+ current += ch;
}
}
switch(state) {
@@ -193,5 +196,5 @@ csvToStrings(const std::string &s, T &tokens)
}
//template bool csvToStrings<list<string> >(const string &, list<string> &);
-template bool csvToStrings<std::vector<std::string> >(const std::string &, std::vector<std::string> &);
-template bool csvToStrings<std::set<std::string> >(const std::string &, std::set<std::string> &);
+template bool csvToStrings<std::vector<std::string> >(const char *, std::vector<std::string> &);
+template bool csvToStrings<std::set<std::string> >(const char *, std::set<std::string> &);
diff --git a/src/db/upnp/Util.hxx b/src/db/upnp/Util.hxx
index 005dd3360..58e382faa 100644
--- a/src/db/upnp/Util.hxx
+++ b/src/db/upnp/Util.hxx
@@ -40,6 +40,7 @@ stringToTokens(const std::string &str,
const char *delims = "/", bool skipinit = true);
template <class T>
-bool csvToStrings(const std::string& s, T &tokens);
+bool
+csvToStrings(const char *s, T &tokens);
#endif /* _UPNPP_H_X_INCLUDED_ */