[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev fix HTReadProgress (patch)
From: |
Leonid Pauzner |
Subject: |
lynx-dev fix HTReadProgress (patch) |
Date: |
Mon, 21 Dec 1998 14:28:06 +0300 (MSK) |
* In HTReadProgress() use DontCheck() instead of interpolation, more accurate
transfer rate calculation (was problem within a second cyrcle). - LP
diff -u old/htalert.c ./htalert.c
--- old/htalert.c Sat Dec 12 20:10:36 1998
+++ ./htalert.c Mon Dec 21 14:14:16 1998
@@ -96,7 +96,7 @@
static long kb_units = 1024;
static time_t first, last;
static long bytes_last;
- long transfer_rate, divisor;
+ static long transfer_rate, divisor;
char line[80];
time_t now = time((time_t *)0); /* once per second */
char *units = "bytes";
@@ -104,20 +104,14 @@
if (bytes == 0) {
first = last = now;
bytes_last = bytes;
- } else if ((bytes > 0) &&
- (now != first))
- /* 1 sec delay for transfer_rate calculation :-( */ {
- transfer_rate = (bytes) / (now - first); /* bytes/sec */
+ } else if ((bytes > 0) && !DontCheck()) {
- /* optimal refresh time: every 0.2 sec */
- if ((bytes - bytes_last) > (transfer_rate / 5)) {
-
- bytes_last += (transfer_rate / 5); /* until we got next second */
-
- if (now != last) {
+ if (now != first && now != last) {
+ /* 1 sec delay for transfer_rate calculation :-( */
+ transfer_rate = (bytes) / (now - first); /* bytes/sec */
last = now;
- bytes_last = bytes;
- }
+ }
+
units = gettext("bytes");
divisor = 1;
if (LYshow_kb_rate
@@ -132,7 +126,7 @@
sprintf (line, gettext("Read %ld of %ld %s of data"), bytes,
total, units);
else
sprintf (line, gettext("Read %ld %s of data"), bytes, units);
- if ((transfer_rate > 0)
+ if ((now != first)
&& (!LYshow_kb_rate || (bytes * divisor >= kb_units)))
sprintf (line + strlen(line), gettext(", %ld %s/sec."),
transfer_rate / divisor, units);
else
@@ -142,7 +136,6 @@
strcat(line, gettext(" (Press 'z' to abort)"));
}
HTProgress(line);
- }
}
}
diff -u old/lyutils.c ./lyutils.c
--- old/lyutils.c Sat Dec 12 20:10:36 1998
+++ ./lyutils.c Mon Dec 21 13:21:10 1998
@@ -2039,7 +2039,7 @@
}
-PRIVATE int DontCheck NOARGS
+PUBLIC int DontCheck NOARGS
{
static long last;
long next;
diff -u old/lyutils.h ./lyutils.h
--- old/lyutils.h Sat Dec 12 20:10:36 1998
+++ ./lyutils.h Mon Dec 21 13:20:54 1998
@@ -65,6 +65,7 @@
extern char *LYgetXDisplay NOPARAMS;
extern char *strip_trailing_slash PARAMS((char * my_dirname));
extern char *wwwName PARAMS((CONST char *pathname));
+extern int DontCheck NOPARAMS;
extern int HTCheckForInterrupt NOPARAMS;
extern int LYCheckForProxyURL PARAMS((char *filename));
extern int LYOpenInternalPage PARAMS((FILE **fp0, char **newfile));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev fix HTReadProgress (patch),
Leonid Pauzner <=