perl/perl-constprint.diff

21 lines
850 B
Diff

--- ./gv.c.orig 2010-05-13 22:01:07.000000000 +0000
+++ ./gv.c 2010-07-28 09:57:06.000000000 +0000
@@ -250,8 +250,16 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, co
if (doproto) { /* Replicate part of newSUB here. */
ENTER;
if (has_constant) {
+ char *name0 = NULL;
+ if (name[len]) {
+ /* newCONSTSUB doesn't take a len arg, so make sure w
+ * give it a \0-terminated string */
+ name0 = savepvn(name, len);
+ }
/* newCONSTSUB takes ownership of the reference from us. */
- GvCV(gv) = newCONSTSUB(stash, name, has_constant);
+ GvCV(gv) = newCONSTSUB(stash, (name0 ? name0 : name), has_constant);
+ if (name0)
+ Safefree(name0);
/* If this reference was a copy of another, then the subroutine
must have been "imported", by a Perl space assignment to a GV
from a reference to CV. */