]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Be prepared to print spaces at the end of a statistics line in case
authorSimon Tatham <anakin@pobox.com>
Sat, 19 May 2001 13:41:18 +0000 (13:41 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 19 May 2001 13:41:18 +0000 (13:41 +0000)
the previously printed line was longer. Avoids multiple trailing
percents.

[originally from svn r1135]

scp.c

diff --git a/scp.c b/scp.c
index dcf80b2fc0bfe007823c079534464db110acd3c7..3e6fcf21b0d7d47ef65e54b4710071d3832b44da 100644 (file)
--- a/scp.c
+++ b/scp.c
@@ -53,6 +53,7 @@ static int preserve = 0;
 static int targetshouldbedirectory = 0;
 static int statistics = 1;
 static int portnumber = 0;
+static int prev_stats_len = 0;
 static char *password = NULL;
 static int errs = 0;
 /* GUI Adaptation - Sept 2000 */
@@ -566,6 +567,7 @@ static void print_stats(char *name, unsigned long size, unsigned long done,
     unsigned long eta;
     char etastr[10];
     int pct;
+    int len;
 
     /* GUI Adaptation - Sept 2000 */
     if (gui_mode)
@@ -586,8 +588,11 @@ static void print_stats(char *name, unsigned long size, unsigned long done,
 
        pct = (int) (100.0 * (float) done / size);
 
-       printf("\r%-25.25s | %10ld kB | %5.1f kB/s | ETA: %8s | %3d%%",
-              name, done / 1024, ratebs / 1024.0, etastr, pct);
+       len = printf("\r%-25.25s | %10ld kB | %5.1f kB/s | ETA: %8s | %3d%%",
+                    name, done / 1024, ratebs / 1024.0, etastr, pct);
+       if (len < prev_stats_len)
+           printf("%*s", prev_stats_len - len, "");
+       prev_stats_len = len;
 
        if (done == size)
            printf("\n");