Commit | Line | Data |
---|---|---|
fe13d51d JM |
1 | #!/usr/bin/perl |
2 | use warnings; | |
3 | use strict; | |
f7b649f0 NC |
4 | |
5 | require './test.pl'; | |
6 | ||
7 | plan('no_plan'); | |
8 | ||
fe13d51d JM |
9 | $|=1; |
10 | ||
f7223e8e | 11 | my $make_exceptions_list = ($ARGV[0]||'') eq '--make-exceptions-list'; |
87a63fff | 12 | |
45f1c7ba | 13 | chdir '..' or die "Can't chdir ..: $!"; |
47f6eaac | 14 | BEGIN { defined $ENV{PERL_UNICODE} and push @INC, "lib"; } |
45f1c7ba | 15 | |
1b1ee2ef KW |
16 | my @functions; |
17 | ||
18 | open my $func_fh, "<", "embed.fnc" or die "Can't open embed.fnc: $!"; | |
19 | ||
20 | # Look for functions in embed.fnc that look like they could be diagnostic ones. | |
21 | while (<$func_fh>) { | |
22 | chomp; | |
23 | s/^\s+//; | |
24 | while (s/\s*\\$//) { # Grab up all continuation lines, these end in \ | |
25 | my $next = <$func_fh>; | |
26 | $next =~ s/^\s+//; | |
27 | chomp $next; | |
28 | $_ .= $next; | |
29 | } | |
30 | next if /^:/; # Lines beginning with colon are comments. | |
31 | next unless /\|/; # Lines without a vertical bar are something we can't deal | |
32 | # with | |
33 | my @fields = split /\s*\|\s*/; | |
34 | next unless $fields[2] =~ /warn|err|(\b|_)die|croak/i; | |
35 | push @functions, $fields[2]; | |
36 | ||
37 | # The flag p means that this function may have a 'Perl_' prefix | |
38 | # The flag s means that this function may have a 'S_' prefix | |
39 | push @functions, "Perl_$fields[2]", if $fields[0] =~ /p/; | |
40 | push @functions, "S_$fields[2]", if $fields[0] =~ /s/; | |
41 | } | |
42 | ||
43 | close $func_fh; | |
44 | ||
45 | my $function_re = join '|', @functions; | |
46 | my $source_msg_re = qr/(?<routine>\bDIE\b|$function_re)/; | |
fe13d51d JM |
47 | |
48 | my %entries; | |
1b1ee2ef KW |
49 | |
50 | # Get the ignores that are compiled into this file | |
87a63fff JM |
51 | while (<DATA>) { |
52 | chomp; | |
53 | $entries{$_}{todo}=1; | |
54 | } | |
55 | ||
fe13d51d | 56 | my $cur_entry; |
1b1ee2ef KW |
57 | open my $diagfh, "<", "pod/perldiag.pod" |
58 | or die "Can't open pod/perldiag.pod: $!"; | |
59 | ||
fe13d51d JM |
60 | while (<$diagfh>) { |
61 | if (m/^=item (.*)/) { | |
62 | $cur_entry = $1; | |
63 | } elsif (m/^\((.)(?: ([a-z]+?))?\)/ and !$entries{$cur_entry}{severity}) { | |
87a63fff JM |
64 | # Make sure to init this here, so an actual entry in perldiag overwrites |
65 | # one in DATA. | |
66 | $entries{$cur_entry}{todo} = 0; | |
fe13d51d JM |
67 | $entries{$cur_entry}{severity} = $1; |
68 | $entries{$cur_entry}{category} = $2; | |
69 | } | |
70 | } | |
71 | ||
1b1ee2ef | 72 | # Recursively descend looking for source files. |
45f1c7ba | 73 | my @todo = <*>; |
fe13d51d JM |
74 | while (@todo) { |
75 | my $todo = shift @todo; | |
45f1c7ba | 76 | next if $todo ~~ ['t', 'lib', 'ext', 'dist', 'cpan']; |
fe13d51d | 77 | # opmini.c is just a copy of op.c, so there's no need to check again. |
45f1c7ba | 78 | next if $todo eq 'opmini.c'; |
fe13d51d JM |
79 | if (-d $todo) { |
80 | push @todo, glob "$todo/*"; | |
87a63fff | 81 | } elsif ($todo =~ m/\.[ch]$/) { |
fe13d51d JM |
82 | check_file($todo); |
83 | } | |
84 | } | |
85 | ||
86 | sub check_file { | |
87 | my ($codefn) = @_; | |
88 | ||
f7223e8e | 89 | print "# $codefn\n"; |
fe13d51d | 90 | |
38ec24b4 | 91 | open my $codefh, "<", $codefn |
fe13d51d JM |
92 | or die "Can't open $codefn: $!"; |
93 | ||
94 | my $listed_as; | |
95 | my $listed_as_line; | |
96 | my $sub = 'top of file'; | |
97 | while (<$codefh>) { | |
98 | chomp; | |
99 | # Getting too much here isn't a problem; we only use this to skip | |
100 | # errors inside of XS modules, which should get documented in the | |
101 | # docs for the module. | |
102 | if (m<^([^#\s].*)> and $1 !~ m/^[{}]*$/) { | |
103 | $sub = $1; | |
104 | } | |
105 | next if $sub =~ m/^XS/; | |
106 | if (m</\* diag_listed_as: (.*) \*/>) { | |
107 | $listed_as = $1; | |
108 | $listed_as_line = $.+1; | |
109 | } | |
110 | next if /^#/; | |
111 | next if /^ * /; | |
1b1ee2ef | 112 | |
c4ea5f2e | 113 | my $multiline = 0; |
1b1ee2ef KW |
114 | # Loop to accumulate the message text all on one line. |
115 | while (m/$source_msg_re/ and not m/\);$/) { | |
fe13d51d JM |
116 | my $nextline = <$codefh>; |
117 | # Means we fell off the end of the file. Not terribly surprising; | |
118 | # this code tries to merge a lot of things that aren't regular C | |
119 | # code (preprocessor stuff, long comments). That's OK; we don't | |
120 | # need those anyway. | |
121 | last if not defined $nextline; | |
122 | chomp $nextline; | |
123 | $nextline =~ s/^\s+//; | |
124 | # Note that we only want to do this where *both* are true. | |
125 | $_ =~ s/\\$//; | |
126 | if ($_ =~ m/"$/ and $nextline =~ m/^"/) { | |
127 | $_ =~ s/"$//; | |
128 | $nextline =~ s/^"//; | |
129 | } | |
130 | $_ = "$_$nextline"; | |
c4ea5f2e | 131 | ++$multiline; |
fe13d51d JM |
132 | } |
133 | # This should happen *after* unwrapping, or we don't reformat the things | |
134 | # in later lines. | |
135 | # List from perlguts.pod "Formatted Printing of IVs, UVs, and NVs" | |
136 | my %specialformats = (IVdf => 'd', | |
137 | UVuf => 'd', | |
138 | UVof => 'o', | |
139 | UVxf => 'x', | |
140 | UVXf => 'X', | |
141 | NVef => 'f', | |
142 | NVff => 'f', | |
143 | NVgf => 'f', | |
144 | SVf => 's'); | |
145 | for my $from (keys %specialformats) { | |
146 | s/%"\s*$from\s*"/\%$specialformats{$from}/g; | |
147 | s/%"\s*$from/\%$specialformats{$from}"/g; | |
148 | } | |
149 | # The %"foo" thing needs to happen *before* this regex. | |
1b1ee2ef | 150 | if (m/$source_msg_re(?:_nocontext)? \s* |
fe13d51d | 151 | \(aTHX_ \s* |
1b1ee2ef KW |
152 | (?:packWARN\d*\((?<category>.*?)\),)? \s* |
153 | "(?<text>(?:\\"|[^"])*?)"/x) | |
154 | { | |
155 | # diag($_); | |
156 | # DIE is just return Perl_die | |
157 | my $severity = {croak => [qw/P F/], | |
fe13d51d JM |
158 | die => [qw/P F/], |
159 | warn => [qw/W D S/], | |
1b1ee2ef KW |
160 | }->{$+{'routine'}||'die'}; |
161 | my @categories; | |
162 | if ($+{'category'}) { | |
163 | @categories = map {s/^WARN_//; lc $_} split /\s*[|,]\s*/, $+{'category'}; | |
164 | } | |
165 | my $name; | |
c4ea5f2e | 166 | if ($listed_as and $listed_as_line == $. - $multiline) { |
fe13d51d | 167 | $name = $listed_as; |
1b1ee2ef KW |
168 | } else { |
169 | $name = $+{'text'}; | |
170 | # The form listed in perldiag ignores most sorts of fancy printf | |
171 | # formatting, or makes it more perlish. | |
fe13d51d JM |
172 | $name =~ s/%%/\\%/g; |
173 | $name =~ s/%l[ud]/%d/g; | |
174 | $name =~ s/%\.(\d+|\*)s/\%s/g; | |
175 | $name =~ s/\\"/"/g; | |
176 | $name =~ s/\\t/\t/g; | |
87a63fff JM |
177 | $name =~ s/\\n/ /g; |
178 | $name =~ s/\s+$//; | |
4a68bf9d | 179 | $name =~ s/(\\)\\/$1/g; |
fe13d51d JM |
180 | } |
181 | ||
87a63fff JM |
182 | # Extra explanatory info on an already-listed error, doesn't |
183 | # need it's own listing. | |
fe13d51d JM |
184 | next if $name =~ m/^\t/; |
185 | ||
186 | # Happens fairly often with PL_no_modify. | |
187 | next if $name eq '%s'; | |
188 | ||
87a63fff JM |
189 | # Special syntax for magic comment, allows ignoring the fact |
190 | # that it isn't listed. Only use in very special circumstances, | |
191 | # like this script failing to notice that the Perl_croak call is | |
192 | # inside an #if 0 block. | |
fe13d51d JM |
193 | next if $name eq 'SKIPME'; |
194 | ||
87a63fff JM |
195 | if (exists $entries{$name}) { |
196 | if ($entries{$name}{todo}) { | |
197 | TODO: { | |
1b1ee2ef | 198 | no warnings 'once'; |
f7b649f0 | 199 | local $::TODO = 'in DATA'; |
87a63fff JM |
200 | fail("Presence of '$name' from $codefn line $."); |
201 | } | |
fe13d51d | 202 | } else { |
87a63fff | 203 | ok("Presence of '$name' from $codefn line $."); |
fe13d51d | 204 | } |
87a63fff JM |
205 | # Later, should start checking that the severity is correct, too. |
206 | } elsif ($name =~ m/^panic: /) { | |
207 | # Just too many panic:s, they are hard to diagnose, and there | |
208 | # is a generic "panic: %s" entry. Leave these for another | |
209 | # pass. | |
210 | ok("Presence of '$name' from $codefn line $., covered by panic: %s entry"); | |
fe13d51d | 211 | } else { |
87a63fff JM |
212 | if ($make_exceptions_list) { |
213 | print STDERR "$name\n"; | |
214 | } else { | |
215 | fail("Presence of '$name' from $codefn line $."); | |
216 | } | |
fe13d51d JM |
217 | } |
218 | ||
219 | die if $name =~ /%$/; | |
220 | } | |
221 | } | |
222 | } | |
f7223e8e | 223 | # Lists all missing things as of the inaguration of this script, so we |
87a63fff JM |
224 | # don't have to go from "meh" to perfect all at once. |
225 | __DATA__ | |
87a63fff JM |
226 | Ambiguous use of %c resolved as operator %c |
227 | Ambiguous use of %c{%s} resolved to %c%s | |
228 | Ambiguous use of %c{%s%s} resolved to %c%s%s | |
229 | Ambiguous use of -%s resolved as -&%s() | |
230 | Argument "%s" isn't numeric | |
231 | Argument "%s" isn't numeric in %s | |
87a63fff JM |
232 | Attempt to clear deleted array |
233 | Attempt to free non-arena SV: 0x%x | |
234 | Attempt to free non-existent shared string '%s'%s | |
235 | Attempt to free temp prematurely: SV 0x%x | |
236 | Attempt to free unreferenced scalar: SV 0x%x | |
237 | Attempt to reload %s aborted. Compilation failed in require | |
238 | av_reify called on tied array | |
239 | Bad name after %s%s | |
d5713896 | 240 | Bad symbol for %s |
87a63fff JM |
241 | bad top format reference |
242 | Bizarre copy of %s | |
243 | Bizarre SvTYPE [%d] | |
244 | Cannot copy to %s | |
245 | Can't call method "%s" %s | |
246 | Can't coerce readonly %s to string | |
247 | Can't coerce readonly %s to string in %s | |
248 | Can't fix broken locale name "%s" | |
249 | Can't get short module name from a handle | |
250 | Can't goto subroutine from an eval-block | |
251 | Can't goto subroutine from an eval-string | |
252 | Can't locate object method "%s" via package "%s" (perhaps you forgot to load "%s"?) | |
253 | Can't modify non-existent substring | |
254 | Can't open | |
255 | Can't open perl script "%s": %s | |
256 | Can't open %s | |
257 | Can't reset \%ENV on this system | |
258 | Can't return array to lvalue scalar context | |
259 | Can't return a %s from lvalue subroutine | |
260 | Can't return hash to lvalue scalar context | |
261 | Can't spawn "%s": %s | |
262 | Can't %s script `%s' with ARGV[0] being `%s' | |
263 | Can't %s "%s": %s | |
264 | Can't %s %s%s%s | |
265 | Can't %s `%s' with ARGV[0] being `%s' (looking for executables only, not found) | |
266 | Can't take %s of %f | |
267 | Can't use '%c' after -mname | |
973a7615 | 268 | Can't use string ("%s"%s) as a subroutine ref while "strict refs" in use |
4a68bf9d | 269 | Can't use \%c to mean $%c in expression |
87a63fff | 270 | Can't use when() outside a topicalizer |
4a68bf9d | 271 | \%c better written as $%c |
87a63fff JM |
272 | Character(s) in '%c' format wrapped in %s |
273 | $%c is no longer supported | |
274 | Cloning substitution context is unimplemented | |
275 | Code missing after '/' in pack | |
276 | Code missing after '/' in unpack | |
277 | Compilation failed in require | |
278 | Corrupted regexp opcode %d > %d | |
279 | '%c' outside of string in pack | |
280 | Debug leaking scalars child failed%s%s with errno %d: %s | |
281 | Deep recursion on anonymous subroutine | |
282 | defined(\%hash) is deprecated | |
4a68bf9d | 283 | Don't know how to handle magic of type \%o |
87a63fff JM |
284 | -Dp not implemented on this platform |
285 | entering effective gid failed | |
286 | entering effective uid failed | |
287 | Error reading "%s": %s | |
288 | Exiting %s via %s | |
289 | Filehandle opened only for %sput | |
290 | Filehandle %s opened only for %sput | |
291 | Filehandle STD%s reopened as %s only for input | |
292 | YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET! FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP! | |
293 | Format STDOUT redefined | |
294 | Free to wrong pool %p not %p | |
295 | get %s %p %p %p | |
296 | glob failed (can't start child: %s) | |
297 | glob failed (child exited with status %d%s) | |
298 | Goto undefined subroutine | |
299 | Goto undefined subroutine &%s | |
300 | Hash \%%s missing the \% in argument %d of %s() | |
4a68bf9d | 301 | Illegal character \%03o (carriage return) |
87a63fff | 302 | Illegal character %sin prototype for %s : %s |
1b1ee2ef | 303 | Integer overflow in binary number |
87a63fff | 304 | Integer overflow in decimal number |
1b1ee2ef KW |
305 | Integer overflow in hexadecimal number |
306 | Integer overflow in octal number | |
87a63fff JM |
307 | Integer overflow in version %d |
308 | internal \%<num>p might conflict with future printf extensions | |
4a68bf9d | 309 | invalid control request: '\%03o' |
87a63fff JM |
310 | Invalid module name %s with -%c option: contains single ':' |
311 | invalid option -D%c, use -D'' to see choices | |
312 | Invalid range "%c-%c" in transliteration operator | |
313 | Invalid separator character %c%c%c in PerlIO layer specification %s | |
314 | Invalid TOKEN object ignored | |
315 | Invalid type '%c' in pack | |
316 | Invalid type '%c' in %s | |
317 | Invalid type '%c' in unpack | |
318 | Invalid type ',' in %s | |
91152fc1 DG |
319 | Invalid strict version format (0 before decimal required) |
320 | Invalid strict version format (no leading zeros) | |
321 | Invalid strict version format (no underscores) | |
322 | Invalid strict version format (v1.2.3 required) | |
323 | Invalid strict version format (version required) | |
324 | Invalid strict version format (1.[0-9] required) | |
87a63fff JM |
325 | Invalid version format (alpha without decimal) |
326 | Invalid version format (misplaced _ in number) | |
327 | Invalid version object | |
4a68bf9d | 328 | It is proposed that "\c{" no longer be valid. It has historically evaluated to ";". If you disagree with this proposal, send email to perl5-porters@perl.org Otherwise, or in the meantime, you can work around this failure by changing "\c{" to ";" |
87a63fff JM |
329 | 'j' not supported on this platform |
330 | 'J' not supported on this platform | |
331 | Layer does not match this perl | |
332 | leaving effective gid failed | |
333 | leaving effective uid failed | |
334 | List form of piped open not implemented | |
335 | Lost precision when decrementing %f by 1 | |
336 | Lost precision when incrementing %f by 1 | |
337 | %lx | |
338 | Malformed UTF-16 surrogate | |
339 | Malformed UTF-8 character (fatal) | |
340 | '\%' may not be used in pack | |
341 | Missing (suid) fd script name | |
342 | More than one argument to open | |
343 | More than one argument to open(,':%s') | |
344 | mprotect for %p %d failed with %d | |
345 | mprotect RW for %p %d failed with %d | |
346 | No code specified for -%c | |
347 | No directory specified for -I | |
348 | No such class field "%s" | |
349 | Not an XSUB reference | |
350 | Not %s reference | |
351 | Offset outside string | |
352 | Opening dirhandle %s also as a file | |
353 | Opening filehandle %s also as a directory | |
354 | Operator or semicolon missing before %c%s | |
87a63fff JM |
355 | PERL_SIGNALS illegal: "%s" |
356 | Perl %s required (did you mean %s?)--this is only %s, stopped | |
357 | Perl %s required--this is only %s, stopped | |
358 | Perls since %s too modern--this is %s, stopped | |
4a68bf9d | 359 | Possible unintended interpolation of $\ in regex |
87a63fff JM |
360 | ptr wrong %p != %p fl=%08 |
361 | Recompile perl with -DDEBUGGING to use -D switch (did you mean -d ?) | |
362 | Recursive call to Perl_load_module in PerlIO_find_layer | |
363 | refcnt_dec: fd %d < 0 | |
364 | refcnt_dec: fd %d: %d <= 0 | |
365 | refcnt_dec: fd %d >= refcnt_size %d | |
366 | refcnt_inc: fd %d < 0 | |
367 | refcnt_inc: fd %d: %d <= 0 | |
368 | Reversed %c= operator | |
369 | Runaway prototype | |
1b1ee2ef | 370 | %s(%.0 |
87a63fff JM |
371 | %s(%.0f) failed |
372 | %s(%.0f) too large | |
373 | Scalar value %s better written as $%s | |
374 | %sCompilation failed in regexp | |
375 | %sCompilation failed in require | |
376 | set %s %p %p %p | |
377 | %s free() ignored (RMAGIC, PERL_CORE) | |
378 | %s has too many errors. | |
379 | SIG%s handler "%s" not defined. | |
380 | %s: illegal mapping '%s' | |
381 | %s in %s | |
382 | Size magic not implemented | |
383 | %s limit (%d) exceeded | |
384 | %s method "%s" overloading "%s" in package "%s" | |
385 | %s number > %s non-portable | |
386 | %s object version %s does not match %s%s%s%s %s | |
387 | %srealloc() %signored | |
388 | %s returned from lvalue subroutine in scalar context | |
389 | %s%s has too many errors. | |
390 | %s%s on %s %s | |
391 | %s%s on %s %s %s | |
392 | Starting Full Screen process with flag=%d, mytype=%d | |
393 | Starting PM process with flag=%d, mytype=%d | |
394 | strxfrm() gets absurd | |
395 | SWASHNEW didn't return an HV ref | |
396 | -T and -B not implemented on filehandles | |
397 | The flock() function is not implemented on NetWare | |
398 | The rewinddir() function is not implemented on NetWare | |
399 | The seekdir() function is not implemented on NetWare | |
400 | The stat preceding lstat() wasn't an lstat | |
401 | The telldir() function is not implemented on NetWare | |
402 | Too deeply nested ()-groups in %s | |
403 | Too late to run CHECK block | |
404 | Too late to run INIT block | |
405 | Too many args on %s line of "%s" | |
406 | U0 mode on a byte string | |
407 | Unbalanced string table refcount: (%d) for "%s" | |
408 | Undefined top format called | |
409 | Unexpected constant lvalue entersub entry via type/targ %d:%d | |
6f6ac1de | 410 | Unicode non-character 0x%04 |
87a63fff JM |
411 | Unknown PerlIO layer "scalar" |
412 | Unknown Unicode option letter '%c' | |
87a63fff | 413 | Unstable directory path, current directory changed unexpectedly |
ee6ba15d EB |
414 | Unsupported script encoding UTF-16BE |
415 | Unsupported script encoding UTF-16LE | |
416 | Unsupported script encoding UTF-32BE | |
417 | Unsupported script encoding UTF-32LE | |
87a63fff JM |
418 | Unterminated compressed integer in unpack |
419 | Usage: CODE(0x%x)(%s) | |
420 | Usage: %s(%s) | |
421 | Usage: %s::%s(%s) | |
422 | Usage: VMS::Filespec::unixrealpath(spec) | |
423 | Usage: VMS::Filespec::vmsrealpath(spec) | |
424 | Use of inherited AUTOLOAD for non-method %s::%s() is deprecated | |
425 | UTF-16 surrogate 0x%04 | |
4a68bf9d | 426 | utf8 "\x%02X" does not map to Unicode |
87a63fff JM |
427 | Value of logical "%s" too long. Truncating to %i bytes |
428 | value of node is %d in Offset macro | |
429 | Value of %s%s can be "0"; test with defined() | |
430 | Variable "%c%s" is not imported | |
431 | vector argument not supported with alpha versions | |
432 | Wide character | |
433 | Wide character in $/ | |
434 | Wide character in print | |
435 | Wide character in %s | |
436 | Within []-length '%c' not allowed in %s | |
437 | Wrong syntax (suid) fd script name "%s" | |
438 | 'X' outside of string in unpack |