[Flac-dev] [PATCH 2/5]: Change 'flac -t' progress display
Joshua Kwan
joshk at triplehelix.org
Mon Jan 8 17:07:32 PST 2007
This patch changes how 'flac -t' progress is displayed. The way the code
currently is, it causes problems when the length of the filename is
longer than the width of the terminal.
--
Joshua Kwan
--- flac-1.1.2/src/flac/decode.c~ 2005-08-18 02:16:46.000000000 -0700
+++ flac-1.1.2/src/flac/decode.c 2005-08-18 02:14:59.000000000 -0700
@@ -1182,6 +1182,7 @@
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 */
@@ -1190,7 +1191,13 @@
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 881 bytes
Desc: Digital signature
Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20070108/32b1a0c7/attachment.pgp
More information about the Flac-dev
mailing list