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 'overflow' => DEFAULT_OFF,
18 'portable' => DEFAULT_OFF,
19 'utf8' => DEFAULT_OFF,
21 'io' => { 'pipe' => DEFAULT_OFF,
22 'unopened' => DEFAULT_OFF,
23 'closed' => DEFAULT_OFF,
24 'newline' => DEFAULT_OFF,
25 'exec' => DEFAULT_OFF,
26 #'wr in in file'=> DEFAULT_OFF,
28 'syntax' => { 'ambiguous' => DEFAULT_OFF,
29 'semicolon' => DEFAULT_OFF,
30 'precedence' => DEFAULT_OFF,
31 'reserved' => DEFAULT_OFF,
32 'octal' => DEFAULT_OFF,
33 'digit' => DEFAULT_OFF,
34 'parenthesis' => DEFAULT_OFF,
35 'deprecated' => DEFAULT_OFF,
36 'printf' => DEFAULT_OFF,
38 'severe' => { 'inplace' => DEFAULT_ON,
39 'internal' => DEFAULT_ON,
40 'debugging' => DEFAULT_ON,
42 'void' => DEFAULT_OFF,
43 'recursion' => DEFAULT_OFF,
44 'redefine' => DEFAULT_OFF,
45 'numeric' => DEFAULT_OFF,
46 'uninitialized'=> DEFAULT_OFF,
47 'once' => DEFAULT_OFF,
48 'misc' => DEFAULT_OFF,
49 #'default' => DEFAULT_ON,
53 ###########################################################################
56 $t .= "\t" x ($l - (length($t) + 1) / 8);
60 ###########################################################################
72 foreach $k (sort keys %$tre) {
74 die "duplicate key $k\n" if defined $list{$k} ;
75 $Value{$index} = uc $k ;
76 push @{ $list{$k} }, $index ++ ;
78 { push (@{ $list{$k} }, walk ($v)) }
79 push @list, @{ $list{$k} } ;
85 ###########################################################################
94 for ($i = 1 ; $i < @a; ++ $i) {
96 if $a[$i] == $a[$i - 1] + 1 && $a[$i] + 1 == $a[$i + 1] ;
99 my $out = join(",",@out);
101 $out =~ s/,(\.\.,)+/../g ;
105 ###########################################################################
110 my $mask = "\x00" x $max ;
114 vec($mask, $_, 1) = 1 ;
117 #$string = unpack("H$max", $mask) ;
118 #$string =~ s/(..)/\x$1/g;
119 foreach (unpack("C*", $mask)) {
120 $string .= '\x' . sprintf("%2.2x", $_) ;
125 ###########################################################################
128 #unlink "warnings.h";
129 #unlink "lib/warnings.pm";
130 open(WARN, ">warnings.h") || die "Can't create warnings.h: $!\n";
131 open(PM, ">lib/warnings.pm") || die "Can't create lib/warnings.pm: $!\n";
134 /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
135 This file is built by warnings.pl
136 Any changes made here will be lost!
140 #define Off(x) ((x) / 8)
141 #define Bit(x) (1 << ((x) % 8))
142 #define IsSet(a, x) ((a)[Off(x)] & Bit(x))
145 #define G_WARN_OFF 0 /* $^W == 0 */
146 #define G_WARN_ON 1 /* -w flag and $^W != 0 */
147 #define G_WARN_ALL_ON 2 /* -W flag */
148 #define G_WARN_ALL_OFF 4 /* -X flag */
149 #define G_WARN_ONCE 8 /* set if 'once' ever enabled */
150 #define G_WARN_ALL_MASK (G_WARN_ALL_ON|G_WARN_ALL_OFF)
152 #define WARN_STD Nullsv
153 #define WARN_ALL (Nullsv+1) /* use warnings 'all' */
154 #define WARN_NONE (Nullsv+2) /* no warnings 'all' */
156 #define specialWARN(x) ((x) == WARN_STD || (x) == WARN_ALL || \
160 ( ! specialWARN(PL_curcop->cop_warnings) && \
161 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x+1))
164 ( (PL_curcop->cop_warnings != WARN_STD && \
165 PL_curcop->cop_warnings != WARN_NONE && \
166 (PL_curcop->cop_warnings == WARN_ALL || \
167 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) ) ) \
168 || (PL_curcop->cop_warnings == WARN_STD && PL_dowarn & G_WARN_ON) )
170 #define ckWARN2(x,y) \
171 ( (PL_curcop->cop_warnings != WARN_STD && \
172 PL_curcop->cop_warnings != WARN_NONE && \
173 (PL_curcop->cop_warnings == WARN_ALL || \
174 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) || \
175 IsSet(SvPVX(PL_curcop->cop_warnings), 2*y) ) ) \
176 || (PL_curcop->cop_warnings == WARN_STD && PL_dowarn & G_WARN_ON) )
178 #define ckWARN_d(x) \
179 (PL_curcop->cop_warnings == WARN_STD || \
180 PL_curcop->cop_warnings == WARN_ALL || \
181 (PL_curcop->cop_warnings != WARN_NONE && \
182 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) ) )
184 #define ckWARN2_d(x,y) \
185 (PL_curcop->cop_warnings == WARN_STD || \
186 PL_curcop->cop_warnings == WARN_ALL || \
187 (PL_curcop->cop_warnings != WARN_NONE && \
188 (IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) || \
189 IsSet(SvPVX(PL_curcop->cop_warnings), 2*y) ) ) )
192 #define isLEXWARN_on (PL_curcop->cop_warnings != WARN_STD)
193 #define isLEXWARN_off (PL_curcop->cop_warnings == WARN_STD)
194 #define isWARN_ONCE (PL_dowarn & (G_WARN_ON|G_WARN_ONCE))
195 #define isWARN_on(c,x) (IsSet(SvPVX(c), 2*(x)))
201 @{ $list{"all"} } = walk ($tree) ;
204 my $warn_size = int($index / 8) + ($index % 8 != 0) ;
207 foreach $k (sort { $a <=> $b } keys %Value) {
208 print WARN tab(5, "#define WARN_$Value{$k}"), "$k\n" ;
212 print WARN tab(5, '#define WARNsize'), "$warn_size\n" ;
213 #print WARN tab(5, '#define WARN_ALLstring'), '"', ('\377' x $warn_size) , "\"\n" ;
214 print WARN tab(5, '#define WARN_ALLstring'), '"', ('\125' x $warn_size) , "\"\n" ;
215 print WARN tab(5, '#define WARN_NONEstring'), '"', ('\0' x $warn_size) , "\"\n" ;
219 /* end of file warnings.h */
226 last if /^KEYWORDS$/ ;
230 $list{'all'} = [ 0 .. 8 * ($warn_size/2) - 1 ] ;
231 print PM "%Bits = (\n" ;
232 foreach $k (sort keys %list) {
235 my @list = sort { $a <=> $b } @$v ;
237 print PM tab(4, " '$k'"), '=> "',
238 # mkHex($warn_size, @list),
239 mkHex($warn_size, map $_ * 2 , @list),
240 '", # [', mkRange(@list), "]\n" ;
245 print PM "%DeadBits = (\n" ;
246 foreach $k (sort keys %list) {
249 my @list = sort { $a <=> $b } @$v ;
251 print PM tab(4, " '$k'"), '=> "',
252 # mkHex($warn_size, @list),
253 mkHex($warn_size, map $_ * 2 + 1 , @list),
254 '", # [', mkRange(@list), "]\n" ;
266 # This file was created by warnings.pl
267 # Any changes made here will be lost.
274 warnings - Perl pragma to control optional warnings
286 If no import list is supplied, all possible warnings are either enabled
289 See L<perlmod/Pragmatic Modules> and L<perllexwarn>.
302 foreach my $word (@_) {
303 if ($word eq 'FATAL')
305 elsif ($catmask = $Bits{$word}) {
307 $mask |= $DeadBits{$word} if $fatal ;
310 { croak "unknown warning category '$word'" }
318 ${^Warnings} |= bits(@_ ? @_ : 'all') ;
323 ${^Warnings} &= ~ bits(@_ ? @_ : 'all') ;
331 if $bits{$string} && ${^Warnings} & $bits{$string} ;