amixer: support infinite line length for --stdin option
Closes: https://github.com/alsa-project/alsa-utils/pull/321 Signed-off-by: Mikhail Ivashinenko <miuivashinenko@salutedevices.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
e73462beaf
commit
aae3f6d787
1 changed files with 7 additions and 4 deletions
|
|
@ -1760,13 +1760,14 @@ static int split_line(char *buf, char **token, int max_token)
|
|||
static int exec_stdin(void)
|
||||
{
|
||||
int narg;
|
||||
char buf[256], *args[MAX_ARGS];
|
||||
char *buf = NULL, *args[MAX_ARGS];
|
||||
size_t size = 0;
|
||||
int err = 0;
|
||||
|
||||
/* quiet = 1; */
|
||||
ignore_error = 1;
|
||||
|
||||
while (fgets(buf, sizeof(buf), stdin)) {
|
||||
while (getline(&buf, &size, stdin) > 0) {
|
||||
narg = split_line(buf, args, MAX_ARGS);
|
||||
if (narg > 0) {
|
||||
if (!strcmp(args[0], "sset") || !strcmp(args[0], "set"))
|
||||
|
|
@ -1774,10 +1775,12 @@ static int exec_stdin(void)
|
|||
else if (!strcmp(args[0], "cset"))
|
||||
err = cset(narg - 1, args + 1, 0, 1);
|
||||
if (err < 0)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
free(buf);
|
||||
return err < 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue