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 'void' => DEFAULT_OFF,
36 'recursion' => DEFAULT_OFF,
37 'redefine' => DEFAULT_OFF,
38 'numeric' => DEFAULT_OFF,
39 'uninitialized'=> DEFAULT_OFF,
40 'once' => DEFAULT_OFF,
41 'misc' => DEFAULT_OFF,
42 'default' => DEFAULT_ON,
46 ###########################################################################
49 $t .= "\t" x ($l - (length($t) + 1) / 8);
53 ###########################################################################
65 foreach $k (sort keys %$tre) {
67 die "duplicate key $k\n" if defined $list{$k} ;
68 $Value{$index} = uc $k ;
69 push @{ $list{$k} }, $index ++ ;
71 { push (@{ $list{$k} }, walk ($v)) }
72 push @list, @{ $list{$k} } ;
78 ###########################################################################
87 for ($i = 1 ; $i < @a; ++ $i) {
89 if $a[$i] == $a[$i - 1] + 1 && $a[$i] + 1 == $a[$i + 1] ;
92 my $out = join(",",@out);
94 $out =~ s/,(\.\.,)+/../g ;
98 ###########################################################################
103 my $mask = "\x00" x $max ;
107 vec($mask, $_, 1) = 1 ;
110 #$string = unpack("H$max", $mask) ;
111 #$string =~ s/(..)/\x$1/g;
112 foreach (unpack("C*", $mask)) {
113 $string .= '\x' . sprintf("%2.2x", $_) ;
118 ###########################################################################
122 #unlink "lib/warning.pm";
123 open(WARN, ">warning.h") || die "Can't create warning.h: $!\n";
124 open(PM, ">lib/warning.pm") || die "Can't create lib/warning.pm: $!\n";
127 /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
128 This file is built by warning.pl
129 Any changes made here will be lost!
133 #define Off(x) ((x) / 8)
134 #define Bit(x) (1 << ((x) % 8))
135 #define IsSet(a, x) ((a)[Off(x)] & Bit(x))
137 #define G_WARN_OFF 0 /* $^W == 0 */
138 #define G_WARN_ON 1 /* $^W != 0 */
139 #define G_WARN_ALL_ON 2 /* -W flag */
140 #define G_WARN_ALL_OFF 4 /* -X flag */
141 #define G_WARN_ALL_MASK (G_WARN_ALL_ON|G_WARN_ALL_OFF)
145 /* Part of the logic below assumes that WARN_NONE is NULL */
148 (PL_curcop->cop_warnings != WARN_ALL && \
149 PL_curcop->cop_warnings != WARN_NONE && \
150 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x+1))
153 ( (PL_curcop->cop_warnings && \
154 (PL_curcop->cop_warnings == WARN_ALL || \
155 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) ) ) \
156 || (PL_dowarn & G_WARN_ON) )
158 #define ckWARN2(x,y) \
159 ( (PL_curcop->cop_warnings && \
160 (PL_curcop->cop_warnings == WARN_ALL || \
161 IsSet(SvPVX(PL_curcop->cop_warnings), 2*x) || \
162 IsSet(SvPVX(PL_curcop->cop_warnings), 2*y) ) ) \
163 || (PL_dowarn & G_WARN_ON) )
168 (PL_curcop->cop_warnings != WARN_ALL && \
169 PL_curcop->cop_warnings != WARN_NONE && \
170 SvPVX(PL_curcop->cop_warnings)[Off(2*x+1)] & Bit(2*x+1) )
173 ( (PL_dowarn & G_WARN_ON) || ( (PL_dowarn & G_WARN_DISABLE) && \
174 PL_curcop->cop_warnings && \
175 ( PL_curcop->cop_warnings == WARN_ALL || \
176 SvPVX(PL_curcop->cop_warnings)[Off(2*x)] & Bit(2*x) ) ) )
178 #define ckWARN2(x,y) \
179 ( (PL_dowarn & G_WARN_ON) || ( (PL_dowarn & G_WARN_DISABLE) && \
180 PL_curcop->cop_warnings && \
181 ( PL_curcop->cop_warnings == WARN_ALL || \
182 SvPVX(PL_curcop->cop_warnings)[Off(2*x)] & Bit(2*x) || \
183 SvPVX(PL_curcop->cop_warnings)[Off(2*y)] & Bit(2*y) ) ) )
187 #define WARN_NONE NULL
188 #define WARN_ALL (&PL_sv_yes)
194 @{ $list{"all"} } = walk ($tree) ;
197 my $warn_size = int($index / 8) + ($index % 8 != 0) ;
200 foreach $k (sort { $a <=> $b } keys %Value) {
201 print WARN tab(5, "#define WARN_$Value{$k}"), "$k\n" ;
205 print WARN tab(5, '#define WARNsize'), "$warn_size\n" ;
206 #print WARN tab(5, '#define WARN_ALLstring'), '"', ('\377' x $warn_size) , "\"\n" ;
207 print WARN tab(5, '#define WARN_ALLstring'), '"', ('\125' x $warn_size) , "\"\n" ;
208 print WARN tab(5, '#define WARN_NONEstring'), '"', ('\0' x $warn_size) , "\"\n" ;
212 /* end of file warning.h */
219 last if /^KEYWORDS$/ ;
223 $list{'all'} = [ 0 .. 8 * ($warn_size/2) - 1 ] ;
224 print PM "%Bits = (\n" ;
225 foreach $k (sort keys %list) {
228 my @list = sort { $a <=> $b } @$v ;
230 print PM tab(4, " '$k'"), '=> "',
231 # mkHex($warn_size, @list),
232 mkHex($warn_size, map $_ * 2 , @list),
233 '", # [', mkRange(@list), "]\n" ;
238 print PM "%DeadBits = (\n" ;
239 foreach $k (sort keys %list) {
242 my @list = sort { $a <=> $b } @$v ;
244 print PM tab(4, " '$k'"), '=> "',
245 # mkHex($warn_size, @list),
246 mkHex($warn_size, map $_ * 2 + 1 , @list),
247 '", # [', mkRange(@list), "]\n" ;
259 # This file was created by warning.pl
260 # Any changes made here will be lost.
267 warning - Perl pragma to control optional warnings
274 use warning "deprecated";
281 If no import list is supplied, all possible restrictions are assumed.
282 (This is the safest mode to operate in, but is sometimes too strict for
283 casual programming.) Currently, there are three possible things to be
288 =item C<warning deprecated>
290 This generates a runtime error if you use deprecated
292 use warning 'deprecated';
296 See L<perlmod/Pragmatic Modules>.
309 foreach my $word (@_) {
310 if ($word eq 'FATAL')
312 elsif ($catmask = $Bits{$word}) {
314 $mask |= $DeadBits{$word} if $fatal ;
317 { croak "unknown warning category '$word'" }
325 $^B |= bits(@_ ? @_ : 'all') ;
330 $^B &= ~ bits(@_ ? @_ : 'all') ;
337 my $bitmask = $self->bits(@_) ;
341 die @_ if $^B & $bitmask ;
356 if $bits{$string} && $^B & $bits{$string} ;