Subject: | Error in language detection - also warnings during make test |
There is a bug in the detection of languages from properties in
HTML-ParseBrowser-1_0:
for my $lang (keys %lang) {
if (/^$lang\-/) {
my $l;
($l, undef) = split /\-/;
push @{$browser->{languages}}, $lang{$l} || $1;
push @{$browser->{langs}}, $1;
}
The code pushes $1 (one) onto the arrays, rather than $l (lowercase l).
This causes a warning during make test. Other parts of the code also
generate warnings during make test, but don't seem to indicate actual bugs.
The attached patch fixes both the above bug and the warnings.
Subject: | html-parsebrowser.patch |
--- lib/HTML/ParseBrowser.pm~ 2008-07-16 17:56:08.000000000 -0400
+++ lib/HTML/ParseBrowser.pm 2008-10-16 11:09:21.000000000 -0400
@@ -34,10 +34,12 @@
if ($useragent =~ s/\((.*)\)//) {
$browser->{detail} = $1;
+ $browser->{properties} = [split /;\s+/, $browser->{detail}];
+ } else {
+ $browser->{properies} = [];
}
$browser->{useragents} = [grep /\//, split /\s+/, $useragent];
- $browser->{properties} = [split /;\s+/, $browser->{detail}];
for (@{$browser->{useragents}}) {
my ($br, $ver) = split /\//;
@@ -144,8 +146,8 @@
if (/^$lang\-/) {
my $l;
($l, undef) = split /\-/;
- push @{$browser->{languages}}, $lang{$l} || $1;
- push @{$browser->{langs}}, $1;
+ push @{$browser->{languages}}, $lang{$l} || $l;
+ push @{$browser->{langs}}, $l;
}
push @{$browser->{languages}}, $lang{$_} if /^$lang$/;
@@ -181,12 +183,18 @@
$langs_in{$_}++;
}
+ if (scalar keys %langs_in) {
($browser->{lang}) = sort {$langs_in{$a} <=> $langs_in{$b}} keys %langs_in;
$browser->{language} = $lang{$browser->{lang}} || $browser->{lang};
+ }
delete $browser->{language} unless $browser->{language};
return $browser;
}
+# define DESTROY so AUTOLOAD is not called
+sub DESTROY {
+}
+
sub AUTOLOAD {
my $obj = shift;
my $me = lc $AUTOLOAD;
Subject: | html-parsebrowser-warnings.txt |
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/HTML-ParseBrowser....ok 1/17Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12.
Use of uninitialized value in split at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 40, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 181, <DATA> line 12.
Use of uninitialized value in hash element at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 185, <DATA> line 12.
Use of uninitialized value in scalar dereference at /home/rkimball/perl/HTML-ParseBrowser/blib/lib/HTML/ParseBrowser.pm line 202, <DATA> line 12 during global destruction.
t/HTML-ParseBrowser....ok
All tests successful.
Files=1, Tests=17, 0 wallclock secs ( 0.04 cusr + 0.00 csys = 0.04 CPU)