From: Mikhail Ivashinenko Date: Wed, 28 Jan 2026 17:53:30 +0000 (+0300) Subject: amixer: support infinite line length for --stdin option X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=aae3f6d7874c0d4304d3f2ead6f1a2b983b5fead;p=alsa-utils.git amixer: support infinite line length for --stdin option Closes: https://github.com/alsa-project/alsa-utils/pull/321 Signed-off-by: Mikhail Ivashinenko Signed-off-by: Jaroslav Kysela --- diff --git a/amixer/amixer.c b/amixer/amixer.c index 07e9819..9eb7f73 100644 --- a/amixer/amixer.c +++ b/amixer/amixer.c @@ -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; }