This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
parts/apicheck.pl: Fix up aTHX
authorKarl Williamson <khw@cpan.org>
Tue, 25 Jun 2019 17:58:35 +0000 (11:58 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 27 Sep 2019 22:39:29 +0000 (16:39 -0600)
Now that we have better flags indicating if a macro or function needs
thread context or not, we can do a better job of handling it.

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

index 5f7cfd5..5bb2a76 100644 (file)
@@ -241,8 +241,8 @@ for $f (@f) {
     }
   }
 
-  unless ($f->{flags}{'T'} || $f->{flags}{'m'}) {
-    $stack = "  dTHX;\n$stack";
+  unless ($f->{flags}{'T'}) {
+    $stack = "  dTHX;\n$stack";     # Harmless to declare even if not needed
     $aTHX = @arg ? 'aTHX_ ' : 'aTHX';
   }
 
@@ -264,11 +264,11 @@ for $f (@f) {
     $stack .= "  $rvt rval;\n";
     $ret = $ignorerv{$f->{name}} ? '(void) ' : "rval = ";
   }
-  my $aTHX_args = "$aTHX$args";
+  my $aTHX_args = "";
 
-  if (!$f->{flags}{'m'} or $f->{flags}{'b'} or @arg > 0) {
+  unless ($f->{flags}{'n'}) {
+    $aTHX_args = "($aTHX$args)";
     $args = "($args)";
-    $aTHX_args = "($aTHX_args)";
   }
 
   print OUT <<HEAD;