mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
control: ctlparse - fix enum values in '' or ""
This comit fixes the enum value string parser
(fixes aaf3a081bf).
BugLink: https://github.com/alsa-project/alsa-ucm-conf/pull/40
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
a80606d1ab
commit
a3ca4803cb
1 changed files with 15 additions and 11 deletions
|
|
@ -282,23 +282,27 @@ static int get_ctl_enum_item_index(snd_ctl_t *handle,
|
||||||
if (items <= 0)
|
if (items <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
end = *ptr;
|
||||||
|
if (end == '\'' || end == '"')
|
||||||
|
ptr++;
|
||||||
|
else
|
||||||
|
end = '\0';
|
||||||
|
|
||||||
for (i = 0; i < items; i++) {
|
for (i = 0; i < items; i++) {
|
||||||
snd_ctl_elem_info_set_item(info, i);
|
snd_ctl_elem_info_set_item(info, i);
|
||||||
if (snd_ctl_elem_info(handle, info) < 0)
|
if (snd_ctl_elem_info(handle, info) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
name = snd_ctl_elem_info_get_item_name(info);
|
name = snd_ctl_elem_info_get_item_name(info);
|
||||||
end = *ptr;
|
|
||||||
if (end == '\'' || end == '"')
|
|
||||||
ptr++;
|
|
||||||
else
|
|
||||||
end = '\0';
|
|
||||||
len = strlen(name);
|
len = strlen(name);
|
||||||
if (strncmp(name, ptr, len) == 0) {
|
if (strncmp(name, ptr, len))
|
||||||
if (ptr[len] == end || ptr[len] == ',' || ptr[len] == '\n') {
|
continue;
|
||||||
ptr += len;
|
if (end == '\0' && (ptr[len] == '\0' || ptr[len] == ',' || ptr[len] == '\n')) {
|
||||||
*ptrp = ptr;
|
*ptrp = ptr + len;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
if (end != '\0' && ptr[len] == end) {
|
||||||
|
*ptrp = ptr + len + 1;
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue