develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [PATCH B::Deparse] Make warnings handling more robust

Thread Previous
From:
Jarkko Hietaniemi
Date:
July 5, 2001 19:21
Subject:
Re: [PATCH B::Deparse] Make warnings handling more robust
Message ID:
20010705212129.M19034@chaos.wustl.edu
On Thu, Jul 05, 2001 at 06:33:21PM +0100, Robin Houston wrote:
> Abhijit Menon-Sen's mkdir patch caused B::Deparse to break. That was
> my fault: the warnings-handling code had some flaws which were only
> shown up by adding an extra bit to the warnings mask.
> 
> The patch below corrects the problem, I hope.

Thanks, applied.  (Hopefully I didn't misunderstand the discussion
that followed...)

>  .robin.
> 
> --- perl@11026/ext/B/B/Deparse.pm	Mon Jul  2 21:49:08 2001
> +++ bleadperl/ext/B/B/Deparse.pm	Thu Jul  5 18:27:31 2001
> @@ -496,9 +496,15 @@
>      return $self;
>  }
>  
> -sub WARN_MASK () {
> -    # Mask out the bits that C<use vars> uses
> -    $warnings::Bits{all} | $warnings::DeadBits{all};
> +{
> +    # Mask out the bits that L<warnings::register> uses
> +    my $WARN_MASK;
> +    BEGIN {
> +	$WARN_MASK = $warnings::Bits{all} | $warnings::DeadBits{all};
> +    }
> +    sub WARN_MASK () {
> +	return $WARN_MASK;
> +    }
>  }
>  
>  # Initialise the contextual information, either from
> @@ -626,7 +632,7 @@
>  
>  	elsif ($name eq 'warnings') {
>  	    if ($val eq 'none') {
> -		$warning_bits = "\0"x12;
> +		$warning_bits = $warnings::NONE;
>  		next();
>  	    }
>  
> @@ -638,7 +644,7 @@
>  		@names = split/\s+/, $val;
>  	    }
>  
> -	    $warning_bits = "\0"x12 if !defined ($warning_bits);
> +	    $warning_bits = $warnings::NONE if !defined ($warning_bits);
>  	    $warning_bits |= warnings::bits(@names);
>  	}
>  
> @@ -1270,10 +1276,10 @@
>      my $warnings = $op->warnings;
>      my $warning_bits;
>      if ($warnings->isa("B::SPECIAL") && $$warnings == 4) {
> -	$warning_bits = $warnings::Bits{"all"};
> +	$warning_bits = $warnings::Bits{"all"} & WARN_MASK;
>      }
>      elsif ($warnings->isa("B::SPECIAL") && $$warnings == 5) {
> -        $warning_bits = "\0"x12;
> +        $warning_bits = $warnings::NONE;
>      }
>      elsif ($warnings->isa("B::SPECIAL")) {
>  	$warning_bits = undef;
> @@ -2668,7 +2674,7 @@
>      # expression would be parenthesized as well.]
>      #
>      $idx =~ s/^\((.*)\)$/$1/ if $self->{'parens'};
> -    
> +
>      # Hash-element braces will autoquote a bareword inside themselves.
>      # We need to make sure that C<$hash{warn()}> doesn't come out as
>      # C<$hash{warn}>, which has a quite different meaning. Currently

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About