You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before this patch
=================
The porting/diag.t test tries to make sure every error message emitted
by perl is documented in pod/perldiag.pod. The way it does this is as
follows:
1. Collect list of diagnostic functions by taking all known functions
whose name contains warn, err, die, croak, or deprecate. Add Perl_mess
and anything that starts with PERL_DIAG_. Add the special
(v)FAIL(2,3,4) macros used in regcomp.c.
2. For every input file, scan it line by line.
3. If the line starts with "#", skip it (so we don't find macro
definitions like "#define croak(...) ..." themselves).
4. If the line contains the name of a diagnostic function, collect the
line.
5. If the function name is followed by a simple argument list (basically
"(...)" with at most one level of nested parentheses within), stop.
Otherwise keep collecting lines until we find a line that ends with
");", which we take to be the end of the statement.
6. Join all collected lines into one blob of text and rescan it for the
diagnostic message.
7. Read the next line and repeat (step 3).
There are some issues with this approach. For example, step 5 may end up
eating large chunks of the input file until a ");" line is encountered.
If we're in a header that "#define"s many macros in a row, all of them
will be swallowed here.
Also, while "#define" lines themselves are skipped, the body of the
macro may not be: If the "#define" line ends with a backslash, the rest
of the macro definition (placed on the following lines) will be scanned
as normal.
Finally, there is a bug in the "simple argument list" check in step 5:
It doesn't handle a completely empty argument list (as in
"croak_memory_wrap()", for example), so it starts collecting lines until
it finds the next ");".
After this patch
================
Extend step 3: If the line is a definition of one of the regcomp error
macros (e.g. "#define FAIL2(...)"), skip the entire definition,
including backslash continuation lines. These macros are just wrappers
around croak; they don't emit any particular diagnostics of their own.
Extend step 5: Handle empty argument lists so "croak_memory_wrap()" does
not start a runaway scan for ");".
Extend step 5: When collecting lines, don't just stop at ");", but also
at (or rather just before) lines starting with "#", so we don't blindly
swallow preprocessor directives.
If an error message is not found in perldiag, report the source location
where it is emitted with the number of the first line of its collected
chunk (i.e. the location of the diagnostic function name), not (as
before) the last line of the chunk (i.e. the location of the next ");",
which may be a long ways off).
This exposes one new message in regcomp_internal.h, which has been added
to perldiag.
0 commit comments