aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-08-08 04:21:50 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-08-08 04:21:50 +0200
commitda0df47f244be581f48fd50909d6a68ceae327a9 (patch)
tree04cb9534d3d4482ab32e2f2f3bda065feeb09d06
parent64f2ba276cb98f43dbc4e420d48330830aec29a8 (diff)
downloadbusybox-w32-da0df47f244be581f48fd50909d6a68ceae327a9.tar.gz
busybox-w32-da0df47f244be581f48fd50909d6a68ceae327a9.tar.bz2
busybox-w32-da0df47f244be581f48fd50909d6a68ceae327a9.zip
wget: fix ndelay_on call; progress bar: small shrink
function old new delta bb_progress_update 682 670 -12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/progress.c24
-rw-r--r--networking/wget.c2
2 files changed, 13 insertions, 13 deletions
diff --git a/libbb/progress.c b/libbb/progress.c
index 7fb8536d2..f53271398 100644
--- a/libbb/progress.c
+++ b/libbb/progress.c
@@ -76,7 +76,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
76 elapsed = monotonic_sec(); 76 elapsed = monotonic_sec();
77 since_last_update = elapsed - p->lastupdate_sec; 77 since_last_update = elapsed - p->lastupdate_sec;
78 /* Do not update on every call 78 /* Do not update on every call
79 * (might be: on every network read!) */ 79 * (we can be called on every network read!) */
80 if (since_last_update == 0 && !totalsize) 80 if (since_last_update == 0 && !totalsize)
81 return; 81 return;
82 82
@@ -84,7 +84,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
84 ratio = 100; 84 ratio = 100;
85 if (beg_and_transferred < totalsize) { 85 if (beg_and_transferred < totalsize) {
86 /* Do not update on every call 86 /* Do not update on every call
87 * (might be: on every network read!) */ 87 * (we can be called on every network read!) */
88 if (since_last_update == 0) 88 if (since_last_update == 0)
89 return; 89 return;
90 /* long long helps to have it working even if !LFS */ 90 /* long long helps to have it working even if !LFS */
@@ -118,14 +118,14 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
118 barlength = get_tty2_width() - 49; 118 barlength = get_tty2_width() - 49;
119 if (barlength > 0) { 119 if (barlength > 0) {
120 /* god bless gcc for variable arrays :) */ 120 /* god bless gcc for variable arrays :) */
121 i = barlength * ratio / 100; 121 char buf[barlength + 1];
122 { 122 unsigned stars = (unsigned)barlength * ratio / (unsigned)100;
123 char buf[i+1]; 123 memset(buf, ' ', barlength);
124 memset(buf, '*', i); 124 buf[barlength] = '\0';
125 buf[i] = '\0'; 125 memset(buf, '*', stars);
126 fprintf(stderr, "|%s%*s|", buf, barlength - i, ""); 126 fprintf(stderr, "|%s|", buf);
127 }
128 } 127 }
128
129 i = 0; 129 i = 0;
130 while (beg_and_transferred >= 100000) { 130 while (beg_and_transferred >= 100000) {
131 i++; 131 i++;
@@ -155,10 +155,10 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
155 fprintf(stderr, "--:--:-- ETA"); 155 fprintf(stderr, "--:--:-- ETA");
156 } else { 156 } else {
157 /* to_download / (transferred/elapsed) - elapsed: */ 157 /* to_download / (transferred/elapsed) - elapsed: */
158 int eta = (int) ((unsigned long long)to_download*elapsed/transferred - elapsed);
159 /* (long long helps to have working ETA even if !LFS) */ 158 /* (long long helps to have working ETA even if !LFS) */
160 i = eta % 3600; 159 unsigned eta = (unsigned long long)to_download*elapsed/(uoff_t)transferred - elapsed;
161 fprintf(stderr, "%02d:%02d:%02d ETA", eta / 3600, i / 60, i % 60); 160 unsigned secs = eta % 3600;
161 fprintf(stderr, "%02u:%02u:%02u ETA", eta / 3600, secs / 60, secs % 60);
162 } 162 }
163 } 163 }
164} 164}
diff --git a/networking/wget.c b/networking/wget.c
index f62339071..fb8e51317 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -455,7 +455,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd)
455 455
456 polldata.fd = fileno(dfp); 456 polldata.fd = fileno(dfp);
457 polldata.events = POLLIN | POLLPRI; 457 polldata.events = POLLIN | POLLPRI;
458 ndelay(polldata.fd); 458 ndelay_on(polldata.fd);
459#endif 459#endif
460 progress_meter(PROGRESS_START); 460 progress_meter(PROGRESS_START);
461 461