aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-19 16:43:35 +0200
committerMax Kellermann <max@duempel.org>2013-10-19 16:47:56 +0200
commit9acc1e1e97ff75e681ef5527f512e57917c617f3 (patch)
tree627e40fcebd7b48963e3e18d55562632b6fed903
parentdaa47546c78a535e1fd0cc6dbf97841f74c7acde (diff)
downloadmpd-9acc1e1e97ff75e681ef5527f512e57917c617f3.tar.gz
mpd-9acc1e1e97ff75e681ef5527f512e57917c617f3.tar.xz
mpd-9acc1e1e97ff75e681ef5527f512e57917c617f3.zip
Permission: use std::find instead of g_strsplit()
-rw-r--r--src/Permission.cxx27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/Permission.cxx b/src/Permission.cxx
index a703a9465..a35c80e94 100644
--- a/src/Permission.cxx
+++ b/src/Permission.cxx
@@ -24,16 +24,15 @@
#include "ConfigOption.hxx"
#include "system/FatalError.hxx"
+#include <algorithm>
#include <map>
#include <string>
-#include <glib.h>
-
#include <assert.h>
#include <string.h>
static constexpr char PERMISSION_PASSWORD_CHAR = '@';
-#define PERMISSION_SEPERATOR ","
+static constexpr char PERMISSION_SEPARATOR = ',';
static constexpr struct {
const char *name;
@@ -65,17 +64,23 @@ static unsigned parsePermissions(const char *string)
{
assert(string != nullptr);
- unsigned permission = 0;
- gchar **tokens;
+ const char *const end = string + strlen(string);
- tokens = g_strsplit(string, PERMISSION_SEPERATOR, 0);
- for (unsigned i = 0; tokens[i] != NULL; ++i) {
- char *temp = tokens[i];
- permission |= ParsePermission(temp);
+ unsigned permission = 0;
+ while (true) {
+ const char *comma = std::find(string, end,
+ PERMISSION_SEPARATOR);
+ if (comma > string) {
+ const std::string name(string, comma);
+ permission |= ParsePermission(name.c_str());
+ }
+
+ if (comma == end)
+ break;
+
+ string = comma + 1;
}
- g_strfreev(tokens);
-
return permission;
}