perl/modules/W3C/LinkChecker/bin checklink,4.89,4.90

Update of /sources/public/perl/modules/W3C/LinkChecker/bin
In directory hutz:/tmp/cvs-serv6138

Modified Files:
	checklink 
Log Message:
Print percentage indicator only when it changes; improves performance
significantly with some terminals and large documents.


Index: checklink
===================================================================
RCS file: /sources/public/perl/modules/W3C/LinkChecker/bin/checklink,v
retrieving revision 4.89
retrieving revision 4.90
diff -u -d -r4.89 -r4.90
--- checklink	10 Feb 2008 13:25:21 -0000	4.89
+++ checklink	10 Feb 2008 13:29:33 -0000	4.90
@@ -1388,7 +1388,10 @@
                 $self->declaration(substr($_[0], 2, -1));
               }, 'self, text, line');
   # Other stuff
-  $p->handler(default => 'parse_progress', 'self, line') if $Opts{Progress};
+  if ($Opts{Progress}) {
+    $p->handler(default => 'parse_progress', 'self, line');
+    $p->{last_percentage} = 0;
+  }
   $p->handler(end_document => 'end_document', 'self, line');
   # Check <a [..] name="...">?
   $p->{check_name} = 1;
@@ -1434,8 +1437,14 @@
 sub parse_progress
 {
   my ($self, $line) = @_;
-  printf("\r%4d%%", int($line/$self->{Total}*100))
-    if (defined($line) && $line >= 0 && $self->{Total} > 0);
+  return unless defined($line) && $line > 0 && $self->{Total} > 0;
+
+  my $percentage = int($line/$self->{Total}*100);
+  if ($percentage != $self->{last_percentage}) {
+    printf("\r%4d%%", $percentage);
+    $self->{last_percentage} = $percentage;
+  }
+
   return;
 }
 

Received on Sunday, 10 February 2008 13:29:48 UTC