- From: Mercurial notifier <nobody@w3.org>
- Date: Thu, 05 Aug 2010 14:47:12 +0000
- To: link-checker updates <www-validator-cvs@w3.org>
changeset: 219:757d35e348e0
user: ville
date: Sun Feb 10 13:29:33 2008 +0000
files: bin/checklink
description:
Print percentage indicator only when it changes; improves performance
significantly with some terminals and large documents.
diff -r 26464e87e9ca -r 757d35e348e0 bin/checklink
--- a/bin/checklink Sun Feb 10 13:25:21 2008 +0000
+++ b/bin/checklink Sun Feb 10 13:29:33 2008 +0000
@@ -5,7 +5,7 @@
# (c) 1999-2008 World Wide Web Consortium
# based on Renaud Bruyeron's checklink.pl
#
-# $Id: checklink,v 4.89 2008-02-10 13:25:21 ville Exp $
+# $Id: checklink,v 4.90 2008-02-10 13:29:33 ville Exp $
#
# This program is licensed under the W3C(r) Software License:
# http://www.w3.org/Consortium/Legal/copyright-software
@@ -244,7 +244,7 @@
$PROGRAM = 'W3C-checklink';
$VERSION = '4.3';
$REVISION = sprintf('version %s (c) 1999-2008 W3C', $VERSION);
- my ($cvsver) = q$Revision: 4.89 $ =~ /(\d+[\d\.]*\.\d+)/;
+ my ($cvsver) = q$Revision: 4.90 $ =~ /(\d+[\d\.]*\.\d+)/;
$AGENT = sprintf('%s/%s [%s] %s',
$PROGRAM, $VERSION, $cvsver, LWP::RobotUA->_agent());
@@ -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 Thursday, 5 August 2010 14:47:25 UTC