]> git.tue.mpg.de Git - paraslash.git/commitdiff
Fix number of whitespaces in duration status item.
authorAndre Noll <maan@systemlinux.org>
Thu, 1 Nov 2007 18:20:40 +0000 (19:20 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 1 Nov 2007 18:20:40 +0000 (19:20 +0100)
aft.c

diff --git a/aft.c b/aft.c
index 62db6e7b42bf663af95df97e6764c5ee8891fffc..8ac8538f7f74c37cdff2b42a827e52af28aa651e 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -787,15 +787,21 @@ static short unsigned get_duration_width(int seconds)
        return width + 6;
 }
 
-static void get_duration_buf(int seconds, char *buf, short unsigned max_width)
+static void get_duration_buf(int seconds, char *buf, struct ls_options *opts)
 {
        unsigned hours = seconds / 3600, mins = (seconds % 3600) / 60;
+       short unsigned max_width;
 
-       if (!hours) /* m:ss or mm:ss */
+       if (!hours) { /* m:ss or mm:ss */
+               max_width = opts->mode == LS_MODE_LONG?
+                       opts->widths.duration_width : 4;
                sprintf(buf, "%*u:%02u", max_width - 3, mins, seconds % 60);
-       else /* more than one hour => h:mm:ss, hh:mm:ss, hhh:mm:ss, ... */
+       } else { /* more than one hour => h:mm:ss, hh:mm:ss, hhh:mm:ss, ... */
+               max_width = opts->mode == LS_MODE_LONG?
+                       opts->widths.duration_width : 7;
                sprintf(buf, "%*u:%02u:%02u", max_width - 6, hours, mins,
                        seconds % 60);
+       }
 }
 
 static char *make_attribute_lines(const char *att_bitmap, struct afs_info *afsi)
@@ -852,7 +858,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts,
                sizeof(last_played_time), current_time, opts->mode);
        if (ret < 0)
                return ret;
-       get_duration_buf(afhi->seconds_total, duration_buf, w->duration_width);
+       get_duration_buf(afhi->seconds_total, duration_buf, opts);
        if (have_score) {
                if (opts->mode == LS_MODE_LONG)
                        sprintf(score_buf, "%*li ", w->score_width, d->score);