aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-04-08 19:28:23 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-04-08 19:28:23 +0000
commiteb856b04fee26345ea0c2addb19c3d97a847e931 (patch)
tree1cde2311aec59fceee7d6dd6d47dd59c14dc57a4
parentcd9ad9e54b4e98487206542aae191a5b7681dc6d (diff)
Improved the looks of the progress meter when the file size is between
9999 KB and 100 MB since it then can display the size as XX.X MB instead of just XX as before.
-rw-r--r--lib/progress.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/progress.c b/lib/progress.c
index 1bd5b470c..1bb5aec0c 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -72,15 +72,23 @@ void time2str(char *r, int t)
but never longer than 5 columns. Add suffix k, M, G when suitable... */
char *max5data(double bytes, char *max5)
{
+#define ONE_KILOBYTE 1024
+#define ONE_MEGABYTE (1024*1024)
+
if(bytes < 100000) {
sprintf(max5, "%5d", (int)bytes);
return max5;
}
- if(bytes < (9999*1024)) {
- sprintf(max5, "%4dk", (int)bytes/1024);
+ if(bytes < (9999*ONE_KILOBYTE)) {
+ sprintf(max5, "%4dk", (int)bytes/ONE_KILOBYTE);
+ return max5;
+ }
+ if(bytes < (100*ONE_MEGABYTE)) {
+ /* 'XX.XM' is good as long as we're less than 100 megs */
+ sprintf(max5, "%2.1fM", bytes/ONE_MEGABYTE);
return max5;
}
- sprintf(max5, "%4dM", (int)bytes/(1024*1024));
+ sprintf(max5, "%4dM", (int)bytes/ONE_MEGABYTE);
return max5;
}