Updated German translation. Includes suggestions by "tablerocker" <tablerocker@web...
[LameXP.git] / etc / Patches / WavPack-4.80.0-FlushPipe.diff
blobc23fad047ecf2aa3082d82257cebf25da2efdbbe
1 cli/wavpack.c | 57 ++++++++++++++++++++++++++++++++++++++-------------------
2 cli/wvunpack.c | 46 +++++++++++++++++++++++++++++++++-------------
3 2 files changed, 71 insertions(+), 32 deletions(-)
5 diff --git a/cli/wavpack.c b/cli/wavpack.c
6 index da60e0b..d81d092 100644
7 --- a/cli/wavpack.c
8 +++ b/cli/wavpack.c
9 @@ -61,6 +61,25 @@
10 #define stricmp strcasecmp
11 #endif
13 +#ifdef _MSC_VER
14 +static __forceinline void flush_stderr(void)
16 + static int stderr_mode = -1;
17 + if (stderr_mode < 0)
18 + {
19 + struct _stat stat;
20 + if (!_fstat(_fileno(stderr), &stat))
21 + {
22 + stderr_mode = stat.st_mode & _S_IFMT;
23 + }
24 + }
25 + if (stderr_mode == _S_IFIFO)
26 + {
27 + fflush(stderr); /*flush iff it's a pipe*/
28 + }
30 +#endif
32 ///////////////////////////// local variable storage //////////////////////////
34 static const char *sign_on = "\n"
35 @@ -777,11 +796,11 @@ int main (int argc, char **argv)
37 if (strcmp (WavpackGetLibraryVersionString (), PACKAGE_VERSION)) {
38 fprintf (stderr, version_warning, WavpackGetLibraryVersionString (), PACKAGE_VERSION);
39 - fflush (stderr);
40 + flush_stderr();
42 else if (!quiet_mode && !error_count) {
43 fprintf (stderr, sign_on, VERSION_OS, WavpackGetLibraryVersionString ());
44 - fflush (stderr);
45 + flush_stderr();
48 // Loop through any tag specification strings and check for file access, convert text
49 @@ -891,7 +910,7 @@ int main (int argc, char **argv)
51 if (error_count) {
52 fprintf (stderr, "\ntype 'wavpack' for short help or 'wavpack --help' for full help\n");
53 - fflush (stderr);
54 + flush_stderr();
55 return 1;
58 @@ -1189,7 +1208,7 @@ int main (int argc, char **argv)
60 if (num_files > 1 && !quiet_mode) {
61 fprintf (stderr, "\n%s:\n", matches [file_index]);
62 - fflush (stderr);
63 + flush_stderr();
66 if (filespec_ext (matches [file_index]) && !stricmp (filespec_ext (matches [file_index]), ".wv"))
67 @@ -1223,11 +1242,11 @@ int main (int argc, char **argv)
68 if (num_files > 1) {
69 if (error_count) {
70 fprintf (stderr, "\n **** warning: errors occurred in %d of %d files! ****\n", error_count, num_files);
71 - fflush (stderr);
72 + flush_stderr();
74 else if (!quiet_mode) {
75 fprintf (stderr, "\n **** %d files successfully processed ****\n", num_files);
76 - fflush (stderr);
77 + flush_stderr();
81 @@ -1278,7 +1297,7 @@ int main(int argc, char **argv)
83 if (pause_mode) {
84 fprintf (stderr, "\nPress any key to continue . . . ");
85 - fflush (stderr);
86 + flush_stderr();
87 while (!_kbhit ());
88 _getch ();
89 fprintf (stderr, "\n");
90 @@ -1507,7 +1526,7 @@ static int pack_file (char *infilename, char *outfilename, char *out2filename, c
92 if (!overwrite_all) {
93 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (outfilename));
94 - fflush (stderr);
95 + flush_stderr();
97 if (set_console_title)
98 DoSetConsoleTitle ("overwrite?");
99 @@ -1532,7 +1551,7 @@ static int pack_file (char *infilename, char *outfilename, char *out2filename, c
101 if (res == 1) {
102 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (out2filename));
103 - fflush (stderr);
104 + flush_stderr();
106 if (set_console_title)
107 DoSetConsoleTitle ("overwrite?");
108 @@ -1643,7 +1662,7 @@ static int pack_file (char *infilename, char *outfilename, char *out2filename, c
109 else
110 fprintf (stderr, "creating %s,", FN_FIT (outfilename));
112 - fflush (stderr);
113 + flush_stderr();
116 #if defined (_WIN32)
117 @@ -2396,7 +2415,7 @@ static int pack_audio (WavpackContext *wpc, FILE *infile, unsigned char *new_ord
118 #else
119 fprintf (stderr, "\n");
120 #endif
121 - fflush (stderr);
122 + flush_stderr();
123 free (sample_buffer);
124 free (input_buffer);
125 return WAVPACK_SOFT_ERROR;
126 @@ -2412,7 +2431,7 @@ static int pack_audio (WavpackContext *wpc, FILE *infile, unsigned char *new_ord
127 if (!quiet_mode) {
128 fprintf (stderr, "%s%3d%% done...",
129 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
130 - fflush (stderr);
131 + flush_stderr();
135 @@ -2506,7 +2525,7 @@ static int repack_file (char *infilename, char *outfilename, char *out2filename,
136 else
137 fprintf (stderr, "overwrite %s with lossy transcode (yes/no/all)? ", FN_FIT (outfilename));
139 - fflush (stderr);
140 + flush_stderr();
142 if (set_console_title)
143 DoSetConsoleTitle ("overwrite?");
144 @@ -2526,7 +2545,7 @@ static int repack_file (char *infilename, char *outfilename, char *out2filename,
145 if (out2filename && !overwrite_all && (wvc_file.file = fopen (out2filename, "rb")) != NULL) {
146 DoCloseHandle (wvc_file.file);
147 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (out2filename));
148 - fflush (stderr);
149 + flush_stderr();
151 if (set_console_title)
152 DoSetConsoleTitle ("overwrite?");
153 @@ -2628,7 +2647,7 @@ static int repack_file (char *infilename, char *outfilename, char *out2filename,
154 else
155 fprintf (stderr, "creating %s,", FN_FIT (outfilename));
157 - fflush (stderr);
158 + flush_stderr();
161 #if defined (_WIN32)
162 @@ -3076,7 +3095,7 @@ static int repack_audio (WavpackContext *outfile, WavpackContext *infile, unsign
163 #else
164 fprintf (stderr, "\n");
165 #endif
166 - fflush (stderr);
167 + flush_stderr();
168 free (sample_buffer);
169 return WAVPACK_SOFT_ERROR;
171 @@ -3091,7 +3110,7 @@ static int repack_audio (WavpackContext *outfile, WavpackContext *infile, unsign
172 if (!quiet_mode) {
173 fprintf (stderr, "%s%3d%% done...",
174 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
175 - fflush (stderr);
176 + flush_stderr();
180 @@ -3194,7 +3213,7 @@ static int verify_audio (char *infilename, unsigned char *md5_digest_source)
181 #else
182 fprintf (stderr, "\n");
183 #endif
184 - fflush (stderr);
185 + flush_stderr();
186 result = WAVPACK_SOFT_ERROR;
187 break;
189 @@ -3208,7 +3227,7 @@ static int verify_audio (char *infilename, unsigned char *md5_digest_source)
190 if (!quiet_mode) {
191 fprintf (stderr, "%s%3d%% done...",
192 "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
193 - fflush (stderr);
194 + flush_stderr();
198 diff --git a/cli/wvunpack.c b/cli/wvunpack.c
199 index 05c9fda..07dbd99 100644
200 --- a/cli/wvunpack.c
201 +++ b/cli/wvunpack.c
202 @@ -58,6 +58,25 @@
203 #define strdup(x) _strdup(x)
204 #endif
206 +#ifdef _MSC_VER
207 +static __forceinline void flush_stderr(void)
209 + static int stderr_mode = -1;
210 + if (stderr_mode < 0)
212 + struct _stat stat;
213 + if (!_fstat(_fileno(stderr), &stat))
215 + stderr_mode = stat.st_mode & _S_IFMT;
218 + if (stderr_mode == _S_IFIFO)
220 + fflush(stderr); /*flush iff it's a pipe*/
223 +#endif
225 ///////////////////////////// local variable storage //////////////////////////
227 static const char *sign_on = "\n"
228 @@ -460,11 +479,11 @@ int main(int argc, char **argv)
230 if (strcmp (WavpackGetLibraryVersionString (), PACKAGE_VERSION)) {
231 fprintf (stderr, version_warning, WavpackGetLibraryVersionString (), PACKAGE_VERSION);
232 - fflush (stderr);
233 + flush_stderr();
235 else if (!quiet_mode && !error_count) {
236 fprintf (stderr, sign_on, VERSION_OS, WavpackGetLibraryVersionString ());
237 - fflush (stderr);
238 + flush_stderr();
241 if (!num_files) {
242 @@ -677,7 +696,7 @@ int main(int argc, char **argv)
244 if (num_files > 1 && !quiet_mode) {
245 fprintf (stderr, "\n%s:\n", matches [file_index]);
246 - fflush (stderr);
247 + flush_stderr();
250 result = unpack_file (matches [file_index], verify_only ? NULL : outfilename);
251 @@ -703,11 +722,11 @@ int main(int argc, char **argv)
252 if (num_files > 1) {
253 if (error_count) {
254 fprintf (stderr, "\n **** warning: errors occurred in %d of %d files! ****\n", error_count, num_files);
255 - fflush (stderr);
256 + flush_stderr();
258 else if (!quiet_mode) {
259 fprintf (stderr, "\n **** %d files successfully processed ****\n", num_files);
260 - fflush (stderr);
261 + flush_stderr();
265 @@ -758,10 +777,11 @@ int main(int argc, char **argv)
267 if (pause_mode) {
268 fprintf (stderr, "\nPress any key to continue . . . ");
269 - fflush (stderr);
270 + flush_stderr();
271 while (!_kbhit ());
272 _getch ();
273 fprintf (stderr, "\n");
274 + flush_stderr();
277 return ret;
278 @@ -845,7 +865,7 @@ static FILE *open_output_file (char *filename, char **tempfilename)
280 if (!overwrite_all) {
281 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (filename));
282 - fflush (stderr);
283 + flush_stderr();
285 if (set_console_title)
286 DoSetConsoleTitle ("overwrite?");
287 @@ -1060,12 +1080,12 @@ static int unpack_file (char *infilename, char *outfilename)
288 if (!quiet_mode) {
289 fprintf (stderr, "unpacking %s%s to stdout,", *infilename == '-' ?
290 "stdin" : FN_FIT (infilename), wvc_mode ? " (+.wvc)" : "");
291 - fflush (stderr);
292 + flush_stderr();
295 else if (!quiet_mode) {
296 fprintf (stderr, "restoring %s,", FN_FIT (outfilename));
297 - fflush (stderr);
298 + flush_stderr();
301 if (outbuf_k)
302 @@ -1087,7 +1107,7 @@ static int unpack_file (char *infilename, char *outfilename)
303 if (!quiet_mode) {
304 fprintf (stderr, "verifying %s%s,", *infilename == '-' ? "stdin" :
305 FN_FIT (infilename), wvc_mode ? " (+.wvc)" : "");
306 - fflush (stderr);
307 + flush_stderr();
311 @@ -1175,7 +1195,7 @@ static int unpack_file (char *infilename, char *outfilename)
312 #else
313 fprintf (stderr, "\n");
314 #endif
315 - fflush (stderr);
316 + flush_stderr();
317 DoTruncateFile (outfile);
318 result = WAVPACK_SOFT_ERROR;
319 break;
320 @@ -1192,7 +1212,7 @@ static int unpack_file (char *infilename, char *outfilename)
321 if (!quiet_mode) {
322 fprintf (stderr, "%s%3d%% done...",
323 nobs ? " " : "\b\b\b\b\b\b\b\b\b\b\b\b", (int) progress);
324 - fflush (stderr);
325 + flush_stderr();
329 @@ -1474,7 +1494,7 @@ static int do_tag_extractions (WavpackContext *wpc, char *outfilename)
330 if (!overwrite_all && (outfile = fopen (full_filename, "r")) != NULL) {
331 DoCloseHandle (outfile);
332 fprintf (stderr, "overwrite %s (yes/no/all)? ", FN_FIT (full_filename));
333 - fflush (stderr);
334 + flush_stderr();
336 if (set_console_title)
337 DoSetConsoleTitle ("overwrite?");