From 02f2171010accc1e9473e2a12a51d79782ee0f52 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 22 Jan 2014 20:24:55 +0100 Subject: db/upnp/Util: pass char* to csvToStrings() --- src/db/upnp/Util.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/db/upnp/Util.cxx') 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 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 >(const string &, list &); -template bool csvToStrings >(const std::string &, std::vector &); -template bool csvToStrings >(const std::string &, std::set &); +template bool csvToStrings >(const char *, std::vector &); +template bool csvToStrings >(const char *, std::set &); -- cgit v1.2.3