8 sub DEFAULT_ON () { 1 }
9 sub DEFAULT_OFF () { 2 }
12 'unsafe' => { 'untie' => DEFAULT_OFF,
13 'substr' => DEFAULT_OFF,
14 'taint' => DEFAULT_OFF,
15 'signal' => DEFAULT_OFF,
16 'closure' => DEFAULT_OFF,
17 'utf8' => DEFAULT_OFF,
19 'io' => { 'pipe' => DEFAULT_OFF,
20 'unopened' => DEFAULT_OFF,
21 'closed' => DEFAULT_OFF,
22 'newline' => DEFAULT_OFF,
23 'exec' => DEFAULT_OFF,
24 #'wr in in file'=> DEFAULT_OFF,
26 'syntax' => { 'ambiguous' => DEFAULT_OFF,
27 'semicolon' => DEFAULT_OFF,
28 'precedence' => DEFAULT_OFF,
29 'reserved' => DEFAULT_OFF,
30 'octal' => DEFAULT_OFF,
31 'parenthesis' => DEFAULT_OFF,
32 'deprecated' => DEFAULT_OFF,
33 'printf' => DEFAULT_OFF,
35 'severe' => { 'inplace' => DEFAULT_ON,
36 'internal' => DEFAULT_ON,
37 'debugging' => DEFAULT_ON,
39 'void' => DEFAULT_OFF,
40 'recursion' => DEFAULT_OFF,
41 'redefine' => DEFAULT_OFF,
42 'numeric' => DEFAULT_OFF,
43 'uninitialized'=> DEFAULT_OFF,
44 'once' => DEFAULT_OFF,
45 'misc' => DEFAULT_OFF,
46 #'default' => DEFAULT_ON,
50 ###########################################################################
53 $t .= "\t" x ($l - (length($t) + 1) / 8);
57 ###########################################################################
69 foreach $k (sort keys %$tre) {
71 die "duplicate key $k\n" if defined $list{$k} ;
72 $Value{$index} = uc $k ;
73 push @{ $list{$k} }, $index ++ ;
75 { push (@{ $list{$k} }, walk ($v)) }
76 push @list, @{ $list{$k} } ;
82 ###########################################################################
91 for ($i = 1 ; $i < @a; ++ $i) {
93 if $a[$i] == $a[$i - 1] + 1 && $a[$i] + 1 == $a[$i + 1] ;
96 my $out = join(",",@out);
98 $out =~ s/,(\.\.,)+/../g ;
102 ###########################################################################
107 my $mask = "\x00" x $max ;
111 vec($mask, $_, 1) = 1 ;
114 #$string = unpack("H$max", $mask) ;
115 #$string =~ s/(..)/\x$1/g;
116 foreach (unpack("C*", $mask)) {
117 $string .= '\x' . sprintf("%2.2x", $_) ;
122 ###########################################################################
126 #unlink "lib/warning.pm";
127 open(WARN, ">warning.h") || die "Can't create warning.h: $!\n";
128 open(PM, ">lib/warning.pm") || die "Can't create lib/warning.pm: $!\n";
131 /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
132 This file is built by warning.pl
133 Any changes made here will be lost!
137 #define Off(x) ((x) / 8)
138 #define Bit(x) (1 << ((x) % 8))
139 #define IsSet(a, x) ((a)[Off(x)] & Bit(x))
142 #define G_WARN_OFF 0 /* $^W == 0 */
143 #define G_WARN_ON 1 /* -w flag and $^W != 0 */
144 #define G_WARN_ALL_ON 2 /* -W flag */
145 #define G_WARN_ALL_OFF 4 /* -X flag */
146 #define G_WARN_ONCE 8 /* set if 'once' ever enabled */
147 #define G_WARN_ALL_MASK (G_WARN_ALL_ON|G_WARN_ALL_OFF)
149 #define WARN_STD Nullsv
150 #define WARN_ALL (&PL_sv_yes) /* use warning 'all' */
151 #define WARN_NONE (&PL_sv_no) /* no warning 'all' */
153 #define specialWARN(x) ((x) == WARN_STD || (x) == WARN_ALL || \
157 ( ! specialWARN(PL_curcop->cop_warnings) && \
158 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x+1))
161 ( (PL_curcop->cop_warnings != WARN_STD && \
162 PL_curcop->cop_warnings != WARN_NONE && \
163 (PL_curcop->cop_warnings == WARN_ALL || \
164 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) ) ) \
165 || (PL_curcop->cop_warnings == WARN_STD && PL_dowarn & G_WARN_ON) )
167 #define ckWARN2(x,y) \
168 ( (PL_curcop->cop_warnings != WARN_STD && \
169 PL_curcop->cop_warnings != WARN_NONE && \
170 (PL_curcop->cop_warnings == WARN_ALL || \
171 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) || \
172 IsSet(SvPVX(PL_curcop->cop_warnings), 2*y) ) ) \
173 || (PL_curcop->cop_warnings == WARN_STD && PL_dowarn & G_WARN_ON) )
175 #define ckWARN_d(x) \
176 (PL_curcop->cop_warnings == WARN_STD || \
177 PL_curcop->cop_warnings == WARN_ALL || \
178 (PL_curcop->cop_warnings != WARN_NONE && \
179 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) ) )
181 #define ckWARN2_d(x,y) \
182 (PL_curcop->cop_warnings == WARN_STD || \
183 PL_curcop->cop_warnings == WARN_ALL || \
184 (PL_curcop->cop_warnings != WARN_NONE && \
185 (IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) || \
186 IsSet(SvPVX(PL_curcop->cop_warnings), 2*y) ) ) )
189 #define isLEXWARN_on (PL_curcop->cop_warnings != WARN_STD)
190 #define isLEXWARN_off (PL_curcop->cop_warnings == WARN_STD)
191 #define isWARN_ONCE (PL_dowarn & (G_WARN_ON|G_WARN_ONCE))
192 #define isWARN_on(c,x) (IsSet(SvPVX(c), 2*(x)))
198 @{ $list{"all"} } = walk ($tree) ;
201 my $warn_size = int($index / 8) + ($index % 8 != 0) ;
204 foreach $k (sort { $a <=> $b } keys %Value) {
205 print WARN tab(5, "#define WARN_$Value{$k}"), "$k\n" ;
209 print WARN tab(5, '#define WARNsize'), "$warn_size\n" ;
210 #print WARN tab(5, '#define WARN_ALLstring'), '"', ('\377' x $warn_size) , "\"\n" ;
211 print WARN tab(5, '#define WARN_ALLstring'), '"', ('\125' x $warn_size) , "\"\n" ;
212 print WARN tab(5, '#define WARN_NONEstring'), '"', ('\0' x $warn_size) , "\"\n" ;
216 /* end of file warning.h */
223 last if /^KEYWORDS$/ ;
227 $list{'all'} = [ 0 .. 8 * ($warn_size/2) - 1 ] ;
228 print PM "%Bits = (\n" ;
229 foreach $k (sort keys %list) {
232 my @list = sort { $a <=> $b } @$v ;
234 print PM tab(4, " '$k'"), '=> "',
235 # mkHex($warn_size, @list),
236 mkHex($warn_size, map $_ * 2 , @list),
237 '", # [', mkRange(@list), "]\n" ;
242 print PM "%DeadBits = (\n" ;
243 foreach $k (sort keys %list) {
246 my @list = sort { $a <=> $b } @$v ;
248 print PM tab(4, " '$k'"), '=> "',
249 # mkHex($warn_size, @list),
250 mkHex($warn_size, map $_ * 2 + 1 , @list),
251 '", # [', mkRange(@list), "]\n" ;
263 # This file was created by warning.pl
264 # Any changes made here will be lost.
271 warning - Perl pragma to control optional warnings
283 If no import list is supplied, all possible warnings are either enabled
286 See L<perlmod/Pragmatic Modules> and L<perllexwarn>.
299 foreach my $word (@_) {
300 if ($word eq 'FATAL')
302 elsif ($catmask = $Bits{$word}) {
304 $mask |= $DeadBits{$word} if $fatal ;
307 { croak "unknown warning category '$word'" }
315 $^B |= bits(@_ ? @_ : 'all') ;
320 $^B &= ~ bits(@_ ? @_ : 'all') ;
327 my $bitmask = $self->bits(@_) ;
331 die @_ if $^B & $bitmask ;
346 if $bits{$string} && $^B & $bits{$string} ;