Hi,
I sent a patch on [EMAIL PROTECTED] a few days ago, but I got no
feedback, so I repost it here so that maybe more people can test
it. (It also fixes a bug with ftp, compared to the first patch I sent) :
It's a patch to add a new dot-style named 'auto'. It tries to choose
reasonnable values depending on the file size so that no more than 10
lines of dots are printed.
Here's a changelog entry :
2001-09-17 Laurent Martelli <[EMAIL PROTECTED]>
* all: new dot-style "auto".
And the patch
diff -ru wget-1.7/doc/wget.texi wget-1.7.patch/doc/wget.texi
--- wget-1.7/doc/wget.texi Mon Jun 4 13:23:23 2001
+++ wget-1.7.patch/doc/wget.texi Mon Sep 17 17:25:35 2001
@@ -630,7 +630,9 @@
retrieved, there are eight dots in a cluster, and 48 dots on each line
(so each line contains 3M). The @code{micro} style is exactly the
reverse; it is suitable for downloading small files, with 128-byte dots,
-8 dots per cluster, and 48 dots (6K) per line.
+8 dots per cluster, and 48 dots (6K) per line. The @code{auto} style
+will automatically choose values depending in the size of files so that
+no more than 10 lines of dots are printed.
@item -N
@itemx --timestamping
diff -ru wget-1.7/src/ftp.c wget-1.7.patch/src/ftp.c
--- wget-1.7/src/ftp.c Sun May 27 21:34:58 2001
+++ wget-1.7.patch/src/ftp.c Mon Sep 17 17:09:09 2001
@@ -856,6 +856,9 @@
if (*len)
{
+ if (opt.dot_style_auto) {
+ compute_auto_dotstyle(*len);
+ }
logprintf (LOG_VERBOSE, _("Length: %s"), legible (*len));
if (restval)
logprintf (LOG_VERBOSE, _(" [%s to go]"), legible (*len - restval));
@@ -864,6 +867,9 @@
}
else if (expected_bytes)
{
+ if (opt.dot_style_auto) {
+ compute_auto_dotstyle(expected_bytes);
+ }
logprintf (LOG_VERBOSE, _("Length: %s"), legible (expected_bytes));
if (restval)
logprintf (LOG_VERBOSE, _(" [%s to go]"),
diff -ru wget-1.7/src/http.c wget-1.7.patch/src/http.c
--- wget-1.7/src/http.c Sun May 27 21:35:02 2001
+++ wget-1.7.patch/src/http.c Mon Sep 17 17:11:26 2001
@@ -1273,6 +1277,9 @@
logputs (LOG_VERBOSE, "\n");
}
}
+ if (opt.dot_style_auto) {
+ compute_auto_dotstyle(contlen);
+ }
FREE_MAYBE (type);
type = NULL; /* We don't need it any more. */
diff -ru wget-1.7/src/init.c wget-1.7.patch/src/init.c
--- wget-1.7/src/init.c Sun May 27 21:35:04 2001
+++ wget-1.7.patch/src/init.c Mon Sep 17 16:50:43 2001
@@ -914,6 +914,10 @@
opt.dot_spacing = 8;
opt.dots_in_line = 48;
}
+ else if (!strcasecmp (val, "auto"))
+ {
+ opt.dot_style_auto=1;
+ }
else
{
fprintf (stderr, _("%s: %s: Invalid specification `%s'.\n"),
diff -ru wget-1.7/src/options.h wget-1.7.patch/src/options.h
--- wget-1.7/src/options.h Sun May 27 21:35:08 2001
+++ wget-1.7.patch/src/options.h Mon Sep 17 16:49:55 2001
@@ -143,6 +143,7 @@
dot. */
int dots_in_line; /* How many dots in one line. */
int dot_spacing; /* How many dots between spacings. */
+ int dot_style_auto;
int delete_after; /* Whether the files will be deleted
after download. */
diff -ru wget-1.7/src/retr.c wget-1.7.patch/src/retr.c
--- wget-1.7/src/retr.c Sun May 27 21:35:09 2001
+++ wget-1.7.patch/src/retr.c Mon Sep 17 17:15:06 2001
@@ -147,6 +147,40 @@
return res;
}
+void compute_auto_dotstyle(long length)
+{
+ if (length>20480*1024)
+ {
+ opt.dot_bytes = 320*1024;
+ opt.dot_spacing = 16;
+ opt.dots_in_line = 64;
+ }
+ else if (length>5000*1024)
+ {
+ opt.dot_bytes = 32*1024;
+ opt.dot_spacing = 16;
+ opt.dots_in_line = 64;
+ }
+ else if (length>1000*1024)
+ {
+ opt.dot_bytes = 10*1024;
+ opt.dot_spacing = 10;
+ opt.dots_in_line = 50;
+ }
+ else if (length>500*1024)
+ {
+ opt.dot_bytes = 2048;
+ opt.dot_spacing = 10;
+ opt.dots_in_line = 50;
+ }
+ else
+ {
+ opt.dot_bytes = 1024;
+ opt.dot_spacing = 10;
+ opt.dots_in_line = 50;
+ }
+}
+
static void
print_percentage (long bytes, long expected)
{
diff -ru wget-1.7/src/retr.h wget-1.7.patch/src/retr.h
--- wget-1.7/src/retr.h Sun May 27 21:35:10 2001
+++ wget-1.7.patch/src/retr.h Mon Sep 17 17:05:08 2001
@@ -36,4 +36,6 @@
void sleep_between_retrievals PARAMS ((int));
+void compute_auto_dotstyle PARAMS ((long));
+
#endif /* RETR_H */
--
Laurent Martelli
[EMAIL PROTECTED] http://www.bearteam.org/~laurent/