You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by pg...@apache.org on 2005/08/24 20:18:22 UTC

svn commit: r239724 - /perl/modperl/trunk/lib/Apache2/Build.pm

Author: pgollucci
Date: Wed Aug 24 11:18:19 2005
New Revision: 239724

URL: http://svn.apache.org/viewcvs?rev=239724&view=rev
Log:
check $ccopts for -Wdeclaration-after-statement
if not already present and the gcc version supports its (3.3.2+)
add it


Modified:
    perl/modperl/trunk/lib/Apache2/Build.pm

Modified: perl/modperl/trunk/lib/Apache2/Build.pm
URL: http://svn.apache.org/viewcvs/perl/modperl/trunk/lib/Apache2/Build.pm?rev=239724&r1=239723&r2=239724&view=diff
==============================================================================
--- perl/modperl/trunk/lib/Apache2/Build.pm (original)
+++ perl/modperl/trunk/lib/Apache2/Build.pm Wed Aug 24 11:18:19 2005
@@ -523,6 +523,12 @@
             $ccopts .= " $Wall -DAP_DEBUG";
             $ccopts .= " -DAP_HAVE_DESIGNATED_INITIALIZER";
         }
+
+        if ($self->has_gcc_version('3.3.2') && 
+            $ccopts !~ /declaration-after-statement/) {
+            debug "Adding -Wdeclaration-after-statement to ccopts";
+            $ccopts .= " -Wdeclaration-after-statement";
+        }
     }
 
     if ($self->{MP_COMPAT_1X}) {
@@ -555,6 +561,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 @tuples = split /\./, $has_version, 3;
+    my @r_tuples = split /\./, $requested_version, 3;
+    
+    return cmp_tuples(\@tuples, \@r_tuples) == 1;
+}
+
+sub cmp_tuples {
+
+    my($a, $b) = @_;
+
+    while (@$a && @$b) {
+        my $cmp = shift @$a <=> shift @$b;
+        return $cmp if $cmp;
+    }
+
+    return @$a <=> @$b;
+}
+    
 sub perl_ccopts {
     my $self = shift;
 



Re: svn commit: r239724 - /perl/modperl/trunk/lib/Apache2/Build.pm

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Philip M. Gollucci wrote:
> Stas Bekman wrote:
> 
>>> +sub cmp_tuples {
>>> +
>>> +    my($a, $b) = @_;
>>> +
>>> +    while (@$a && @$b) {
>>> +        my $cmp = shift @$a <=> shift @$b;
>>> +        return $cmp if $cmp;
>>> +    }
>>> +
>>> +    return @$a <=> @$b;
>>> +}
>>
>> Philip, please avoid using $a and $b in any code, but sort()
>> callbacks, as they are special in perl and may have bad side effects.
> 
> Gozer wrote that :)

Yup, it was only an example ;-) But, really, stas is correct, $a and $b can
have some nasty side effects.

--------------------------------------------------------------------------------
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

Re: svn commit: r239724 - /perl/modperl/trunk/lib/Apache2/Build.pm

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Stas Bekman wrote:
> 
>> +sub cmp_tuples {
>> +
>> +    my($a, $b) = @_;
>> +
>> +    while (@$a && @$b) {
>> +        my $cmp = shift @$a <=> shift @$b;
>> +        return $cmp if $cmp;
>> +    }
>> +
>> +    return @$a <=> @$b;
>> +}
> 
> 
> Philip, please avoid using $a and $b in any code, but sort() callbacks, 
> as they are special in perl and may have bad side effects.
Gozer wrote that :)

-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: svn commit: r239724 - /perl/modperl/trunk/lib/Apache2/Build.pm

Posted by Stas Bekman <st...@stason.org>.
> +sub cmp_tuples {
> +
> +    my($a, $b) = @_;
> +
> +    while (@$a && @$b) {
> +        my $cmp = shift @$a <=> shift @$b;
> +        return $cmp if $cmp;
> +    }
> +
> +    return @$a <=> @$b;
> +}

Philip, please avoid using $a and $b in any code, but sort() callbacks, as 
they are special in perl and may have bad side effects.


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://mailchannels.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org