diff options
author | Paul Marquess <paul.marquess@btinternet.com> | 2002-06-20 18:14:12 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-06-20 15:27:18 +0000 |
commit | 6e9af7e4283affa5138ab8f50e01b3144acd68ca (patch) | |
tree | f57e517d5e07f3f5e90b174add6216721208bd2a /lib/warnings.pm | |
parent | 353813d9d162685fa077a818008763d730617d20 (diff) | |
download | perl-6e9af7e4283affa5138ab8f50e01b3144acd68ca.tar.gz |
RE: mixing FATAL and non-FATAL warnings
From: "Paul Marquess" <Paul.Marquess@btinternet.com>
Message-ID: <AIEAJICLCBDNAAOLLOKLOEJAEOAA.Paul.Marquess@btinternet.com>
p4raw-id: //depot/perl@17325
Diffstat (limited to 'lib/warnings.pm')
-rw-r--r-- | lib/warnings.pm | 75 |
1 files changed, 67 insertions, 8 deletions
diff --git a/lib/warnings.pm b/lib/warnings.pm index 5cb6eff2bd..8aa77482b2 100644 --- a/lib/warnings.pm +++ b/lib/warnings.pm @@ -294,17 +294,30 @@ sub Croaker croak @_ ; } -sub bits { - my $mask ; +sub bits +{ + # called from B::Deparse.pm + + push @_, 'all' unless @_; + + my $mask; my $catmask ; my $fatal = 0 ; - foreach my $word (@_) { - if ($word eq 'FATAL') { + my $no_fatal = 0 ; + + foreach my $word ( @_ ) { + if ($word eq 'FATAL') { $fatal = 1; + $no_fatal = 0; + } + elsif ($word eq 'NONFATAL') { + $fatal = 0; + $no_fatal = 1; } elsif ($catmask = $Bits{$word}) { $mask |= $catmask ; $mask |= $DeadBits{$word} if $fatal ; + $mask &= ~($DeadBits{$word}|$All) if $no_fatal ; } else { Croaker("Unknown warnings category '$word'")} @@ -313,24 +326,70 @@ sub bits { return $mask ; } -sub import { +sub import +{ shift; + + my $catmask ; + my $fatal = 0 ; + my $no_fatal = 0 ; + my $mask = ${^WARNING_BITS} ; + if (vec($mask, $Offsets{'all'}, 1)) { $mask |= $Bits{'all'} ; $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); } - ${^WARNING_BITS} = $mask | bits(@_ ? @_ : 'all') ; + + push @_, 'all' unless @_; + + foreach my $word ( @_ ) { + if ($word eq 'FATAL') { + $fatal = 1; + $no_fatal = 0; + } + elsif ($word eq 'NONFATAL') { + $fatal = 0; + $no_fatal = 1; + } + elsif ($catmask = $Bits{$word}) { + $mask |= $catmask ; + $mask |= $DeadBits{$word} if $fatal ; + $mask &= ~($DeadBits{$word}|$All) if $no_fatal ; + } + else + { Croaker("Unknown warnings category '$word'")} + } + + ${^WARNING_BITS} = $mask ; } -sub unimport { +sub unimport +{ shift; + + my $catmask ; my $mask = ${^WARNING_BITS} ; + if (vec($mask, $Offsets{'all'}, 1)) { $mask |= $Bits{'all'} ; $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); } - ${^WARNING_BITS} = $mask & ~ (bits('FATAL' => (@_ ? @_ : 'all')) | $All) ; + + push @_, 'all' unless @_; + + foreach my $word ( @_ ) { + if ($word eq 'FATAL') { + next; + } + elsif ($catmask = $Bits{$word}) { + $mask &= ~($catmask | $DeadBits{$word} | $All); + } + else + { Croaker("Unknown warnings category '$word'")} + } + + ${^WARNING_BITS} = $mask ; } sub __chk |