1*0Sstevel@tonic-gate 2*0Sstevel@tonic-gate# !!!!!!! DO NOT EDIT THIS FILE !!!!!!! 3*0Sstevel@tonic-gate# This file was created by warnings.pl 4*0Sstevel@tonic-gate# Any changes made here will be lost. 5*0Sstevel@tonic-gate# 6*0Sstevel@tonic-gate 7*0Sstevel@tonic-gatepackage warnings; 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gateour $VERSION = '1.03'; 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gate=head1 NAME 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gatewarnings - Perl pragma to control optional warnings 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gate=head1 SYNOPSIS 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gate use warnings; 18*0Sstevel@tonic-gate no warnings; 19*0Sstevel@tonic-gate 20*0Sstevel@tonic-gate use warnings "all"; 21*0Sstevel@tonic-gate no warnings "all"; 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate use warnings::register; 24*0Sstevel@tonic-gate if (warnings::enabled()) { 25*0Sstevel@tonic-gate warnings::warn("some warning"); 26*0Sstevel@tonic-gate } 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate if (warnings::enabled("void")) { 29*0Sstevel@tonic-gate warnings::warn("void", "some warning"); 30*0Sstevel@tonic-gate } 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate if (warnings::enabled($object)) { 33*0Sstevel@tonic-gate warnings::warn($object, "some warning"); 34*0Sstevel@tonic-gate } 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate warnings::warnif("some warning"); 37*0Sstevel@tonic-gate warnings::warnif("void", "some warning"); 38*0Sstevel@tonic-gate warnings::warnif($object, "some warning"); 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate=head1 DESCRIPTION 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gateThe C<warnings> pragma is a replacement for the command line flag C<-w>, 43*0Sstevel@tonic-gatebut the pragma is limited to the enclosing block, while the flag is global. 44*0Sstevel@tonic-gateSee L<perllexwarn> for more information. 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gateIf no import list is supplied, all possible warnings are either enabled 47*0Sstevel@tonic-gateor disabled. 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gateA number of functions are provided to assist module authors. 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate=over 4 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate=item use warnings::register 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gateCreates a new warnings category with the same name as the package where 56*0Sstevel@tonic-gatethe call to the pragma is used. 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate=item warnings::enabled() 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gateUse the warnings category with the same name as the current package. 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gateReturn TRUE if that warnings category is enabled in the calling module. 63*0Sstevel@tonic-gateOtherwise returns FALSE. 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate=item warnings::enabled($category) 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gateReturn TRUE if the warnings category, C<$category>, is enabled in the 68*0Sstevel@tonic-gatecalling module. 69*0Sstevel@tonic-gateOtherwise returns FALSE. 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate=item warnings::enabled($object) 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gateUse the name of the class for the object reference, C<$object>, as the 74*0Sstevel@tonic-gatewarnings category. 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gateReturn TRUE if that warnings category is enabled in the first scope 77*0Sstevel@tonic-gatewhere the object is used. 78*0Sstevel@tonic-gateOtherwise returns FALSE. 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gate=item warnings::warn($message) 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gatePrint C<$message> to STDERR. 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gateUse the warnings category with the same name as the current package. 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gateIf that warnings category has been set to "FATAL" in the calling module 87*0Sstevel@tonic-gatethen die. Otherwise return. 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate=item warnings::warn($category, $message) 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gatePrint C<$message> to STDERR. 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gateIf the warnings category, C<$category>, has been set to "FATAL" in the 94*0Sstevel@tonic-gatecalling module then die. Otherwise return. 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate=item warnings::warn($object, $message) 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gatePrint C<$message> to STDERR. 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gateUse the name of the class for the object reference, C<$object>, as the 101*0Sstevel@tonic-gatewarnings category. 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gateIf that warnings category has been set to "FATAL" in the scope where C<$object> 104*0Sstevel@tonic-gateis first used then die. Otherwise return. 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate=item warnings::warnif($message) 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gateEquivalent to: 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate if (warnings::enabled()) 112*0Sstevel@tonic-gate { warnings::warn($message) } 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate=item warnings::warnif($category, $message) 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gateEquivalent to: 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate if (warnings::enabled($category)) 119*0Sstevel@tonic-gate { warnings::warn($category, $message) } 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate=item warnings::warnif($object, $message) 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gateEquivalent to: 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate if (warnings::enabled($object)) 126*0Sstevel@tonic-gate { warnings::warn($object, $message) } 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate=back 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gateSee L<perlmodlib/Pragmatic Modules> and L<perllexwarn>. 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate=cut 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gateuse Carp (); 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gateour %Offsets = ( 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate # Warnings Categories added in Perl 5.008 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate 'all' => 0, 141*0Sstevel@tonic-gate 'closure' => 2, 142*0Sstevel@tonic-gate 'deprecated' => 4, 143*0Sstevel@tonic-gate 'exiting' => 6, 144*0Sstevel@tonic-gate 'glob' => 8, 145*0Sstevel@tonic-gate 'io' => 10, 146*0Sstevel@tonic-gate 'closed' => 12, 147*0Sstevel@tonic-gate 'exec' => 14, 148*0Sstevel@tonic-gate 'layer' => 16, 149*0Sstevel@tonic-gate 'newline' => 18, 150*0Sstevel@tonic-gate 'pipe' => 20, 151*0Sstevel@tonic-gate 'unopened' => 22, 152*0Sstevel@tonic-gate 'misc' => 24, 153*0Sstevel@tonic-gate 'numeric' => 26, 154*0Sstevel@tonic-gate 'once' => 28, 155*0Sstevel@tonic-gate 'overflow' => 30, 156*0Sstevel@tonic-gate 'pack' => 32, 157*0Sstevel@tonic-gate 'portable' => 34, 158*0Sstevel@tonic-gate 'recursion' => 36, 159*0Sstevel@tonic-gate 'redefine' => 38, 160*0Sstevel@tonic-gate 'regexp' => 40, 161*0Sstevel@tonic-gate 'severe' => 42, 162*0Sstevel@tonic-gate 'debugging' => 44, 163*0Sstevel@tonic-gate 'inplace' => 46, 164*0Sstevel@tonic-gate 'internal' => 48, 165*0Sstevel@tonic-gate 'malloc' => 50, 166*0Sstevel@tonic-gate 'signal' => 52, 167*0Sstevel@tonic-gate 'substr' => 54, 168*0Sstevel@tonic-gate 'syntax' => 56, 169*0Sstevel@tonic-gate 'ambiguous' => 58, 170*0Sstevel@tonic-gate 'bareword' => 60, 171*0Sstevel@tonic-gate 'digit' => 62, 172*0Sstevel@tonic-gate 'parenthesis' => 64, 173*0Sstevel@tonic-gate 'precedence' => 66, 174*0Sstevel@tonic-gate 'printf' => 68, 175*0Sstevel@tonic-gate 'prototype' => 70, 176*0Sstevel@tonic-gate 'qw' => 72, 177*0Sstevel@tonic-gate 'reserved' => 74, 178*0Sstevel@tonic-gate 'semicolon' => 76, 179*0Sstevel@tonic-gate 'taint' => 78, 180*0Sstevel@tonic-gate 'threads' => 80, 181*0Sstevel@tonic-gate 'uninitialized' => 82, 182*0Sstevel@tonic-gate 'unpack' => 84, 183*0Sstevel@tonic-gate 'untie' => 86, 184*0Sstevel@tonic-gate 'utf8' => 88, 185*0Sstevel@tonic-gate 'void' => 90, 186*0Sstevel@tonic-gate 'y2k' => 92, 187*0Sstevel@tonic-gate ); 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gateour %Bits = ( 190*0Sstevel@tonic-gate 'all' => "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15", # [0..46] 191*0Sstevel@tonic-gate 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [29] 192*0Sstevel@tonic-gate 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00", # [30] 193*0Sstevel@tonic-gate 'closed' => "\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] 194*0Sstevel@tonic-gate 'closure' => "\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1] 195*0Sstevel@tonic-gate 'debugging' => "\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00", # [22] 196*0Sstevel@tonic-gate 'deprecated' => "\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2] 197*0Sstevel@tonic-gate 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00", # [31] 198*0Sstevel@tonic-gate 'exec' => "\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] 199*0Sstevel@tonic-gate 'exiting' => "\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] 200*0Sstevel@tonic-gate 'glob' => "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] 201*0Sstevel@tonic-gate 'inplace' => "\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00", # [23] 202*0Sstevel@tonic-gate 'internal' => "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00", # [24] 203*0Sstevel@tonic-gate 'io' => "\x00\x54\x55\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11] 204*0Sstevel@tonic-gate 'layer' => "\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] 205*0Sstevel@tonic-gate 'malloc' => "\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00", # [25] 206*0Sstevel@tonic-gate 'misc' => "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00", # [12] 207*0Sstevel@tonic-gate 'newline' => "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] 208*0Sstevel@tonic-gate 'numeric' => "\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00", # [13] 209*0Sstevel@tonic-gate 'once' => "\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00", # [14] 210*0Sstevel@tonic-gate 'overflow' => "\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00", # [15] 211*0Sstevel@tonic-gate 'pack' => "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", # [16] 212*0Sstevel@tonic-gate 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [32] 213*0Sstevel@tonic-gate 'pipe' => "\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10] 214*0Sstevel@tonic-gate 'portable' => "\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00", # [17] 215*0Sstevel@tonic-gate 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00", # [33] 216*0Sstevel@tonic-gate 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00", # [34] 217*0Sstevel@tonic-gate 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00", # [35] 218*0Sstevel@tonic-gate 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00", # [36] 219*0Sstevel@tonic-gate 'recursion' => "\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00", # [18] 220*0Sstevel@tonic-gate 'redefine' => "\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00", # [19] 221*0Sstevel@tonic-gate 'regexp' => "\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00", # [20] 222*0Sstevel@tonic-gate 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00", # [37] 223*0Sstevel@tonic-gate 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00", # [38] 224*0Sstevel@tonic-gate 'severe' => "\x00\x00\x00\x00\x00\x54\x05\x00\x00\x00\x00\x00", # [21..25] 225*0Sstevel@tonic-gate 'signal' => "\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00", # [26] 226*0Sstevel@tonic-gate 'substr' => "\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00", # [27] 227*0Sstevel@tonic-gate 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\x55\x55\x15\x00\x00", # [28..38] 228*0Sstevel@tonic-gate 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [39] 229*0Sstevel@tonic-gate 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [40] 230*0Sstevel@tonic-gate 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00", # [41] 231*0Sstevel@tonic-gate 'unopened' => "\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11] 232*0Sstevel@tonic-gate 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00", # [42] 233*0Sstevel@tonic-gate 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [43] 234*0Sstevel@tonic-gate 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [44] 235*0Sstevel@tonic-gate 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", # [45] 236*0Sstevel@tonic-gate 'y2k' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [46] 237*0Sstevel@tonic-gate ); 238*0Sstevel@tonic-gate 239*0Sstevel@tonic-gateour %DeadBits = ( 240*0Sstevel@tonic-gate 'all' => "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\x2a", # [0..46] 241*0Sstevel@tonic-gate 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [29] 242*0Sstevel@tonic-gate 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00", # [30] 243*0Sstevel@tonic-gate 'closed' => "\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] 244*0Sstevel@tonic-gate 'closure' => "\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [1] 245*0Sstevel@tonic-gate 'debugging' => "\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00", # [22] 246*0Sstevel@tonic-gate 'deprecated' => "\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [2] 247*0Sstevel@tonic-gate 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00", # [31] 248*0Sstevel@tonic-gate 'exec' => "\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] 249*0Sstevel@tonic-gate 'exiting' => "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] 250*0Sstevel@tonic-gate 'glob' => "\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] 251*0Sstevel@tonic-gate 'inplace' => "\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00", # [23] 252*0Sstevel@tonic-gate 'internal' => "\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00", # [24] 253*0Sstevel@tonic-gate 'io' => "\x00\xa8\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [5..11] 254*0Sstevel@tonic-gate 'layer' => "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] 255*0Sstevel@tonic-gate 'malloc' => "\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00", # [25] 256*0Sstevel@tonic-gate 'misc' => "\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", # [12] 257*0Sstevel@tonic-gate 'newline' => "\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] 258*0Sstevel@tonic-gate 'numeric' => "\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00", # [13] 259*0Sstevel@tonic-gate 'once' => "\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00", # [14] 260*0Sstevel@tonic-gate 'overflow' => "\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00", # [15] 261*0Sstevel@tonic-gate 'pack' => "\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", # [16] 262*0Sstevel@tonic-gate 'parenthesis' => "\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [32] 263*0Sstevel@tonic-gate 'pipe' => "\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [10] 264*0Sstevel@tonic-gate 'portable' => "\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00", # [17] 265*0Sstevel@tonic-gate 'precedence' => "\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00", # [33] 266*0Sstevel@tonic-gate 'printf' => "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00", # [34] 267*0Sstevel@tonic-gate 'prototype' => "\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00", # [35] 268*0Sstevel@tonic-gate 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00", # [36] 269*0Sstevel@tonic-gate 'recursion' => "\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00", # [18] 270*0Sstevel@tonic-gate 'redefine' => "\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00", # [19] 271*0Sstevel@tonic-gate 'regexp' => "\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00", # [20] 272*0Sstevel@tonic-gate 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00", # [37] 273*0Sstevel@tonic-gate 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00", # [38] 274*0Sstevel@tonic-gate 'severe' => "\x00\x00\x00\x00\x00\xa8\x0a\x00\x00\x00\x00\x00", # [21..25] 275*0Sstevel@tonic-gate 'signal' => "\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00", # [26] 276*0Sstevel@tonic-gate 'substr' => "\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00", # [27] 277*0Sstevel@tonic-gate 'syntax' => "\x00\x00\x00\x00\x00\x00\x00\xaa\xaa\x2a\x00\x00", # [28..38] 278*0Sstevel@tonic-gate 'taint' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [39] 279*0Sstevel@tonic-gate 'threads' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [40] 280*0Sstevel@tonic-gate 'uninitialized' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00", # [41] 281*0Sstevel@tonic-gate 'unopened' => "\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [11] 282*0Sstevel@tonic-gate 'unpack' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00", # [42] 283*0Sstevel@tonic-gate 'untie' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [43] 284*0Sstevel@tonic-gate 'utf8' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [44] 285*0Sstevel@tonic-gate 'void' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", # [45] 286*0Sstevel@tonic-gate 'y2k' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [46] 287*0Sstevel@tonic-gate ); 288*0Sstevel@tonic-gate 289*0Sstevel@tonic-gate$NONE = "\0\0\0\0\0\0\0\0\0\0\0\0"; 290*0Sstevel@tonic-gate$LAST_BIT = 94 ; 291*0Sstevel@tonic-gate$BYTES = 12 ; 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate$All = "" ; vec($All, $Offsets{'all'}, 2) = 3 ; 294*0Sstevel@tonic-gate 295*0Sstevel@tonic-gatesub Croaker 296*0Sstevel@tonic-gate{ 297*0Sstevel@tonic-gate delete $Carp::CarpInternal{'warnings'}; 298*0Sstevel@tonic-gate Carp::croak(@_); 299*0Sstevel@tonic-gate} 300*0Sstevel@tonic-gate 301*0Sstevel@tonic-gatesub bits 302*0Sstevel@tonic-gate{ 303*0Sstevel@tonic-gate # called from B::Deparse.pm 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate push @_, 'all' unless @_; 306*0Sstevel@tonic-gate 307*0Sstevel@tonic-gate my $mask; 308*0Sstevel@tonic-gate my $catmask ; 309*0Sstevel@tonic-gate my $fatal = 0 ; 310*0Sstevel@tonic-gate my $no_fatal = 0 ; 311*0Sstevel@tonic-gate 312*0Sstevel@tonic-gate foreach my $word ( @_ ) { 313*0Sstevel@tonic-gate if ($word eq 'FATAL') { 314*0Sstevel@tonic-gate $fatal = 1; 315*0Sstevel@tonic-gate $no_fatal = 0; 316*0Sstevel@tonic-gate } 317*0Sstevel@tonic-gate elsif ($word eq 'NONFATAL') { 318*0Sstevel@tonic-gate $fatal = 0; 319*0Sstevel@tonic-gate $no_fatal = 1; 320*0Sstevel@tonic-gate } 321*0Sstevel@tonic-gate elsif ($catmask = $Bits{$word}) { 322*0Sstevel@tonic-gate $mask |= $catmask ; 323*0Sstevel@tonic-gate $mask |= $DeadBits{$word} if $fatal ; 324*0Sstevel@tonic-gate $mask &= ~($DeadBits{$word}|$All) if $no_fatal ; 325*0Sstevel@tonic-gate } 326*0Sstevel@tonic-gate else 327*0Sstevel@tonic-gate { Croaker("Unknown warnings category '$word'")} 328*0Sstevel@tonic-gate } 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate return $mask ; 331*0Sstevel@tonic-gate} 332*0Sstevel@tonic-gate 333*0Sstevel@tonic-gatesub import 334*0Sstevel@tonic-gate{ 335*0Sstevel@tonic-gate shift; 336*0Sstevel@tonic-gate 337*0Sstevel@tonic-gate my $catmask ; 338*0Sstevel@tonic-gate my $fatal = 0 ; 339*0Sstevel@tonic-gate my $no_fatal = 0 ; 340*0Sstevel@tonic-gate 341*0Sstevel@tonic-gate my $mask = ${^WARNING_BITS} ; 342*0Sstevel@tonic-gate 343*0Sstevel@tonic-gate if (vec($mask, $Offsets{'all'}, 1)) { 344*0Sstevel@tonic-gate $mask |= $Bits{'all'} ; 345*0Sstevel@tonic-gate $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); 346*0Sstevel@tonic-gate } 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gate push @_, 'all' unless @_; 349*0Sstevel@tonic-gate 350*0Sstevel@tonic-gate foreach my $word ( @_ ) { 351*0Sstevel@tonic-gate if ($word eq 'FATAL') { 352*0Sstevel@tonic-gate $fatal = 1; 353*0Sstevel@tonic-gate $no_fatal = 0; 354*0Sstevel@tonic-gate } 355*0Sstevel@tonic-gate elsif ($word eq 'NONFATAL') { 356*0Sstevel@tonic-gate $fatal = 0; 357*0Sstevel@tonic-gate $no_fatal = 1; 358*0Sstevel@tonic-gate } 359*0Sstevel@tonic-gate elsif ($catmask = $Bits{$word}) { 360*0Sstevel@tonic-gate $mask |= $catmask ; 361*0Sstevel@tonic-gate $mask |= $DeadBits{$word} if $fatal ; 362*0Sstevel@tonic-gate $mask &= ~($DeadBits{$word}|$All) if $no_fatal ; 363*0Sstevel@tonic-gate } 364*0Sstevel@tonic-gate else 365*0Sstevel@tonic-gate { Croaker("Unknown warnings category '$word'")} 366*0Sstevel@tonic-gate } 367*0Sstevel@tonic-gate 368*0Sstevel@tonic-gate ${^WARNING_BITS} = $mask ; 369*0Sstevel@tonic-gate} 370*0Sstevel@tonic-gate 371*0Sstevel@tonic-gatesub unimport 372*0Sstevel@tonic-gate{ 373*0Sstevel@tonic-gate shift; 374*0Sstevel@tonic-gate 375*0Sstevel@tonic-gate my $catmask ; 376*0Sstevel@tonic-gate my $mask = ${^WARNING_BITS} ; 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gate if (vec($mask, $Offsets{'all'}, 1)) { 379*0Sstevel@tonic-gate $mask |= $Bits{'all'} ; 380*0Sstevel@tonic-gate $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1); 381*0Sstevel@tonic-gate } 382*0Sstevel@tonic-gate 383*0Sstevel@tonic-gate push @_, 'all' unless @_; 384*0Sstevel@tonic-gate 385*0Sstevel@tonic-gate foreach my $word ( @_ ) { 386*0Sstevel@tonic-gate if ($word eq 'FATAL') { 387*0Sstevel@tonic-gate next; 388*0Sstevel@tonic-gate } 389*0Sstevel@tonic-gate elsif ($catmask = $Bits{$word}) { 390*0Sstevel@tonic-gate $mask &= ~($catmask | $DeadBits{$word} | $All); 391*0Sstevel@tonic-gate } 392*0Sstevel@tonic-gate else 393*0Sstevel@tonic-gate { Croaker("Unknown warnings category '$word'")} 394*0Sstevel@tonic-gate } 395*0Sstevel@tonic-gate 396*0Sstevel@tonic-gate ${^WARNING_BITS} = $mask ; 397*0Sstevel@tonic-gate} 398*0Sstevel@tonic-gate 399*0Sstevel@tonic-gatesub __chk 400*0Sstevel@tonic-gate{ 401*0Sstevel@tonic-gate my $category ; 402*0Sstevel@tonic-gate my $offset ; 403*0Sstevel@tonic-gate my $isobj = 0 ; 404*0Sstevel@tonic-gate 405*0Sstevel@tonic-gate if (@_) { 406*0Sstevel@tonic-gate # check the category supplied. 407*0Sstevel@tonic-gate $category = shift ; 408*0Sstevel@tonic-gate if (ref $category) { 409*0Sstevel@tonic-gate Croaker ("not an object") 410*0Sstevel@tonic-gate if $category !~ /^([^=]+)=/ ; 411*0Sstevel@tonic-gate $category = $1 ; 412*0Sstevel@tonic-gate $isobj = 1 ; 413*0Sstevel@tonic-gate } 414*0Sstevel@tonic-gate $offset = $Offsets{$category}; 415*0Sstevel@tonic-gate Croaker("Unknown warnings category '$category'") 416*0Sstevel@tonic-gate unless defined $offset; 417*0Sstevel@tonic-gate } 418*0Sstevel@tonic-gate else { 419*0Sstevel@tonic-gate $category = (caller(1))[0] ; 420*0Sstevel@tonic-gate $offset = $Offsets{$category}; 421*0Sstevel@tonic-gate Croaker("package '$category' not registered for warnings") 422*0Sstevel@tonic-gate unless defined $offset ; 423*0Sstevel@tonic-gate } 424*0Sstevel@tonic-gate 425*0Sstevel@tonic-gate my $this_pkg = (caller(1))[0] ; 426*0Sstevel@tonic-gate my $i = 2 ; 427*0Sstevel@tonic-gate my $pkg ; 428*0Sstevel@tonic-gate 429*0Sstevel@tonic-gate if ($isobj) { 430*0Sstevel@tonic-gate while (do { { package DB; $pkg = (caller($i++))[0] } } ) { 431*0Sstevel@tonic-gate last unless @DB::args && $DB::args[0] =~ /^$category=/ ; 432*0Sstevel@tonic-gate } 433*0Sstevel@tonic-gate $i -= 2 ; 434*0Sstevel@tonic-gate } 435*0Sstevel@tonic-gate else { 436*0Sstevel@tonic-gate for ($i = 2 ; $pkg = (caller($i))[0] ; ++ $i) { 437*0Sstevel@tonic-gate last if $pkg ne $this_pkg ; 438*0Sstevel@tonic-gate } 439*0Sstevel@tonic-gate $i = 2 440*0Sstevel@tonic-gate if !$pkg || $pkg eq $this_pkg ; 441*0Sstevel@tonic-gate } 442*0Sstevel@tonic-gate 443*0Sstevel@tonic-gate my $callers_bitmask = (caller($i))[9] ; 444*0Sstevel@tonic-gate return ($callers_bitmask, $offset, $i) ; 445*0Sstevel@tonic-gate} 446*0Sstevel@tonic-gate 447*0Sstevel@tonic-gatesub enabled 448*0Sstevel@tonic-gate{ 449*0Sstevel@tonic-gate Croaker("Usage: warnings::enabled([category])") 450*0Sstevel@tonic-gate unless @_ == 1 || @_ == 0 ; 451*0Sstevel@tonic-gate 452*0Sstevel@tonic-gate my ($callers_bitmask, $offset, $i) = __chk(@_) ; 453*0Sstevel@tonic-gate 454*0Sstevel@tonic-gate return 0 unless defined $callers_bitmask ; 455*0Sstevel@tonic-gate return vec($callers_bitmask, $offset, 1) || 456*0Sstevel@tonic-gate vec($callers_bitmask, $Offsets{'all'}, 1) ; 457*0Sstevel@tonic-gate} 458*0Sstevel@tonic-gate 459*0Sstevel@tonic-gate 460*0Sstevel@tonic-gatesub warn 461*0Sstevel@tonic-gate{ 462*0Sstevel@tonic-gate Croaker("Usage: warnings::warn([category,] 'message')") 463*0Sstevel@tonic-gate unless @_ == 2 || @_ == 1 ; 464*0Sstevel@tonic-gate 465*0Sstevel@tonic-gate my $message = pop ; 466*0Sstevel@tonic-gate my ($callers_bitmask, $offset, $i) = __chk(@_) ; 467*0Sstevel@tonic-gate Carp::croak($message) 468*0Sstevel@tonic-gate if vec($callers_bitmask, $offset+1, 1) || 469*0Sstevel@tonic-gate vec($callers_bitmask, $Offsets{'all'}+1, 1) ; 470*0Sstevel@tonic-gate Carp::carp($message) ; 471*0Sstevel@tonic-gate} 472*0Sstevel@tonic-gate 473*0Sstevel@tonic-gatesub warnif 474*0Sstevel@tonic-gate{ 475*0Sstevel@tonic-gate Croaker("Usage: warnings::warnif([category,] 'message')") 476*0Sstevel@tonic-gate unless @_ == 2 || @_ == 1 ; 477*0Sstevel@tonic-gate 478*0Sstevel@tonic-gate my $message = pop ; 479*0Sstevel@tonic-gate my ($callers_bitmask, $offset, $i) = __chk(@_) ; 480*0Sstevel@tonic-gate 481*0Sstevel@tonic-gate return 482*0Sstevel@tonic-gate unless defined $callers_bitmask && 483*0Sstevel@tonic-gate (vec($callers_bitmask, $offset, 1) || 484*0Sstevel@tonic-gate vec($callers_bitmask, $Offsets{'all'}, 1)) ; 485*0Sstevel@tonic-gate 486*0Sstevel@tonic-gate Carp::croak($message) 487*0Sstevel@tonic-gate if vec($callers_bitmask, $offset+1, 1) || 488*0Sstevel@tonic-gate vec($callers_bitmask, $Offsets{'all'}+1, 1) ; 489*0Sstevel@tonic-gate 490*0Sstevel@tonic-gate Carp::carp($message) ; 491*0Sstevel@tonic-gate} 492*0Sstevel@tonic-gate 493*0Sstevel@tonic-gate1; 494