mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pw-cli: fix command parsing after pw_split changes
Don't assume anything about the way the split function maintain the state.
This commit is contained in:
parent
0792c690c2
commit
9a90030596
1 changed files with 10 additions and 9 deletions
|
|
@ -118,19 +118,20 @@ struct command {
|
||||||
static int pw_split_ip(char *str, const char *delimiter, int max_tokens, char *tokens[])
|
static int pw_split_ip(char *str, const char *delimiter, int max_tokens, char *tokens[])
|
||||||
{
|
{
|
||||||
const char *state = NULL;
|
const char *state = NULL;
|
||||||
char *s;
|
char *s, *t;
|
||||||
size_t len;
|
size_t len, l2;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
s = (char *)pw_split_walk(str, delimiter, &len, &state);
|
s = (char *)pw_split_walk(str, delimiter, &len, &state);
|
||||||
while (s && n + 1 < max_tokens) {
|
while (s && n + 1 < max_tokens) {
|
||||||
|
t = (char*)pw_split_walk(str, delimiter, &l2, &state);
|
||||||
s[len] = '\0';
|
s[len] = '\0';
|
||||||
tokens[n++] = s;
|
tokens[n++] = s;
|
||||||
s = (char*)pw_split_walk(str, delimiter, &len, &state);
|
s = t;
|
||||||
|
len = l2;
|
||||||
}
|
}
|
||||||
if (s) {
|
if (s)
|
||||||
tokens[n++] = s;
|
tokens[n++] = s;
|
||||||
}
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue