~ubuntu-branches/ubuntu/precise/perl/precise

« back to all changes in this revision

Viewing changes to gv.c

  • Committer: Bazaar Package Importer
  • Author(s): Niko Tyni
  • Date: 2011-02-06 11:31:38 UTC
  • mto: (8.2.12 experimental) (1.1.12)
  • mto: This revision was merged to the branch mainline in revision 46.
  • Revision ID: james.westby@ubuntu.com-20110206113138-lzpm3g6rur7i3eyp
Tags: upstream-5.12.3
ImportĀ upstreamĀ versionĀ 5.12.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
248
248
    if (multi || doproto)              /* doproto means it _was_ mentioned */
249
249
        GvMULTI_on(gv);
250
250
    if (doproto) {                      /* Replicate part of newSUB here. */
 
251
        CV *cv;
251
252
        ENTER;
252
253
        if (has_constant) {
 
254
            char *name0 = NULL;
 
255
            if (name[len])
 
256
                /* newCONSTSUB doesn't take a len arg, so make sure we
 
257
                 * give it a \0-terminated string */
 
258
                name0 = savepvn(name,len);
 
259
 
253
260
            /* newCONSTSUB takes ownership of the reference from us.  */
254
 
            GvCV(gv) = newCONSTSUB(stash, name, has_constant);
 
261
            cv = newCONSTSUB(stash, (name0 ? name0 : name), has_constant);
 
262
            if (name0)
 
263
                Safefree(name0);
255
264
            /* If this reference was a copy of another, then the subroutine
256
265
               must have been "imported", by a Perl space assignment to a GV
257
266
               from a reference to CV.  */
259
268
                GvIMPORTED_CV_on(gv);
260
269
        } else {
261
270
            (void) start_subparse(0,0); /* Create empty CV in compcv. */
262
 
            GvCV(gv) = PL_compcv;
 
271
            cv = PL_compcv;
263
272
        }
 
273
        GvCV(gv) = cv;
264
274
        LEAVE;
265
275
 
266
276
        mro_method_changed_in(GvSTASH(gv)); /* sub Foo::bar($) { (shift) } sub ASDF::baz($); *ASDF::baz = \&Foo::bar */
267
 
        CvGV(GvCV(gv)) = gv;
268
 
        CvFILE_set_from_cop(GvCV(gv), PL_curcop);
269
 
        CvSTASH(GvCV(gv)) = PL_curstash;
 
277
        CvGV(cv) = gv;
 
278
        CvFILE_set_from_cop(cv, PL_curcop);
 
279
        CvSTASH(cv) = PL_curstash;
270
280
        if (proto) {
271
 
            sv_usepvn_flags(MUTABLE_SV(GvCV(gv)), proto, protolen,
 
281
            sv_usepvn_flags(MUTABLE_SV(cv), proto, protolen,
272
282
                            SV_HAS_TRAILING_NUL);
273
283
        }
274
284
    }