perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@ectoplasm.org>
Subject Re: -Wdeclaration-after-statement Final version
Date Wed, 24 Aug 2005 17:39:38 GMT
Philip M. Gollucci wrote:
> Philip M. Gollucci wrote:
> 
>> Philippe M. Chiasson wrote:
>> Ah, I did miss it... read right over it. D'oh!
>>
> Here is its again with the return 0 left in as most of the code in
> Build.pm is return 0 though not all.
> Also, using Philippe's cmp_tuples function.

Looks good, with notes below...

> 
> Index: Build.pm
> ===================================================================
> --- Build.pm    (revision 234145)
> +++ Build.pm    (working copy)
> @@ -523,6 +523,11 @@
>              $ccopts .= " $Wall -DAP_DEBUG";
>              $ccopts .= " -DAP_HAVE_DESIGNATED_INITIALIZER";
>          }
> +
> +        if ($self->has_gcc_version('3.3.2') &&
> +            $ccopts !~ /declaration-after-statement/) {
> +            $ccopts .= " -Wdeclaration-after-statement";

		debug "Adding -Wdeclaration-after-statement to ccopts";

> +        }
>      }
> 
>      if ($self->{MP_COMPAT_1X}) {
> @@ -555,6 +560,33 @@
>      $ccopts;
>  }
> 
> +sub has_gcc_version {
> +
> +    my $self = shift;
> +    my $requested_version = shift;
> +
> +    my $has_version = $self->perl_config('gccversion');
> +
> +    return 0 unless $has_version;
> +
> +    my ($has_major, $has_minor, $has_patch) = split /\./, $has_version, 3;
> +    my ($r_major, $r_minor, $r_patch) = split /\./, $requested_version, 3;

Again, why not a simpler:

my @tuples = split /\./, $has_version;
my @r_tuples = split /\./, $requested_version;

> +    return &cmp_tuples(\@tuples, \@r_tuples) == 1;

return cmp_tuples(); The '&' isn't necessary.

> +}
> +
> +sub cmp_tuples {
> +
> +    my ($a, $b) = @_;
> +
> +    while(@$a && @$b) {
> +        my $cmp = shift @$a <=> shift @$b;
> +        return $cmp if $cmp;
> +    }
> +
> +    return @$a <=> @$b;
> +}
> +

Otherwise, +1

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Mime
View raw message