On Sunday 04 October 2009 20:17, Maciek Borzecki wrote:
> Proposed patch for dotted progress indicator support as well as using
> it by default if stderr output is redirected to non-tty. Quite useful
> in case of calling wget from other process.
> Should apply cleanly against current git master.

Looks mostly ok, needs a few minor fixes:

+       opt = getopt32(argv, "csqO:P:Y:U:" /*ignored:*/ "t:T:d",

Comment is lying now after your cnange. -d is definitely not ignored!


+       IF_FEATURE_WGET_STATUSBAR( \
+     "\n        -d      Use \'dot\' progress bar") \
      "\n       -P      Set directory prefix to DIR" \

Use tab, not spaces, just like -P option text does.
Also, do not invent incompatible options,
use --progress={bar,dot}[:style]
to be compatible with upstream. You may ignore :style,
but do not fail if it's there.


        unsigned lastupdate_sec;
        unsigned start_sec;
+       int use_dot;

...

+       if (use_dot == 1) {

...

+
+       if (opt & WGET_OPT_DOT)
+               use_dot = 1;
+
+       if (!isatty(STDERR_FILENO)) 
+               use_dot = 1;

(1) use_dot should be smallint or bool, but
(2) you do not even need it - just use (option_mask32 & WGET_OPT_DOT)
    instead.


+                       while ((transferred - lastsize) > 1024 ) {

Why > instead of >= ?


+                                               /* ETA calculated exactly the 
same */
+                                               int eta = (int) 
ETA(to_download, transferred, elapsed);

"exactly the same" as what? The comment is a bit confusing.
Maybe move it to the definition of ETA()?


+               unsigned lastsize_k = lastsize >> 10;
...
+                       unsigned lastsize_fill = ((lastsize >> 10) + 1) << 10;
+                       while (lastsize < lastsize_fill) {
+                               fputc(' ', stderr);
+                               lastsize += 1024;
+                       }
+                       fprintf(stderr, "%d%% %ds\n", ratio, elapsed);

You already have (lastsize >> 10) in lastsize_k. But it looks buggy anyway,
you round up to nearest kb but you need to round up to nearest 50k.
The result looks wrong:

# ./busybox wget -d http://kernel.org/
Connecting to kernel.org (204.152.191.37:80)
 100% 0s
......... .......... ....

was ist das? Upstream does this:

    0K .......... .......... ....                               64.76 KB/s

00:04:22 (64.76 KB/s) - `index.html' saved [25199]


--
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to