Package: vorbis-tools / 1.4.0-11

0017-oggdec-Write-to-stdout-instead-of-.wav-when-reading-.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From: =?utf-8?q?Martin_Stegh=C3=B6fer?= <martin@steghoefer.eu>
Date: Thu, 8 Oct 2015 21:29:45 +0200
Subject: 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 3f2ae7b..84047de 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);
@@ -469,7 +474,7 @@ int main(int argc, char **argv)
                 return 1;
             }
 
-            if(!outfilename)
+            if(!outfilename && out)
                 free(out);
 
             fclose(outfile);