Change order of flac_LDADD libs so it works with mingw.
[platform/upstream/flac.git] / src / flac / decode.c
index 958e3d9..4aa70d3 100644 (file)
@@ -1,5 +1,5 @@
 /* flac - Command-line FLAC encoder/decoder
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008  Josh Coalson
+ * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
 #  include <config.h>
 #endif
 
-#if defined _WIN32 && !defined __CYGWIN__
-/* where MSVC puts unlink() */
-# include <io.h>
-#else
-# include <unistd.h>
-#endif
-#if defined _MSC_VER || defined __MINGW32__
-#include <sys/types.h> /* for off_t */
-#if _MSC_VER <= 1600 /* @@@ [2G limit] */
-#define fseeko fseek
-#define ftello ftell
-#endif
-#endif
 #include <errno.h>
 #include <math.h> /* for floor() */
 #include <stdio.h> /* for FILE etc. */
@@ -40,6 +27,7 @@
 #include "FLAC/all.h"
 #include "share/grabbag.h"
 #include "share/replaygain_synthesis.h"
+#include "share/compat.h"
 #include "decode.h"
 
 typedef struct {
@@ -1426,6 +1414,7 @@ void print_error_with_state(const DecoderSession *d, const char *message)
 
 void print_stats(const DecoderSession *decoder_session)
 {
+       static int count = 0;
        if(flac__utils_verbosity_ >= 2) {
 #if defined _MSC_VER || defined __MINGW32__
                /* with MSVC you have to spoon feed it the casting */
@@ -1434,7 +1423,13 @@ void print_stats(const DecoderSession *decoder_session)
                const double progress = (double)decoder_session->samples_processed / (double)decoder_session->total_samples * 100.0;
 #endif
                if(decoder_session->total_samples > 0) {
-                       fprintf(stderr, "\r%s: %s%u%% complete",
+                       while (count > 0 && count--)
+                               fprintf(stderr, "\b");
+
+                       if ((unsigned)floor(progress + 0.5) == 100)
+                               return;
+
+                       count = fprintf(stderr, "%s: %s%u%% complete",
                                decoder_session->inbasefilename,
                                decoder_session->test_only? "testing, " : decoder_session->analysis_mode? "analyzing, " : "",
                                (unsigned)floor(progress + 0.5)