summaryrefslogtreecommitdiff
path: root/dist/Devel-PPPort/parts/inc/ppphbin
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-07-21 12:43:30 -0600
committerNicolas R <atoomic@cpan.org>2019-09-27 16:51:27 -0600
commit2b5a6a7e2b03329123d6d72b94aff54e4313e27c (patch)
treea65259f8119a5f47d769b9c298e6cd1f5449fd88 /dist/Devel-PPPort/parts/inc/ppphbin
parente63fbd6e6e3c0e48b80d89e8367dc2aa02543d88 (diff)
downloadperl-2b5a6a7e2b03329123d6d72b94aff54e4313e27c.tar.gz
parts/inc/ppphbin: Fix accumulation of Hints/Warnings
Prior to this commit, if any line in the middle of one of these didn't begin with an asterisk (a typical comment continuation marker), the hint was silently discarded. (cherry picked from commit d7b17de7bd53bc7f5c58e0aebeec7420e0de860d) Signed-off-by: Nicolas R <atoomic@cpan.org>
Diffstat (limited to 'dist/Devel-PPPort/parts/inc/ppphbin')
-rw-r--r--dist/Devel-PPPort/parts/inc/ppphbin54
1 files changed, 46 insertions, 8 deletions
diff --git a/dist/Devel-PPPort/parts/inc/ppphbin b/dist/Devel-PPPort/parts/inc/ppphbin
index 5a6597d0d7..ac04f8158d 100644
--- a/dist/Devel-PPPort/parts/inc/ppphbin
+++ b/dist/Devel-PPPort/parts/inc/ppphbin
@@ -115,18 +115,56 @@ sub find_api
while (<DATA>) {
if ($hint) {
+
+ # Here, we are in the middle of accumulating a hint or warning.
+ my $end_of_hint = 0;
+
+ # A line containing a comment end marker closes the hint. Remove that
+ # marker for processing below.
+ if (s/\s*$rcce(.*?)\s*$//) {
+ die "Nothing can follow the end of comment in '$_'\n" if length $1 > 0;
+ $end_of_hint = 1;
+ }
+
+ # Set $h to the hash of which type.
my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings;
- if (m{^\s*\*\s(.*?)\s*$}) {
- for (@{$hint->[1]}) {
- $h->{$_} ||= ''; # suppress warning with older perls
- $h->{$_} .= "$1\n";
- }
+
+ # Ignore any leading and trailing white space, and an optional star comment
+ # continuation marker, then place the meat of the line into $1
+ m/^\s*(?:\*\s*)?(.*?)\s*$/;
+
+ # Add the meat of this line to the hash value of each API element it
+ # applies to
+ for (@{$hint->[1]}) {
+ $h->{$_} ||= ''; # avoid the warning older perls generate
+ $h->{$_} .= "$1\n";
}
- else { undef $hint }
+
+ # If the line had a comment close, we are through with this hint
+ undef $hint if $end_of_hint;
+
+ next;
}
- $hint = [$1, [split /,?\s+/, $2]]
- if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$};
+ # Set up $hint if this is the beginning of a Hint: or Warning:
+ # These are from a multi-line C comment in the file, with the first line
+ # looking like (a space has been inserted because this file can't have C
+ # comment markers in it):
+ # / * Warning: PL_expect, PL_copline, PL_rsfp
+ #
+ # $hint becomes
+ # [
+ # 'Warning',
+ # [
+ # 'PL_expect',
+ # 'PL_copline',
+ # 'PL_rsfp',
+ # ],
+ # ]
+ if (m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}) {
+ $hint = [$1, [split /,?\s+/, $2]];
+ next;
+ }
if ($define) {
if ($define->[1] =~ /\\$/) {