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 Fri, 12 Aug 2005 19:01:32 GMT
Philip M. Gollucci wrote:
> Third and final take.  No objects and I'll commit.  I combined all 3 of
> the verions. :) Who would have thought something so small would take so
> long?

I am not so surprised ;-) I've seen patches take many more iterations
than this one before going thru. It's one way to keep the codebase
clean and concise (and hopefully bug-free).

> ===================================================================
> --- lib/Apache2/Build.pm        (revision 230957)
> +++ lib/Apache2/Build.pm        (working copy)
> @@ -518,10 +518,21 @@
> 
>      if ($self->{MP_MAINTAINER}) {
>          $self->{MP_DEBUG} = 1;
> -        if ($self->perl_config('gccversion')) {
> +
> +        if (my $gccversion = $self->perl_config('gccversion')) {
>              #same as --with-maintainter-mode
>              $ccopts .= " $Wall -DAP_DEBUG";
>              $ccopts .= " -DAP_HAVE_DESIGNATED_INITIALIZER";
> +
> +            my ($gcc_major, $gcc_minor, $gcc_patch) =
> +                $gccversion =~ /^(\d)\.(\d+)\.(\d+)/;
> +
> +            my $gccversion_decimal = $gcc_major .
> +                $gcc_minor . $gcc_patch;
> +
> +            ## GCC 3.3.2+

if ($gcc_major > 3 ||
    $gcc_major == 3 && (
	$gcc_minor > 3 ||
	    $gcc_minor == 3 &&
		$gcc_patch >= 2 )) {

> +            if ($gccversion_decimal > 332) {
> +              $ccopts .= " -Wdeclaration-after-statement";
> +            }
>          }
>      }

Getting version arithmetic is always a pita, for instance, the decimal concat
version will fail if there is such a thing as gcc-3.2.10 or gcc-2.95.2.

sub check_gcc332_if {
    my $gccversion = shift;
    my ($gcc_major, $gcc_minor, $gcc_patch) =
      $gccversion =~ /^(\d)\.(\d+)\.(\d+)/;

    if (   $gcc_major > 3
        || $gcc_major == 3
        && ($gcc_minor > 3 || $gcc_minor == 3 && $gcc_patch > 2))
    {

        return 1;
    }
    return;
}

sub check_gcc332_dec {
    my $gccversion = shift;
    my ($gcc_major, $gcc_minor, $gcc_patch) =
      $gccversion =~ /^(\d)\.(\d+)\.(\d+)/;
    my $gccversion_decimal = $gcc_major . $gcc_minor . $gcc_patch;
    if ($gccversion_decimal > 332) {
        return 1;
    }
    return;
}

#using version.pm
sub check_gcc332_ver {
    require version;
    my $v = version::qv(shift);
    return $v > version::qv('3.3.2');
}

use Test::More qw(no_plan);

foreach
  my $v (qw(2.3.4 2.96.4 3.0.0 3.1.0 3.2.0 3.3.0 3.3.1 3.3.2 3 3.3.2 3.2.10))
{
    ok !check_gcc332_if($v),  "if $v";
    ok !check_gcc332_dec($v), "dec $v";
    ok !check_gcc332_ver($v), "ver $v";
}
foreach my $v (qw(3.3.3 3.3.10 3.4.10 4.0.0 4.10.1)) {
    ok check_gcc332_if($v),  "if $v";
    ok check_gcc332_dec($v), "dec $v";
    ok check_gcc332_ver($v), "ver $v";
}

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