This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
parts/apicheck.pl: Handle identifier containing 'const'
authorKarl Williamson <khw@cpan.org>
Tue, 25 Jun 2019 17:35:51 +0000 (11:35 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 27 Sep 2019 22:39:29 +0000 (16:39 -0600)
While reading the code, I realized that if an identifier name contained
the substring 'const' this wouldn't work.  It's a simple matter to add
\b to prevent this unlikely scenario.

(cherry picked from commit eaa9c034d31c5a167bf85b6888fed5201bf0667f)
Signed-off-by: Nicolas R <atoomic@cpan.org>
dist/Devel-PPPort/parts/apicheck.pl

index 65ece66..e043690 100644 (file)
@@ -220,7 +220,7 @@ for $f (@f) {
     }
     my($n, $p, $d) = $a =~ /^ (\w+(?:\s+\w+)*)\s*  # type name  => $n
                               (\**)                # pointer    => $p
-                              (?:\s*const\s*)?     # const
+                              (?:\s*\bconst\b\s*)? # const
                               ((?:\[[^\]]*\])*)    # dimension  => $d
                             $/x
                      or die "$0 - cannot parse argument: [$a]\n";
@@ -229,7 +229,7 @@ for $f (@f) {
       next;
     }
     $n = $tmap{$n} || $n;
-    if ($n eq 'const char' and $p eq '*' and !$f->{flags}{f}) {
+    if ($n =~ /\bconst\s+char\b/ and $p eq '*' and !$f->{flags}{f}) {
       push @arg, '"foo"';
     }
     else {