Permission: use IterableSplitString

This commit is contained in:
Max Kellermann 2019-04-03 21:47:03 +02:00
parent 8f20edac9d
commit b8a8bdeaec
1 changed files with 4 additions and 13 deletions

View File

@ -22,6 +22,7 @@
#include "config/Param.hxx"
#include "config/Data.hxx"
#include "config/Option.hxx"
#include "util/IterableSplitString.hxx"
#include "util/RuntimeError.hxx"
#include "util/StringView.hxx"
@ -69,21 +70,11 @@ static unsigned parsePermissions(const char *string)
{
assert(string != nullptr);
const char *const end = string + strlen(string);
unsigned permission = 0;
while (true) {
const char *comma = std::find(string, end,
PERMISSION_SEPARATOR);
if (comma > string) {
permission |= ParsePermission({string, comma});
}
if (comma == end)
break;
string = comma + 1;
}
for (const auto i : IterableSplitString(string, PERMISSION_SEPARATOR))
if (!i.empty())
permission |= ParsePermission(i);
return permission;
}