mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-25 06:59:57 -05:00
pipewire: utils: pw_split_walk(): skip leading runs of chars in delimiter
Previously, if the string started with any of the characters in delimiter, the first returned string would've been an empty string. This is in contrast with the fact that otherwise `pw_split_walk()` skips empty fields. E.g. "::field1::field2" with ":" as `delimiter` would have resulted in * "" * "field1" * "field2". Adjust the function to skip leading runs of characters in `delimiter` by calling `strspn()` first.
This commit is contained in:
parent
576513583b
commit
3b681f2138
1 changed files with 1 additions and 2 deletions
|
|
@ -44,13 +44,12 @@ const char *pw_split_walk(const char *str, const char *delimiter, size_t * len,
|
||||||
{
|
{
|
||||||
const char *s = *state ? *state : str;
|
const char *s = *state ? *state : str;
|
||||||
|
|
||||||
|
s += strspn(s, delimiter);
|
||||||
if (*s == '\0')
|
if (*s == '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*len = strcspn(s, delimiter);
|
*len = strcspn(s, delimiter);
|
||||||
|
|
||||||
*state = s + *len;
|
*state = s + *len;
|
||||||
*state += strspn(*state, delimiter);
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue