SVN: toys/rsget.pl/RSGet: Curl.pm HTTPRequest.pm Line.pm

sparky sparky at pld-linux.org
Sun Dec 19 23:35:54 CET 2010


Author: sparky
Date: Sun Dec 19 23:35:54 2010
New Revision: 12006

Modified:
   toys/rsget.pl/RSGet/Curl.pm
   toys/rsget.pl/RSGet/HTTPRequest.pm
   toys/rsget.pl/RSGet/Line.pm
Log:
- record progress as 0.0-1.0 number, convert to % later


Modified: toys/rsget.pl/RSGet/Curl.pm
==============================================================================
--- toys/rsget.pl/RSGet/Curl.pm	(original)
+++ toys/rsget.pl/RSGet/Curl.pm	Sun Dec 19 23:35:54 2010
@@ -621,8 +621,8 @@
 
 		my $size = bignum( $size_got ) . " / " . bignum( $size_total );
 		if ( $size_total > 0 ) {
-			my $per = sprintf "%.2f%%", $size_got * 100 / $size_total;
-			$size .= " [$per]";
+			my $per = $size_got / $size_total;
+			$size .= sprintf ' [%.2f%%]', $per * 100;
 			$supercurl->{get_obj}->linedata( prog => $per );
 		}
 

Modified: toys/rsget.pl/RSGet/HTTPRequest.pm
==============================================================================
--- toys/rsget.pl/RSGet/HTTPRequest.pm	(original)
+++ toys/rsget.pl/RSGet/HTTPRequest.pm	Sun Dec 19 23:35:54 2010
@@ -193,7 +193,8 @@
 	$uri = sgml( $uri );
 
 	my $prog = "";
-	$prog = qq#<div style="width: $o->{prog}"></div># if $o->{prog};
+	$prog = sprintf '<div style="width: %f%%"></div>', $o->{prog} * 100
+		if $o->{prog};
 	$line =~ s/^\Q$o->{name}\E//;
 	$line =~ s/^.*?:\s+//;
 	$line = sgml( $line );

Modified: toys/rsget.pl/RSGet/Line.pm
==============================================================================
--- toys/rsget.pl/RSGet/Line.pm	(original)
+++ toys/rsget.pl/RSGet/Line.pm	Sun Dec 19 23:35:54 2010
@@ -154,8 +154,7 @@
 		if ( my $prog = $line->[2]->{prog} ) {
 			$thisline = $line->[0] . $text;
 			$thisline .= " " x ( $columns - length $thisline );
-			$prog =~ s/%//;
-			substr $thisline, $columns * $prog / 100, 0, "\033[0;32m";
+			substr $thisline, $columns * $prog, 0, "\033[0;32m";
 			$thisline = "\033[30;42m$thisline$endcolor";
 		}
 		push @print, "\r\n\033[K" . $thisline;


More information about the pld-cvs-commit mailing list