tag 467122 patch
thanks
On Sat, Feb 23, 2008 at 10:10:29AM +0200, Niko Tyni wrote:
> Package: libapache-admin-config-perl
> Version: 0.94-1
> Severity: important
> User: [EMAIL PROTECTED]
> Usertags: perl-5.10-ftbfs
>
> Your package fails to build with Perl 5.10 (currently in experimental.)
> t/value...............# Failed test 3 in t/value.t at line 15
> # t/value.t line 15 is: ok($item eq 'test');
> # Failed test 5 in t/value.t at line 18
> # t/value.t line 18 is: ok($item == 40);
> # Failed test 9 in t/value.t at line 24
> # t/value.t line 24 is: ok($item2 eq 'test');
> # Failed test 11 in t/value.t at line 27
> # t/value.t line 27 is: ok($item2 eq 'test_change');
> # Failed test 13 in t/value.t at line 29
> # t/value.t line 29 is: ok($item eq 'test_change');
This was really weird to debug.
The code in Apache::Admin::Config::Tree->to_string() is working around
[rt.perl.org #41546]: perl 5.8.x bug: overloaded 'eq' does not work with
'nomethod'
http://rt.perl.org/rt3/Public/Bug/Display.html?id=41546
with clearly incorrect code like
if($meth eq 'eq') [...] return($other ne $self->{value});
if($meth eq 'ne') [...] return($other ne $self->{value});
that now breaks because the Perl bug is fixed in the 5.10 series.
The attached patch implements 'cmp' and '<=>', so that 'eq', 'ne',
'==' and '!=' are computed in terms of those rather than by falling
back to 'nomethod'. This works for me on both 5.8.8 and 5.10.0.
Please send this upstream too.
Cheers,
--
Niko Tyni [EMAIL PROTECTED]
diff --git a/lib/Apache/Admin/Config.pm b/lib/Apache/Admin/Config.pm
index 06c3738..237b7a5 100644
--- a/lib/Apache/Admin/Config.pm
+++ b/lib/Apache/Admin/Config.pm
@@ -227,7 +227,8 @@ package Apache::Admin::Config::Tree;
use strict;
use Carp;
use FileHandle;
-use overload nomethod => \&to_string;
+use overload cmp => \&cmp_string, '<=>' => \&spaceship_number,
+ nomethod => \&to_string;
sub new
@@ -1228,47 +1229,25 @@ sub isin
}
}
+sub cmp_string
+{
+ my ($self, $other, $inv) = @_;
+ return $inv ? ($other cmp $self->{value}) :
+ ($self->{value} cmp $other);
+}
+
+sub spaceship_number
+{
+ my ($self, $other, $inv) = @_;
+ return $inv ? ($other <=> $self->{value}) :
+ ($self->{value} <=> $other);
+}
+
sub to_string
{
my($self, $other, $inv, $meth) = @_;
- if($meth eq 'eq')
- {
- if($^W and (!defined $other or !defined $self->{value}))
- {
- carp "Use of uninitialized value in string eq";
- }
- local $^W;
- return($other ne $self->{value});
- }
- elsif($meth eq 'ne')
- {
- if($^W and (!defined $other or !defined $self->{value}))
- {
- carp "Use of uninitialized value in string ne";
- }
- local $^W;
- return($other ne $self->{value});
- }
- elsif($meth eq '==')
- {
- if($^W and (!defined $other or !defined $self->{value}))
- {
- carp "Use of uninitialized value in numeric eq (==)";
- }
- local $^W;
- return($other != $self->{value});
- }
- elsif($meth eq '!=')
- {
- if($^W and (!defined $other or !defined $self->{value}))
- {
- carp "Use of uninitialized value in numeric ne (!=)";
- }
- local $^W;
- return($other != $self->{value});
- }
- elsif(!defined $self->{value})
+ if(!defined $self->{value})
{
return overload::StrVal($self);
}