4 @INC = '..' if -f '../TestInit.pm';
6 use TestInit qw(T); # T is chdir to the top level
14 if ( $Config{usecrosscompile} ) {
15 skip_all( "Not all files are available during cross-compilation" );
20 # --make-exceptions-list outputs the list of strings that don't have
21 # perldiag.pod entries to STDERR without TAP formatting, so they can
22 # easily be put in the __DATA__ section of this file. This was done
23 # initially so as to not create new test failures upon the initial
24 # creation of this test file. You probably shouldn't do it again.
25 # Just add the documentation instead.
26 my $make_exceptions_list = ($ARGV[0]||'') eq '--make-exceptions-list'
29 require 'regen/embed_lib.pl';
31 # Look for functions that look like they could be diagnostic ones.
33 foreach (@{(setup_embed())[0]}) {
35 next unless $_->[2] =~ /warn|(?<!ov)err|(\b|_)die|croak/i;
36 # The flag p means that this function may have a 'Perl_' prefix
37 # The flag s means that this function may have a 'S_' prefix
38 push @functions, $_->[2];
39 push @functions, 'Perl_' . $_->[2] if $_->[0] =~ /p/;
40 push @functions, 'S_' . $_->[2] if $_->[0] =~ /s/;
43 my $regcomp_fail_re = '\b(?:(?:Simple_)?v)?FAIL[2-4]?(?:utf8f)?\b';
45 "(?<routine>ckWARN(?:\\d+)?reg\\w*|vWARN\\d+|$regcomp_fail_re)";
46 my $function_re = join '|', @functions;
48 "(?<routine>\\bDIE\\b|$function_re)";
49 my $text_re = '"(?<text>(?:\\\\"|[^"]|"\s*[A-Z_]+\s*")*)"';
50 my $source_msg_call_re = qr/$source_msg_re(?:_nocontext)? \s*
52 (?:packWARN\d*\((?<category>.*?)\),)? \s*
54 my $bad_version_re = qr{BADVERSION\([^"]*$text_re};
55 $regcomp_fail_re = qr/$regcomp_fail_re\([^"]*$text_re/;
56 my $regcomp_call_re = qr/$regcomp_re.*?$text_re/;
60 # Get the ignores that are compiled into this file
61 my $reading_categorical_exceptions;
64 $entries{$_}{todo} = 1;
65 $reading_categorical_exceptions and $entries{$_}{cattodo}=1;
66 /__CATEGORIES__/ and ++$reading_categorical_exceptions;
69 my $pod = "pod/perldiag.pod";
71 open my $diagfh, "<", $pod
72 or die "Can't open $pod: $!";
74 my $category_re = qr/ [a-z0-9_:]+?/; # Note: requires an initial space
75 my $severity_re = qr/ . (?: \| . )* /x; # A severity is a single char, but can
76 # be of the form 'S|P|W'
82 # Allow multi-line headers
88 $cur_entry =~ s/ ?\z/ $_/;
91 $cur_entry =~ s/\n/ /gs; # Fix multi-line headers if they have \n's
92 $cur_entry =~ s/\s+\z//;
93 $cur_entry =~ s/[BCIFS](?:<<< (.*?) >>>|<< (.*?) >>|<(.*?)>)/$+/g;
95 if (exists $entries{$cur_entry} && $entries{$cur_entry}{todo}
96 && !$entries{$cur_entry}{cattodo}) {
98 local $::TODO = "Remove the TODO entry \"$cur_entry\" from DATA as it is already in $pod near line $.";
102 # Make sure to init this here, so an actual entry in perldiag
103 # overwrites one in DATA.
104 $entries{$cur_entry}{todo} = 0;
105 $entries{$cur_entry}{line_number} = $.;
108 next if ! defined $cur_entry;
110 if (! $entries{$cur_entry}{severity}) {
111 if (/^ \( ( $severity_re )
113 # Can have multiple categories separated by commas
114 ( $category_re (?: , $category_re)* )? \) /x)
116 $entries{$cur_entry}{severity} = $1;
117 $entries{$cur_entry}{category} =
118 $2 && join ", ", sort split " ", $2 =~ y/,//dr;
120 # Record it also for other messages sharing the same description
121 @$_{qw<severity category>} =
122 @{$entries{$cur_entry}}{qw<severity category>}
125 elsif (! $entries{$cur_entry}{first_line} && $_ =~ /\S/) {
127 # Keep track of first line of text if doesn't contain a severity, so
128 # that can later examine it to determine if that is ok or not
129 $entries{$cur_entry}{first_line} = $_;
135 push @same_descr, $entries{$cur_entry};
140 foreach my $cur_entry ( keys %entries) {
141 next if $entries{$cur_entry}{todo}; # If in this file, won't have a severity
142 if (! exists $entries{$cur_entry}{severity}
144 # If there is no first line, it was two =items in a row, so the
145 # second one is the one with with text, not this one.
146 && exists $entries{$cur_entry}{first_line}
148 # If the first line refers to another message, no need for severity
149 && $entries{$cur_entry}{first_line} !~ /^See/)
153 " $pod entry at line $entries{$cur_entry}{line_number}\n"
154 . " \"$cur_entry\"\n"
155 . " is missing a severity and/or category"
160 # List from perlguts.pod "Formatted Printing of IVs, UVs, and NVs"
161 # Convert from internal formats to ones that the readers will be familiar
162 # with, while removing any format modifiers, such as precision, the
163 # presence of which would just confuse the pod's explanation
164 my %specialformats = (IVdf => 'd',
178 my $format_modifiers = qr/ [#0\ +-]* # optional flags
179 (?: [1-9][0-9]* | \* )? # optional field width
180 (?: \. \d* )? # optional precision
181 (?: h|l )? # optional length modifier
185 join '|', sort { length $b cmp length $a } keys %specialformats;
186 my $specialformats_re = qr/%$format_modifiers"\s*($specialformats)(\s*")?/;
189 check_file($_) for @ARGV;
192 open my $fh, '<', 'MANIFEST' or die "Can't open MANIFEST: $!";
193 while (my $file = <$fh>) {
196 next unless $file =~ /\.(?:c|cpp|h|xs|y)\z/ or $file =~ /^perly\./;
197 # OS/2 extensions have never been migrated to ext/, hence the special case:
198 next if $file =~ m!\A(?:ext|dist|cpan|lib|t|os2/OS2|x2p)/!
199 && $file !~ m!\Aext/DynaLoader/!;
204 # Standardize messages with variants into the form that appears
205 # in perldiag.pod -- useful for things without a diag_listed_as annotation
209 if ( $name =~ m/^(Invalid strict version format) \([^\)]*\)/ ) {
212 elsif ( $name =~ m/^(Invalid version format) \([^\)]*\)/ ) {
215 elsif ($name =~ m/^panic: /) {
216 $name = "panic: \%s";
225 print "# Checking $codefn\n";
227 open my $codefh, "<", $codefn
228 or die "Can't open $codefn: $!";
232 my $sub = 'top of file';
235 # Getting too much here isn't a problem; we only use this to skip
236 # errors inside of XS modules, which should get documented in the
237 # docs for the module.
238 if (m<^[^#\s]> and $_ !~ m/^[{}]*$/) {
241 next if $sub =~ m/^XS/;
242 if (m</\*\s*diag_listed_as: (.*?)\s*\*/>) {
244 $listed_as_line = $.+1;
249 # Loop to accumulate the message text all on one line.
250 if (m/(?!^)\b(?:$source_msg_re(?:_nocontext)?|$regcomp_re)\s*\(/) {
251 while (not m/\);$/) {
252 my $nextline = <$codefh>;
253 # Means we fell off the end of the file. Not terribly surprising;
254 # this code tries to merge a lot of things that aren't regular C
255 # code (preprocessor stuff, long comments). That's OK; we don't
257 last if not defined $nextline;
259 $nextline =~ s/^\s+//;
261 # Note that we only want to do this where *both* are true.
262 if ($_ =~ m/"\s*$/ and $nextline =~ m/^"/) {
270 # This should happen *after* unwrapping, or we don't reformat the things
273 s/$specialformats_re/"%$specialformats{$1}" . (defined $2 ? '' : '"')/ge;
275 # Remove any remaining format modifiers, but not in %%
276 s/ (?<!%) % $format_modifiers ( [dioxXucsfeEgGp] ) /%$1/xg;
278 # The %"foo" thing needs to happen *before* this regex.
280 # DIE is just return Perl_die
281 my ($name, $category, $routine);
282 if (/\b$source_msg_call_re/) {
283 ($name, $category, $routine) = ($+{'text'}, $+{'category'}, $+{'routine'});
284 # Sometimes the regexp will pick up too much for the category
285 # e.g., WARN_UNINITIALIZED), PL_warn_uninit_sv ... up to the next )
286 $category && $category =~ s/\).*//s;
287 if (/win32_croak_not_implemented\(/) {
288 $name .= " not implemented!"
291 elsif (/$bad_version_re/) {
292 ($name, $category) = ($+{'text'}, undef);
294 elsif (/$regcomp_fail_re/) {
295 # FAIL("foo") -> "foo in regex m/%s/"
296 # vFAIL("foo") -> "foo in regex; marked by <-- HERE in m/%s/"
297 ($name, $category) = ($+{'text'}, undef);
299 " in regex" . ("; marked by <-- HERE in" x /vFAIL/) . " m/%s/";
301 elsif (/$regcomp_call_re/) {
302 # vWARN/ckWARNreg("foo") -> "foo in regex; marked by <-- HERE in m/%s/
303 ($name, $category, $routine) = ($+{'text'}, undef, $+{'routine'});
304 $name .= " in regex; marked by <-- HERE in m/%s/";
305 $category = 'WARN_REGEXP';
306 if ($routine =~ /dep/) {
307 $category .= ',WARN_DEPRECATED';
314 # Try to guess what the severity should be. In the case of
315 # Perl_ck_warner and other _ck_ functions, we can tell whether it is
316 # a severe/default warning or no by the _d suffix. In the case of
317 # other warn functions we cannot tell, because Perl_warner may be pre-
318 # ceded by if(ckWARN) or if(ckWARN_d).
319 my $severity = !$routine ? '[PFX]'
320 : $routine =~ /warn.*_d\z/ ? '[DS]'
321 : $routine =~ /ck_warn/ ? 'W'
322 : $routine =~ /warner/ ? '[WDS]'
323 : $routine =~ /warn/ ? 'S'
324 : $routine =~ /ckWARN.*dep/ ? 'D'
325 : $routine =~ /ckWARN\d*reg_d/? 'S'
326 : $routine =~ /ckWARN\d*reg/ ? 'W'
327 : $routine =~ /vWARN\d/ ? '[WDS]'
330 if (defined $category) {
331 $category =~ s/__/::/g;
334 sort map {s/^WARN_//; lc $_} split /\s*[|,]\s*/, $category;
336 if ($listed_as and $listed_as_line == $. - $multiline) {
339 # The form listed in perldiag ignores most sorts of fancy printf
340 # formatting, or makes it more perlish.
342 $name =~ s/%l[ud]/%d/g;
343 $name =~ s/%\.(\d+|\*)s/\%s/g;
344 $name =~ s/(?:%s){2,}/%s/g;
345 $name =~ s/(\\")|("\s*[A-Z_]+\s*")/$1 ? '"' : '%s'/egg;
349 $name =~ s/(\\)\\/$1/g;
352 # Extra explanatory info on an already-listed error, doesn't
353 # need it's own listing.
354 next if $name =~ m/^\t/;
356 # Happens fairly often with PL_no_modify.
357 next if $name eq '%s';
359 # Special syntax for magic comment, allows ignoring the fact
360 # that it isn't listed. Only use in very special circumstances,
361 # like this script failing to notice that the Perl_croak call is
362 # inside an #if 0 block.
363 next if $name eq 'SKIPME';
365 next if $name=~/\[TESTING\]/; # ignore these as they are works in progress
367 check_message(standardize($name),$codefn,$severity,$categories);
372 my($name,$codefn,$severity,$categories,$partial) = @_;
373 my $key = $name =~ y/\n/ /r;
376 # Try to reduce printf() formats to simplest forms
377 # Really this should be matching %s, etc like diagnostics.pm does
380 $key =~ s/%[#0\-+]/%/g;
383 $key =~ s/\%(\d+|\*)/%/g;
386 $key =~ s/\%\.(\d+|\*)/%/g;
388 if (exists $entries{$key} and
389 # todo + cattodo means it is not found and it is not in the
390 # regular todo list, either
391 !$entries{$key}{todo} || !$entries{$key}{cattodo}) {
393 if ( $entries{$key}{seen}++ ) {
394 # no need to repeat entries we've tested
395 } elsif ($entries{$key}{todo}) {
398 local $::TODO = 'in DATA';
399 # There is no listing, but it is in the list of exceptions. TODO FAIL.
402 " Message '$name'\n from $codefn line $. is not listed in $pod\n".
403 " (but it wasn't documented in 5.10 either, so marking it TODO)."
407 # We found an actual valid entry in perldiag.pod for this error.
411 if $entries{$key}{cattodo};
413 # Now check the category and severity
415 # Cache our severity qr thingies
418 my $qr = $qrs{$severity} ||= qr/$severity/;
420 like($entries{$key}{severity}, $qr,
422 ? "severity is one of $severity for $key"
423 : "severity is $severity for $key");
425 is($entries{$key}{category}, $categories,
426 ($categories ? "categories are [$categories]" : "no category")
435 check_message($_,$codefn,$severity,$categories,1) or $ok = 0, last
436 for split /\n/, $name;
440 } elsif ($make_exceptions_list) {
441 # We're making an updated version of the exception list, to
442 # stick in the __DATA__ section. I honestly can't think of
443 # a situation where this is the right thing to do, but I'm
444 # leaving it here, just in case one of my descendents thinks
446 print STDERR "$key\n";
448 # No listing found, and no excuse either.
449 # Find the correct place in perldiag.pod, and add a stanza beginning =item $name.
451 diag(" Message '$name'\n from $codefn line $. is not listed in $pod");
453 # seen it, so only fail once for this message
454 $entries{$name}{seen}++;
457 die if $name =~ /%$/;
461 # Lists all missing things as of the inauguration of this script, so we
462 # don't have to go from "meh" to perfect all at once.
464 # PLEASE DO NOT ADD TO THIS LIST. Instead, write an entry in
465 # pod/perldiag.pod for your new (warning|error). Nevertheless,
466 # listing exceptions here when this script is not smart enough
467 # to recognize the messages is not so bad, as long as there are
468 # entries in perldiag.
470 # Entries after __CATEGORIES__ are those that are in perldiag but fail the
471 # severity/category test.
473 # Also FIXME this test, as the first entry in TODO *is* covered by the
474 # description: Malformed UTF-8 character (%s)
476 Malformed UTF-8 character (unexpected non-continuation byte 0x%x, immediately after start byte 0x%x)
478 Cannot apply "%s" in non-PerlIO perl
480 Can't find DLL name for the module `%s' by the handle %d, rc=%u=%x
481 Can't find string terminator %c%s%c anywhere before EOF
482 Can't fix broken locale name "%s"
483 Can't get short module name from a handle
484 Can't load DLL `%s', possible problematic module `%s'
486 Can't locate object method "%s" via package "%s" (perhaps you forgot to load "%s"?)
488 Can't set type on DOS
491 Can't %s script `%s' with ARGV[0] being `%s'
493 Can't %s `%s' with ARGV[0] being `%s' (looking for executables only, not found)
494 Can't use string ("%s"%s) as a subroutine ref while "strict refs" in use
495 Character(s) in '%c' format wrapped in %s
496 chown not implemented!
498 Code missing after '/' in pack
499 Code missing after '/' in unpack
500 Could not find version 1.1 of winsock dll
501 Could not find version 2.0 of winsock dll
502 '%c' outside of string in pack
503 Debug leaking scalars child failed%s with errno %d: %s
504 detach of a thread which could not start
505 detach on an already detached thread
506 detach on a thread with a waiter
507 '/' does not take a repeat count in %s
508 -Dp not implemented on this platform
509 Empty array reference given to mod2fname
510 endhostent not implemented!
511 endnetent not implemented!
512 endprotoent not implemented!
513 endservent not implemented!
514 Error loading module '%s': %s
515 Error reading "%s": %s
516 execl not implemented!
517 EVAL without pos change exceeded limit in regex
518 Filehandle opened only for %sput
519 Filehandle %s opened only for %sput
520 Filehandle STD%s reopened as %s only for input
521 file_type not implemented on DOS
522 filter_del can only delete in reverse order (currently)
524 fork() not implemented!
525 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!
527 Free to wrong pool %p not %p
528 Function "endnetent" not implemented in this version of perl.
529 Function "endprotoent" not implemented in this version of perl.
530 Function "endservent" not implemented in this version of perl.
531 Function "getnetbyaddr" not implemented in this version of perl.
532 Function "getnetbyname" not implemented in this version of perl.
533 Function "getnetent" not implemented in this version of perl.
534 Function "getprotobyname" not implemented in this version of perl.
535 Function "getprotobynumber" not implemented in this version of perl.
536 Function "getprotoent" not implemented in this version of perl.
537 Function "getservbyport" not implemented in this version of perl.
538 Function "getservent" not implemented in this version of perl.
539 Function "getsockopt" not implemented in this version of perl.
540 Function "recvmsg" not implemented in this version of perl.
541 Function "sendmsg" not implemented in this version of perl.
542 Function "sethostent" not implemented in this version of perl.
543 Function "setnetent" not implemented in this version of perl.
544 Function "setprotoent" not implemented in this version of perl.
545 Function "setservent" not implemented in this version of perl.
546 Function "setsockopt" not implemented in this version of perl.
547 Function "tcdrain" not implemented in this version of perl.
548 Function "tcflow" not implemented in this version of perl.
549 Function "tcflush" not implemented in this version of perl.
550 Function "tcsendbreak" not implemented in this version of perl.
552 gethostent not implemented!
553 getnetbyaddr not implemented!
554 getnetbyname not implemented!
555 getnetent not implemented!
556 getprotoent not implemented!
557 getpwnam returned invalid UIC %o for user "%s"
558 getservent not implemented!
559 glob failed (can't start child: %s)
560 glob failed (child exited with status %d%s)
561 Got an error from DosAllocMem: %i
562 Goto undefined subroutine
563 Goto undefined subroutine &%s
565 ()-group starts with a count in %s
566 Illegal binary digit '%c' ignored
567 Illegal character %sin prototype for %s : %s
568 Illegal hexadecimal digit '%c' ignored
569 Illegal octal digit '%c' ignored
570 INSTALL_PREFIX too long: `%s'
571 Invalid argument to sv_cat_decode
572 Invalid range "%c-%c" in transliteration operator
573 Invalid separator character %c%c%c in PerlIO layer specification %s
574 Invalid TOKEN object ignored
575 Invalid type '%c' in pack
576 Invalid type '%c' in %s
577 Invalid type '%c' in unpack
578 Invalid type ',' in %s
579 ioctl implemented only on sockets
580 ioctlsocket not implemented!
581 join with a thread with a waiter
582 killpg not implemented!
583 List form of pipe open not implemented
584 Looks like we have no PM; will not load DLL %s without $ENV{PERL_ASIF_PM}
585 Malformed integer in [] in %s
587 Malformed UTF-8 character (fatal)
588 Missing (suid) fd script name
589 More than one argument to open
590 More than one argument to open(,':%s')
592 No %s allowed while running setgid
593 No %s allowed with (suid) fdscript
594 Not an XSUB reference
595 Not a reference given to mod2fname
596 Not array reference given to mod2fname
597 Operator or semicolon missing before %c%s
598 Out of memory during list extend
600 PerlApp::TextQuery: no arguments, please
601 POSIX syntax [%c %c] is reserved for future extensions in regex; marked by <-- HERE in m/%s/
602 ptr wrong %p != %p fl=%x nl=%p e=%p for %d
604 Recompile perl with -DDEBUGGING to use -D switch (did you mean -d ?)
605 recursion detected in %s
606 Regexp *+ operand could be empty in regex; marked by <-- HERE in m/%s/
607 Reversed %c= operator
608 %s: Can't parse EXE/DLL name: '%s'
610 %sCompilation failed in require
611 %s: Error stripping dirs from EXE/DLL/INSTALLDIR name
612 sethostent not implemented!
613 setnetent not implemented!
614 setprotoent not implemented!
616 setservent not implemented!
617 %s free() ignored (RMAGIC, PERL_CORE)
618 %s has too many errors.
619 SIG%s handler "%s" not defined.
621 Size magic not implemented
622 %s: name `%s' too long
624 %s number > %s non-portable
625 %srealloc() %signored
628 socketpair not implemented!
630 Starting Full Screen process with flag=%d, mytype=%d
631 Starting PM process with flag=%d, mytype=%d
632 sv_2iv assumed (U_V(fabs((double)SvNVX(sv))) < (UV)IV_MAX) but SvNVX(sv)=%f U_V is 0x%x, IV_MAX is 0x%x
633 switching effective gid is not implemented
634 switching effective uid is not implemented
635 System V IPC is not implemented on this machine
636 Terminating on signal SIG%s(%d)
637 The crypt() function is not implemented on NetWare
638 The flock() function is not implemented on NetWare
639 The rewinddir() function is not implemented on NetWare
640 The seekdir() function is not implemented on NetWare
641 The telldir() function is not implemented on NetWare
642 This perl was compiled without taint support. Cowardly refusing to run with -t or -T flags
643 This version of OS/2 does not support %s.%s
644 Too deeply nested ()-groups in %s
645 Too many args on %s line of "%s"
646 U0 mode on a byte string
647 unable to find VMSPIPE.COM for i/o piping
648 Unable to locate winsock library!
649 Unexpected program mode %d when morphing back from PM
650 Unrecognized character %s; marked by <-- HERE after %s<-- HERE near column %d
651 Unstable directory path, current directory changed unexpectedly
652 Unterminated compressed integer in unpack
655 Usage: CODE(0x%x)(%s)
656 Usage: File::Copy::rmscopy(from,to[,date_flag])
657 Usage: VMS::Filespec::candelete(spec)
658 Usage: VMS::Filespec::fileify(spec)
659 Usage: VMS::Filespec::pathify(spec)
660 Usage: VMS::Filespec::rmsexpand(spec[,defspec])
661 Usage: VMS::Filespec::unixify(spec)
662 Usage: VMS::Filespec::unixpath(spec)
663 Usage: VMS::Filespec::unixrealpath(spec)
664 Usage: VMS::Filespec::vmsify(spec)
665 Usage: VMS::Filespec::vmspath(spec)
666 Usage: VMS::Filespec::vmsrealpath(spec)
667 Use of inherited AUTOLOAD for non-method %s::%s() is deprecated
668 utf8 "\x%X" does not map to Unicode
669 Value of logical "%s" too long. Truncating to %i bytes
670 waitpid: process %x is not a child of process %x
673 win32_get_osfhandle() TBD on this platform
674 win32_open_osfhandle() TBD on this platform
675 Within []-length '*' not allowed in %s
676 Within []-length '%c' not allowed in %s
677 Wrong size of loadOrdinals array: expected %d, actual %d
678 Wrong syntax (suid) fd script name "%s"
679 'X' outside of string in %s
680 'X' outside of string in unpack
684 # This is a warning, but is currently followed immediately by a croak (toke.c)
685 Illegal character \%o (carriage return)
687 # Because uses WARN_MISSING as a synonym for WARN_UNINITIALIZED (sv.c)
688 Missing argument in %s
690 # This message can be both fatal and non-
691 False [] range "%s" in regex; marked by <-- HERE in m/%s/