develooper Front page | perl.perl5.porters | Postings from April 2003

CvFILE for constant subs

Thread Next
From:
Stephen McCamant
Date:
April 6, 2003 13:39
Subject:
CvFILE for constant subs
Message ID:
16016.36977.667436.279778@syllepsis.MIT.EDU
During the 5.7.x development cycle, constant subroutines were changed
to be XSUBs, making them more memory efficient. Normally when XSUBs
are created, their CvFILE is set to the name of the C source file in
which they were defined; apparently following that logic, the CvFILE
for all constant subroutines was set to "op.c".

It would seem more logical to me for the CvFILE to be set to the name
of the perl file in which the subroutine was defined, since the
XSUBness is an implementation detail. The attached patch makes that
change, and seems to pass the test suite, though I'm not sure if it
should have a savepv() or something else to make sure the string
sticks around long enough.

I noticed this because B::Deparse uses CvFILE to tell which
subroutines to print, and constant subs were disappearing. It looks
like the right file information is available in the GV corresponding
to the CV, though, so Deparse can be fixed even without this change.

 -- Stephen

--- op.c.orig	2003-04-05 02:53:54.000000000 -0500
+++ op.c	2003-04-05 02:55:30.000000000 -0500
@@ -4273,7 +4273,7 @@
 	CopSTASH_set(PL_curcop,stash);
     }
 
-    cv = newXS(name, const_sv_xsub, __FILE__);
+    cv = newXS(name, const_sv_xsub, CopFILE(PL_curcop));
     CvXSUBANY(cv).any_ptr = sv;
     CvCONST_on(cv);
     sv_setpv((SV*)cv, "");  /* prototype is "" */

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About