IO::Socket now sets $!, avoids eval/die (patch from Graham Barr
[p5sagit/p5-mst-13.2.git] / lib / warnings.pm
index e15d364..b952295 100644 (file)
@@ -32,11 +32,12 @@ use Carp ;
 %Bits = (
     'all'              => "\x55\x55\x55\x55\x55\x55\x55\x55\x55", # [0..35]
     'ambiguous'                => "\x00\x00\x00\x00\x01\x00\x00\x00\x00", # [16]
+    'bareword'         => "\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [17]
     'closed'           => "\x04\x00\x00\x00\x00\x00\x00\x00\x00", # [1]
     'closure'          => "\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [27]
     'debugging'                => "\x00\x00\x00\x01\x00\x00\x00\x00\x00", # [12]
-    'deprecated'       => "\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [17]
-    'digit'            => "\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [18]
+    'deprecated'       => "\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [18]
+    'digit'            => "\x00\x00\x00\x00\x40\x00\x00\x00\x00", # [19]
     'exec'             => "\x10\x00\x00\x00\x00\x00\x00\x00\x00", # [2]
     'inplace'          => "\x00\x00\x00\x04\x00\x00\x00\x00\x00", # [13]
     'internal'         => "\x00\x00\x00\x10\x00\x00\x00\x00\x00", # [14]
@@ -44,13 +45,12 @@ use Carp ;
     'misc'             => "\x00\x10\x00\x00\x00\x00\x00\x00\x00", # [6]
     'newline'          => "\x40\x00\x00\x00\x00\x00\x00\x00\x00", # [3]
     'numeric'          => "\x00\x40\x00\x00\x00\x00\x00\x00\x00", # [7]
-    'octal'            => "\x00\x00\x00\x00\x40\x00\x00\x00\x00", # [19]
+    'octal'            => "\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [20]
     'once'             => "\x00\x00\x01\x00\x00\x00\x00\x00\x00", # [8]
     'overflow'         => "\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [28]
-    'parenthesis'      => "\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [20]
+    'parenthesis'      => "\x00\x00\x00\x00\x00\x04\x00\x00\x00", # [21]
     'pipe'             => "\x00\x01\x00\x00\x00\x00\x00\x00\x00", # [4]
     'portable'         => "\x00\x00\x00\x00\x00\x00\x00\x04\x00", # [29]
-    'precedence'       => "\x00\x00\x00\x00\x00\x04\x00\x00\x00", # [21]
     'printf'           => "\x00\x00\x00\x00\x00\x10\x00\x00\x00", # [22]
     'recursion'                => "\x00\x00\x04\x00\x00\x00\x00\x00\x00", # [9]
     'redefine'         => "\x00\x00\x10\x00\x00\x00\x00\x00\x00", # [10]
@@ -72,11 +72,12 @@ use Carp ;
 %DeadBits = (
     'all'              => "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", # [0..35]
     'ambiguous'                => "\x00\x00\x00\x00\x02\x00\x00\x00\x00", # [16]
+    'bareword'         => "\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [17]
     'closed'           => "\x08\x00\x00\x00\x00\x00\x00\x00\x00", # [1]
     'closure'          => "\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [27]
     'debugging'                => "\x00\x00\x00\x02\x00\x00\x00\x00\x00", # [12]
-    'deprecated'       => "\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [17]
-    'digit'            => "\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [18]
+    'deprecated'       => "\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [18]
+    'digit'            => "\x00\x00\x00\x00\x80\x00\x00\x00\x00", # [19]
     'exec'             => "\x20\x00\x00\x00\x00\x00\x00\x00\x00", # [2]
     'inplace'          => "\x00\x00\x00\x08\x00\x00\x00\x00\x00", # [13]
     'internal'         => "\x00\x00\x00\x20\x00\x00\x00\x00\x00", # [14]
@@ -84,13 +85,12 @@ use Carp ;
     'misc'             => "\x00\x20\x00\x00\x00\x00\x00\x00\x00", # [6]
     'newline'          => "\x80\x00\x00\x00\x00\x00\x00\x00\x00", # [3]
     'numeric'          => "\x00\x80\x00\x00\x00\x00\x00\x00\x00", # [7]
-    'octal'            => "\x00\x00\x00\x00\x80\x00\x00\x00\x00", # [19]
+    'octal'            => "\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [20]
     'once'             => "\x00\x00\x02\x00\x00\x00\x00\x00\x00", # [8]
     'overflow'         => "\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [28]
-    'parenthesis'      => "\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [20]
+    'parenthesis'      => "\x00\x00\x00\x00\x00\x08\x00\x00\x00", # [21]
     'pipe'             => "\x00\x02\x00\x00\x00\x00\x00\x00\x00", # [4]
     'portable'         => "\x00\x00\x00\x00\x00\x00\x00\x08\x00", # [29]
-    'precedence'       => "\x00\x00\x00\x00\x00\x08\x00\x00\x00", # [21]
     'printf'           => "\x00\x00\x00\x00\x00\x20\x00\x00\x00", # [22]
     'recursion'                => "\x00\x00\x08\x00\x00\x00\x00\x00\x00", # [9]
     'redefine'         => "\x00\x00\x20\x00\x00\x00\x00\x00\x00", # [10]
@@ -115,14 +115,15 @@ sub bits {
     my $catmask ;
     my $fatal = 0 ;
     foreach my $word (@_) {
-       if  ($word eq 'FATAL')
-         { $fatal = 1 }
-       elsif ($catmask = $Bits{$word}) {
-         $mask |= $catmask ;
-         $mask |= $DeadBits{$word} if $fatal ;
+       if  ($word eq 'FATAL') {
+           $fatal = 1;
+       }
+       else {
+           if ($catmask = $Bits{$word}) {
+               $mask |= $catmask ;
+               $mask |= $DeadBits{$word} if $fatal ;
+           }
        }
-       else
-         { croak "unknown warning category '$word'" }
     }
 
     return $mask ;
@@ -130,12 +131,12 @@ sub bits {
 
 sub import {
     shift;
-    ${^Warnings} |= bits(@_ ? @_ : 'all') ;
+    ${^WARNING_BITS} |= bits(@_ ? @_ : 'all') ;
 }
 
 sub unimport {
     shift;
-    ${^Warnings} &= ~ bits(@_ ? @_ : 'all') ;
+    ${^WARNING_BITS} &= ~ bits(@_ ? @_ : 'all') ;
 }
 
 sub enabled
@@ -143,7 +144,7 @@ sub enabled
     my $string = shift ;
 
     return 1
-       if $bits{$string} && ${^Warnings} & $bits{$string} ;
+       if $bits{$string} && ${^WARNING_BITS} & $bits{$string} ;
    
     return 0 ; 
 }