xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/warnings/register.pm (revision 0:68f95e015346)
1*0Sstevel@tonic-gatepackage warnings::register ;
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateour $VERSION = '1.00';
4*0Sstevel@tonic-gate
5*0Sstevel@tonic-gate=pod
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gate=head1 NAME
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gatewarnings::register - warnings import function
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gate=head1 SYNOPSIS
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate    use warnings::register ;
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gate=head1 DESCRIPTION
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gateCreate a warnings category with the same name as the current package.
18*0Sstevel@tonic-gate
19*0Sstevel@tonic-gateSee L<perlmodlib/Pragmatic Modules> and L<perllexwarn>.
20*0Sstevel@tonic-gate
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gate=cut
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gaterequire warnings ;
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gatesub mkMask
27*0Sstevel@tonic-gate{
28*0Sstevel@tonic-gate    my ($bit) = @_ ;
29*0Sstevel@tonic-gate    my $mask = "" ;
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate    vec($mask, $bit, 1) = 1 ;
32*0Sstevel@tonic-gate    return $mask ;
33*0Sstevel@tonic-gate}
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gatesub import
36*0Sstevel@tonic-gate{
37*0Sstevel@tonic-gate    shift ;
38*0Sstevel@tonic-gate    my $package = (caller(0))[0] ;
39*0Sstevel@tonic-gate    if (! defined $warnings::Bits{$package}) {
40*0Sstevel@tonic-gate        $warnings::Bits{$package}     = mkMask($warnings::LAST_BIT) ;
41*0Sstevel@tonic-gate        vec($warnings::Bits{'all'}, $warnings::LAST_BIT, 1) = 1 ;
42*0Sstevel@tonic-gate        $warnings::Offsets{$package}  = $warnings::LAST_BIT ++ ;
43*0Sstevel@tonic-gate	foreach my $k (keys %warnings::Bits) {
44*0Sstevel@tonic-gate	    vec($warnings::Bits{$k}, $warnings::LAST_BIT, 1) = 0 ;
45*0Sstevel@tonic-gate	}
46*0Sstevel@tonic-gate        $warnings::DeadBits{$package} = mkMask($warnings::LAST_BIT);
47*0Sstevel@tonic-gate        vec($warnings::DeadBits{'all'}, $warnings::LAST_BIT++, 1) = 1 ;
48*0Sstevel@tonic-gate    }
49*0Sstevel@tonic-gate}
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gate1 ;
52