From 1e94f1e6291f37f88829cf5d28852cc67b573b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Stegh=C3=B6fer?= Date: Thu, 8 Oct 2015 21:29:45 +0200 Subject: [PATCH] oggdec: Write to stdout instead of "-.wav" when reading from stdin and not output file name is given. In bug #263762 it was reported that the behavior of oggdec was inconsistent with its documentation: According to the man page, "oggdec" should write to stdout, when reading its input from stdin and no output file name is given. The "oggdec" executable writes to "-.wav" instead. I adjusted the behavior of "oggdec" instead of adjusting the documentation because it seems more sensible to write to stdout than to write to a file called "-.wav". The code changes themselves are simple enough to be self-explanatory. Bug-Debian: https://bugs.debian.org/263762 Forwarded: https://trac.xiph.org/ticket/1678#comment:1 --- oggdec/oggdec.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/oggdec/oggdec.c b/oggdec/oggdec.c index ae700ad..500bd9b 100644 --- a/oggdec/oggdec.c +++ b/oggdec/oggdec.c @@ -443,16 +443,21 @@ int main(int argc, char **argv) out = outfilename; } else { - char *end = strrchr(argv[i], '.'); - end = end?end:(argv[i] + strlen(argv[i]) + 1); - - out = malloc(strlen(argv[i]) + 10); - strncpy(out, argv[i], end-argv[i]); - out[end-argv[i]] = 0; - if(raw) - strcat(out, ".raw"); - else - strcat(out, ".wav"); + if(!strcmp(argv[i], "-")) { + out = NULL; + } + else { + char *end = strrchr(argv[i], '.'); + end = end?end:(argv[i] + strlen(argv[i]) + 1); + + out = malloc(strlen(argv[i]) + 10); + strncpy(out, argv[i], end-argv[i]); + out[end-argv[i]] = 0; + if(raw) + strcat(out, ".raw"); + else + strcat(out, ".wav"); + } } infile = open_input(in); @@ -472,7 +477,7 @@ int main(int argc, char **argv) return 1; } - if(!outfilename) + if(!outfilename && out) free(out); fclose(outfile); -- GitLab