Hello all,
I noticed incorrect behavior of Arachne in some situations:
(1) When the history ([Backspace] key) is displayed, it is
(internally?) converted to HTML itemized list. The links which
contain special characters (like "&" in pages generated by server-
side scripts) are displayed incorrectly: these characters should
be escaped ("&" or ""), otherwise every "&" is treated as
beginning of an HTML entity.
(2) When I'm downloading my mail, the progress indicator often shows
slightly more than 100% (this may be a problem with the server,
I didn't investigate this). In such a situation, the green progress
bar extends to the right behind the limit of the status line, and
a piece of it remains on the screen even after the status line is
updated, and only [F9] key (repaint) helps.
(3) From time to time, I can see negative numbers while downloading
inline images -- something like
"Parallel image download (-nnnnn of -mmmmm bytes)".
Maybe there is an "int" variable instead of "long" one somewhere?
(4) While downloading a file larger than 20.5 Mbytes,
negative percentages are shown. The reason is, I guess, that the
percentage is calculated as:
int percent;
long amount, size;
percent = (100 * amount) / size;
The multiplication causes integer overflow when
amount > (MAXLONG / 100) == 0x0147AE14 == 21474836,
i.e., for about 20.5 Mbytes (binary, "MiB").
The possible solutions are:
(a) Use floating point to prevent integer overflow:
percent = (int) ((100.0 * amount) / size);
But if the FP library isn't normally linked, it will bloat the
executable.
(b) Use 64-bit integer (long long int) if available (not BC++ 3.1):
percent = 100 * ((long long) amount) / size;
(c) Accept a small error and use an alternative formula for big files:
percent = (size > 0x0147AE14) ?
amount / (size / 100) : (100 * amount) / size;
The error (overestimation) is very small, one can get percent == 100
when amount >= (size - 99), i.e., when no more than 99 bytes is left
to download. (The formula can be changed to overestimating, then one
can get percent == 99 when amount == size and another condition has
to be added to get 100% at the end).
To generate more efficient code, the condition can be replaced with
size >= 0x01000000
which is, for positive numbers, equivalent to "nicer" ones
size & 0x7F000000,
size >> 24,
which may generate shorter code, depending on compiler capabilities
and settings. [The best machine code, of course, is generated by the
best compiler: experienced programmer's mind ;-)]
Sorry for boring these all who don't have the source code,
Michal