summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Barcroft <mike@FreeBSD.org>2001-08-29 23:51:14 +0000
committerMike Barcroft <mike@FreeBSD.org>2001-08-29 23:51:14 +0000
commit2b8bab2f343c7709d26d253250ac611ff665acf5 (patch)
treec48af1237f4e5ae72678b12e80086ec5acb0ee37
parent36e0bf6e9c7d06434c5c9d4435aafead0908022b (diff)
Notes
-rw-r--r--usr.bin/ftp/util.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c
index 60481910c342..3c1d49a6dfc0 100644
--- a/usr.bin/ftp/util.c
+++ b/usr.bin/ftp/util.c
@@ -670,16 +670,22 @@ progressmeter(flag)
if (bytes <= 0 || elapsed <= 0.0 || cursize > filesize) {
n = snprintf(buf + len, sizeof(buf) - len,
" --:-- ETA");
+ if (n > 0 && n < sizeof(buf) - len)
+ len += n;
} else if (wait.tv_sec >= STALLTIME) {
n = snprintf(buf + len, sizeof(buf) - len,
" - stalled -");
+ if (n > 0 && n < sizeof(buf) - len)
+ len += n;
} else {
remaining =
((filesize - restart_point) / (bytes / elapsed) - elapsed);
- if (remaining >= 100 * SECSPERHOUR)
+ if (remaining >= 100 * SECSPERHOUR) {
n = snprintf(buf + len, sizeof(buf) - len,
" --:-- ETA");
- else {
+ if (n > 0 && n < sizeof(buf) - len)
+ len += n;
+ } else {
i = remaining / SECSPERHOUR;
if (i)
n = snprintf(buf + len, sizeof(buf) - len,
@@ -694,8 +700,6 @@ progressmeter(flag)
"%02d:%02d ETA", i / 60, i % 60);
}
}
- if (n > 0 && n < sizeof(buf) - len)
- len += n;
(void)write(STDOUT_FILENO, buf, len);
if (flag == -1) {