14 # --make-exceptions-list outputs the list of strings that don't have
15 # perldiag.pod entries to STDERR without TAP formatting, so they can
16 # easily be put in the __DATA__ section of this file. This was done
17 # initially so as to not create new test failures upon the initial
18 # creation of this test file. You probably shouldn't do it again.
19 # Just add the documentation instead.
20 my $make_exceptions_list = ($ARGV[0]||'') eq '--make-exceptions-list';
22 chdir '..' or die "Can't chdir ..: $!";
23 BEGIN { defined $ENV{PERL_UNICODE} and push @INC, "lib"; }
27 open my $func_fh, "<", "embed.fnc" or die "Can't open embed.fnc: $!";
29 # Look for functions in embed.fnc that look like they could be diagnostic ones.
33 while (s/\s*\\$//) { # Grab up all continuation lines, these end in \
34 my $next = <$func_fh>;
39 next if /^:/; # Lines beginning with colon are comments.
40 next unless /\|/; # Lines without a vertical bar are something we can't deal
42 my @fields = split /\s*\|\s*/;
43 next unless $fields[2] =~ /warn|err|(\b|_)die|croak/i;
44 push @functions, $fields[2];
46 # The flag p means that this function may have a 'Perl_' prefix
47 # The flag s means that this function may have a 'S_' prefix
48 push @functions, "Perl_$fields[2]", if $fields[0] =~ /p/;
49 push @functions, "S_$fields[2]", if $fields[0] =~ /s/;
54 my $regcomp_re = "(?<routine>(?:ckWARN(?:\\d+)?reg\\w*|vWARN\\d+))";
55 my $function_re = join '|', @functions;
56 my $regcomp_fail_re = '\b(?:(?:Simple_)?v)?FAIL[2-4]?\b';
58 "(?<routine>\\bDIE\\b|$function_re|$regcomp_fail_re)";
59 my $text_re = '"(?<text>(?:\\\\"|[^"]|"\s*[A-Z_]+\s*")*)"';
60 my $source_msg_call_re = qr/$source_msg_re(?:_nocontext)? \s*
62 (?:packWARN\d*\((?<category>.*?)\),)? \s*
64 my $bad_version_re = qr{BADVERSION\([^"]*$text_re};
65 $regcomp_fail_re = qr/$regcomp_fail_re\([^"]*$text_re/;
66 my $regcomp_call_re = qr/$regcomp_re.*?$text_re/;
70 # Get the ignores that are compiled into this file
71 my $reading_categorical_exceptions;
74 $entries{$_}{$reading_categorical_exceptions ? 'cattodo' : 'todo'}=1;
75 /__CATEGORIES__/ and ++$reading_categorical_exceptions;
78 my $pod = "pod/perldiag.pod";
80 open my $diagfh, "<", $pod
81 or die "Can't open $pod: $!";
83 my $category_re = qr/ [a-z0-9_:]+?/; # Note: requires an initial space
84 my $severity_re = qr/ . (?: \| . )* /x; # A severity is a single char, but can
85 # be of the form 'S|P|W'
91 # Allow multi-line headers
100 $cur_entry =~ s/\n/ /gs; # Fix multi-line headers if they have \n's
101 $cur_entry =~ s/\s+\z//;
103 if (exists $entries{$cur_entry} && $entries{$cur_entry}{todo}) {
105 local $::TODO = "Remove the TODO entry \"$cur_entry\" from DATA as it is already in $pod near line $.";
109 # Make sure to init this here, so an actual entry in perldiag
110 # overwrites one in DATA.
111 $entries{$cur_entry}{todo} = 0;
112 $entries{$cur_entry}{line_number} = $.;
115 next if ! defined $cur_entry;
117 if (! $entries{$cur_entry}{severity}) {
118 if (/^ \( ( $severity_re )
120 # Can have multiple categories separated by commas
121 ( $category_re (?: , $category_re)* )? \) /x)
123 $entries{$cur_entry}{severity} = $1;
124 $entries{$cur_entry}{category} =
125 $2 && join ", ", sort split " ", $2 =~ y/,//dr;
127 # Record it also for other messages sharing the same description
128 @$_{qw<severity category>} =
129 @{$entries{$cur_entry}}{qw<severity category>}
132 elsif (! $entries{$cur_entry}{first_line} && $_ =~ /\S/) {
134 # Keep track of first line of text if doesn't contain a severity, so
135 # that can later examine it to determine if that is ok or not
136 $entries{$cur_entry}{first_line} = $_;
142 push @same_descr, $entries{$cur_entry};
147 foreach my $cur_entry ( keys %entries) {
148 next if $entries{$cur_entry}{todo}; # If in this file, won't have a severity
149 if (! exists $entries{$cur_entry}{severity}
151 # If there is no first line, it was two =items in a row, so the
152 # second one is the one with with text, not this one.
153 && exists $entries{$cur_entry}{first_line}
155 # If the first line refers to another message, no need for severity
156 && $entries{$cur_entry}{first_line} !~ /^See/)
160 " $pod entry at line $entries{$cur_entry}{line_number}\n"
161 . " \"$cur_entry\"\n"
162 . " is missing a severity and/or category"
167 # List from perlguts.pod "Formatted Printing of IVs, UVs, and NVs"
168 # Convert from internal formats to ones that the readers will be familiar
169 # with, while removing any format modifiers, such as precision, the
170 # presence of which would just confuse the pod's explanation
171 my %specialformats = (IVdf => 'd',
184 my $format_modifiers = qr/ [#0\ +-]* # optional flags
185 (?: [1-9][0-9]* | \* )? # optional field width
186 (?: \. \d* )? # optional precision
187 (?: h|l )? # optional length modifier
191 join '|', sort { length $b cmp length $a } keys %specialformats;
192 my $specialformats_re = qr/%$format_modifiers"\s*($specialformats)(\s*")?/;
194 # Recursively descend looking for source files.
197 my $todo = shift @todo;
198 next if $todo ~~ ['t', 'lib', 'ext', 'dist', 'cpan'];
199 # opmini.c is just a copy of op.c, so there's no need to check again.
200 next if $todo eq 'opmini.c';
202 unshift @todo, sort glob "$todo/*";
203 } elsif ($todo =~ m/\.[ch]$/) {
208 # Standardize messages with variants into the form that appears
209 # in perldiag.pod -- useful for things without a diag_listed_as annotation
213 if ( $name =~ m/^(Invalid strict version format) \([^\)]*\)/ ) {
216 elsif ( $name =~ m/^(Invalid version format) \([^\)]*\)/ ) {
219 elsif ($name =~ m/^panic: /) {
220 $name = "panic: \%s";
229 print "# Checking $codefn\n";
231 open my $codefh, "<", $codefn
232 or die "Can't open $codefn: $!";
236 my $sub = 'top of file';
239 # Getting too much here isn't a problem; we only use this to skip
240 # errors inside of XS modules, which should get documented in the
241 # docs for the module.
242 if (m<^[^#\s]> and $_ !~ m/^[{}]*$/) {
245 next if $sub =~ m/^XS/;
246 if (m</\*\s*diag_listed_as: (.*?)\s*\*/>) {
248 $listed_as_line = $.+1;
253 # Loop to accumulate the message text all on one line.
254 if (m/(?:$source_msg_re(?:_nocontext)?|$regcomp_re)\s*\(/) {
255 while (not m/\);$/) {
256 my $nextline = <$codefh>;
257 # Means we fell off the end of the file. Not terribly surprising;
258 # this code tries to merge a lot of things that aren't regular C
259 # code (preprocessor stuff, long comments). That's OK; we don't
261 last if not defined $nextline;
263 $nextline =~ s/^\s+//;
265 # Note that we only want to do this where *both* are true.
266 if ($_ =~ m/"$/ and $nextline =~ m/^"/) {
274 # This should happen *after* unwrapping, or we don't reformat the things
277 s/$specialformats_re/"%$specialformats{$1}" . (defined $2 ? '' : '"')/ge;
279 # Remove any remaining format modifiers, but not in %%
280 s/ (?<!%) % $format_modifiers ( [dioxXucsfeEgGp] ) /%$1/xg;
282 # The %"foo" thing needs to happen *before* this regex.
284 # DIE is just return Perl_die
285 my ($name, $category, $routine);
286 if (/$source_msg_call_re/) {
287 ($name, $category, $routine) = ($+{'text'}, $+{'category'}, $+{'routine'});
288 # Sometimes the regexp will pick up too much for the category
289 # e.g., WARN_UNINITIALIZED), PL_warn_uninit_sv ... up to the next )
290 $category && $category =~ s/\).*//s;
292 elsif (/$bad_version_re/) {
293 ($name, $category) = ($+{'text'}, undef);
295 elsif (/$regcomp_fail_re/) {
296 # FAIL("foo") -> "foo in regex m/%s/"
297 # vFAIL("foo") -> "foo in regex; marked by <-- HERE in m/%s/"
298 ($name, $category) = ($+{'text'}, undef);
300 " in regex" . ("; marked by <-- HERE in" x /vFAIL/) . " m/%s/";
302 elsif (/$regcomp_call_re/) {
303 # vWARN/ckWARNreg("foo") -> "foo in regex; marked by <-- HERE in m/%s/
304 ($name, $category, $routine) = ($+{'text'}, undef, $+{'routine'});
305 $name .= " in regex; marked by <-- HERE in m/%s/";
306 $category = 'WARN_REGEXP';
307 if ($routine =~ /dep/) {
308 $category .= ',WARN_DEPRECATED';
315 my $severity = !$routine ? '[PFX]'
316 : $routine =~ /warn.*_d\z/ ? '[DS]'
317 : $routine =~ /warn/ ? '[WDS]'
318 : $routine =~ /ckWARN\d*reg/ ? '[WDS]'
319 : $routine =~ /vWARN\d/ ? '[WDS]'
322 if (defined $category) {
323 $category =~ s/__/::/g;
326 sort map {s/^WARN_//; lc $_} split /\s*[|,]\s*/, $category;
328 if ($listed_as and $listed_as_line == $. - $multiline) {
331 # The form listed in perldiag ignores most sorts of fancy printf
332 # formatting, or makes it more perlish.
334 $name =~ s/%l[ud]/%d/g;
335 $name =~ s/%\.(\d+|\*)s/\%s/g;
336 $name =~ s/(?:%s){2,}/%s/g;
337 $name =~ s/(\\")|("\s*[A-Z_]+\s*")/$1 ? '"' : '%s'/egg;
341 $name =~ s/(\\)\\/$1/g;
344 # Extra explanatory info on an already-listed error, doesn't
345 # need it's own listing.
346 next if $name =~ m/^\t/;
348 # Happens fairly often with PL_no_modify.
349 next if $name eq '%s';
351 # Special syntax for magic comment, allows ignoring the fact
352 # that it isn't listed. Only use in very special circumstances,
353 # like this script failing to notice that the Perl_croak call is
354 # inside an #if 0 block.
355 next if $name eq 'SKIPME';
357 check_message(standardize($name),$codefn,$severity,$categories);
362 my($name,$codefn,$severity,$categories,$partial) = @_;
363 my $key = $name =~ y/\n/ /r;
366 # Try to reduce printf() formats to simplest forms
367 # Really this should be matching %s, etc like diagnostics.pm does
370 $key =~ s/%[#0\-+]/%/g;
373 $key =~ s/\%(\d+|\*)/%/g;
376 $key =~ s/\%\.(\d+|\*)/%/g;
378 if (exists $entries{$key}) {
380 if ( $entries{$key}{seen}++ ) {
381 # no need to repeat entries we've tested
382 } elsif ($entries{$key}{todo}) {
385 local $::TODO = 'in DATA';
386 # There is no listing, but it is in the list of exceptions. TODO FAIL.
389 " Message '$name'\n from $codefn line $. is not listed in $pod\n".
390 " (but it wasn't documented in 5.10 either, so marking it TODO)."
394 # We found an actual valid entry in perldiag.pod for this error.
397 # Now check the category and severity
399 # Cache our severity qr thingies
402 my $qr = $qrs{$severity} ||= qr/$severity/;
405 if $entries{$key}{cattodo};
407 like $entries{$key}{severity}, $qr,
408 "severity is one of $severity for $key";
410 is $entries{$key}{category}, $categories,
411 ($categories ? "categories are [$categories]" : "no category")
414 # Later, should start checking that the severity is correct, too.
421 check_message($_,$codefn,$severity,$categories,1) or $ok = 0, last
422 for split /\n/, $name;
426 } elsif ($make_exceptions_list) {
427 # We're making an updated version of the exception list, to
428 # stick in the __DATA__ section. I honestly can't think of
429 # a situation where this is the right thing to do, but I'm
430 # leaving it here, just in case one of my descendents thinks
432 print STDERR "$key\n";
434 # No listing found, and no excuse either.
435 # Find the correct place in perldiag.pod, and add a stanza beginning =item $name.
437 diag(" Message '$name'\n from $codefn line $. is not listed in $pod");
439 # seen it, so only fail once for this message
440 $entries{$name}{seen}++;
443 die if $name =~ /%$/;
447 # Lists all missing things as of the inauguration of this script, so we
448 # don't have to go from "meh" to perfect all at once.
450 # PLEASE DO NOT ADD TO THIS LIST. Instead, write an entry in
451 # pod/perldiag.pod for your new (warning|error).
453 # Entries after __CATEGORIES__ are those that are in perldiag but fail the
454 # severity/category test.
456 # Also FIXME this test, as the first entry in TODO *is* covered by the
457 # description: Malformed UTF-8 character (%s)
459 Malformed UTF-8 character (unexpected non-continuation byte 0x%x, immediately after start byte 0x%x)
461 '%c' allowed only after types %s in %s
462 bad top format reference
463 Cannot apply "%s" in non-PerlIO perl
464 Can't %s big-endian %ss on this
465 Can't call mro_isa_changed_in() on anonymous symbol table
466 Can't call mro_method_changed_in() on anonymous symbol table
467 Can't coerce readonly %s to string
468 Can't coerce readonly %s to string in %s
469 Can't find string terminator %c%s%c anywhere before EOF
470 Can't fix broken locale name "%s"
471 Can't get short module name from a handle
472 Can't locate object method "%s" via package "%s" (perhaps you forgot to load "%s"?)
476 Can't %s script `%s' with ARGV[0] being `%s'
478 Can't %s `%s' with ARGV[0] being `%s' (looking for executables only, not found)
479 Can't use string ("%s"%s) as a subroutine ref while "strict refs" in use
480 \%c better written as $%c
481 Character(s) in '%c' format wrapped in %s
482 chown not implemented!
484 Code missing after '/' in pack
485 Code missing after '/' in unpack
486 Corrupted regexp opcode %d > %d
487 '%c' outside of string in pack
488 Debug leaking scalars child failed%s with errno %d: %s
489 '/' does not take a repeat count in %s
490 Don't know how to get file name
491 Don't know how to handle magic of type \%o
492 -Dp not implemented on this platform
493 Empty \%c{} in regex; marked by <-- HERE in m/%s/
494 Error reading "%s": %s
495 execl not implemented!
496 EVAL without pos change exceeded limit in regex
497 Expecting close bracket in regex; marked by <-- HERE in m/%s/
498 Filehandle opened only for %sput
499 Filehandle %s opened only for %sput
500 Filehandle STD%s reopened as %s only for input
501 filter_del can only delete in reverse order (currently)
502 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!
503 fork() not implemented!
505 Free to wrong pool %p not %p
507 gethostent not implemented!
508 getpwnam returned invalid UIC %o for user "%s"
509 glob failed (can't start child: %s)
510 glob failed (child exited with status %d%s)
511 Goto undefined subroutine
512 Goto undefined subroutine &%s
514 ()-group starts with a count in %s
515 Illegal binary digit '%c' ignored
516 Illegal character %sin prototype for %s : %s
517 Illegal hexadecimal digit '%c' ignored
518 Illegal octal digit '%c' ignored
519 Illegal pattern in regex; marked by <-- HERE in m/%s/
520 Infinite recursion in regex
521 internal %<num>p might conflict with future printf extensions
522 Invalid argument to sv_cat_decode
523 Invalid [] range "%*.*s" in regex; marked by <-- HERE in m/%s/
524 Invalid range "%c-%c" in transliteration operator
525 Invalid separator character %c%c%c in PerlIO layer specification %s
526 Invalid TOKEN object ignored
527 Invalid type '%c' in pack
528 Invalid type '%c' in %s
529 Invalid type '%c' in unpack
530 Invalid type ',' in %s
531 ioctlsocket not implemented!
532 'j' not supported on this platform
533 'J' not supported on this platform
534 killpg not implemented!
535 length() used on %s (did you mean "scalar(%s)"?)
536 length() used on %hash (did you mean "scalar(keys %hash)"?)
537 length() used on @array (did you mean "scalar(@array)"?)
538 List form of pipe open not implemented
539 Malformed integer in [] in %s
540 Malformed UTF-8 character (fatal)
541 Missing (suid) fd script name
542 More than one argument to open
543 More than one argument to open(,':%s')
544 mprotect for %p %u failed with %d
545 mprotect RW for %p %u failed with %d
546 No %s allowed while running setgid
547 No %s allowed with (suid) fdscript
548 No such class field "%s"
549 Not an XSUB reference
550 Operator or semicolon missing before %c%s
551 Pattern subroutine nesting without pos change exceeded limit in regex
552 Perl %s required--this is only %s, stopped
553 POSIX syntax [%c %c] is reserved for future extensions in regex; marked by <-- HERE in m/%s/
554 ptr wrong %p != %p fl=%x nl=%p e=%p for %d
555 Recompile perl with -DDEBUGGING to use -D switch (did you mean -d ?)
556 Regexp modifier "%c" may appear a maximum of twice in regex; marked by <-- HERE in m/%s/
557 Regexp modifier "%c" may not appear twice in regex; marked by <-- HERE in m/%s/
558 Regexp modifiers "%c" and "%c" are mutually exclusive in regex; marked by <-- HERE in m/%s/
559 Regexp *+ operand could be empty in regex; marked by <-- HERE in m/%s/
560 Repeated format line will never terminate (~~ and @#)
561 Reversed %c= operator
563 %sCompilation failed in require
564 Sequence (?%c...) not implemented in regex; marked by <-- HERE in m/%s/
565 Sequence (%s...) not recognized in regex; marked by <-- HERE in m/%s/
566 Sequence %s... not terminated in regex; marked by <-- HERE in m/%s/
567 Sequence (?%c... not terminated in regex; marked by <-- HERE in m/%s/
568 Sequence (?(%c... not terminated in regex; marked by <-- HERE in m/%s/
569 Sequence (?R) not terminated in regex m/%s/
571 %s free() ignored (RMAGIC, PERL_CORE)
572 %s has too many errors.
573 SIG%s handler "%s" not defined.
575 Size magic not implemented
576 %s number > %s non-portable
577 %srealloc() %signored
580 socketpair not implemented!
581 Starting Full Screen process with flag=%d, mytype=%d
582 Starting PM process with flag=%d, mytype=%d
583 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
584 SWASHNEW didn't return an HV ref
585 switching effective gid is not implemented
586 switching effective uid is not implemented
587 System V IPC is not implemented on this machine
588 -T and -B not implemented on filehandles
589 Terminating on signal SIG%s(%d)
590 The crypt() function is unimplemented due to excessive paranoia.
591 The crypt() function is not implemented on NetWare
592 The flock() function is not implemented on NetWare
593 The rewinddir() function is not implemented on NetWare
594 The seekdir() function is not implemented on NetWare
595 The telldir() function is not implemented on NetWare
596 Too deeply nested ()-groups in %s
597 Too many args on %s line of "%s"
598 U0 mode on a byte string
599 unable to find VMSPIPE.COM for i/o piping
600 Unknown Unicode option value %d
601 Unrecognized character %s; marked by <-- HERE after %s<-- HERE near column %d
602 Unstable directory path, current directory changed unexpectedly
603 Unterminated compressed integer in unpack
604 Unterminated \g... pattern in regex; marked by <-- HERE in m/%s/
605 Usage: CODE(0x%x)(%s)
608 Usage: File::Copy::rmscopy(from,to[,date_flag])
609 Usage: VMS::Filespec::candelete(spec)
610 Usage: VMS::Filespec::fileify(spec)
611 Usage: VMS::Filespec::pathify(spec)
612 Usage: VMS::Filespec::rmsexpand(spec[,defspec])
613 Usage: VMS::Filespec::unixify(spec)
614 Usage: VMS::Filespec::unixpath(spec)
615 Usage: VMS::Filespec::unixrealpath(spec)
616 Usage: VMS::Filespec::vmsify(spec)
617 Usage: VMS::Filespec::vmspath(spec)
618 Usage: VMS::Filespec::vmsrealpath(spec)
619 Use of inherited AUTOLOAD for non-method %s::%s() is deprecated
620 utf8 "\x%X" does not map to Unicode
621 Value of logical "%s" too long. Truncating to %i bytes
622 waitpid: process %x is not a child of process %x
625 Within []-length '*' not allowed in %s
626 Within []-length '%c' not allowed in %s
627 Wrong syntax (suid) fd script name "%s"
628 'X' outside of string in %s
629 'X' outside of string in unpack
630 Useless (%s%c) - %suse /%c modifier in regex; marked by <-- HERE in m/%s/
631 Useless (%sc) - %suse /gc modifier in regex; marked by <-- HERE in m/%s/
632 Useless use of (?-p) in regex; marked by <-- HERE in m/%s/
635 Code point 0x%X is not Unicode, all \p{} matches fail; all \P{} matches succeed
636 Code point 0x%X is not Unicode, may not be portable
637 Illegal character \%o (carriage return)
638 Missing argument in %s
639 Unicode non-character U+%X is illegal for open interchange
640 Operation "%s" returns its argument for non-Unicode code point 0x%X
641 Operation "%s" returns its argument for UTF-16 surrogate U+%X
642 Unicode surrogate U+%X is illegal in UTF-8
643 UTF-16 surrogate U+%X