This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
newCONSTSUB needs its own CV.
authorCraig A. Berry <craigberry@mac.com>
Fri, 17 Aug 2012 16:05:14 +0000 (11:05 -0500)
committerCraig A. Berry <craigberry@mac.com>
Fri, 17 Aug 2012 16:15:05 +0000 (11:15 -0500)
It had been using one called simply C<cv> but that name is already
taken in the (opaque) argument list generated by the XS_EUPXS
wrapper around the function name.  And that cv is actually used
by boilerplate code generated from PPCODE, but only when there is
an ALIAS section present, which there wasn't before c0810f8ef84,
but now is.

So declare and use our own CV and leave the one passed in alone.

ext/XS-APItest/APItest.xs

index 0979aee..ffe0c43 100644 (file)
@@ -1965,23 +1965,23 @@ newCONSTSUB(stash, name, flags, sv)
     ALIAS:
        newCONSTSUB_flags = 1
     PREINIT:
-       CV* cv;
+       CV* mycv;
        STRLEN len;
        const char *pv = SvPV(name, len);
     PPCODE:
         switch (ix) {
            case 0:
-              cv = newCONSTSUB(stash, pv, SvOK(sv) ? SvREFCNT_inc(sv) : NULL);
+               mycv = newCONSTSUB(stash, pv, SvOK(sv) ? SvREFCNT_inc(sv) : NULL);
                break;
            case 1:
-               cv = newCONSTSUB_flags(
+               mycv = newCONSTSUB_flags(
                  stash, pv, len, flags | SvUTF8(name), SvOK(sv) ? SvREFCNT_inc(sv) : NULL
                );
                break;
         }
         EXTEND(SP, 2);
-        PUSHs( CvCONST(cv) ? &PL_sv_yes : &PL_sv_no );
-       PUSHs((SV*)CvGV(cv));
+        PUSHs( CvCONST(mycv) ? &PL_sv_yes : &PL_sv_no );
+        PUSHs((SV*)CvGV(mycv));
 
 void
 gv_init_type(namesv, multi, flags, type)