diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-12-04 22:50:09 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-12-04 22:50:09 +0000 |
commit | c51f309cf368f501b8590fd49c5bad910c416040 (patch) | |
tree | d622254620fede628f464d3ddfe64ea8b2699e1f /util.c | |
parent | 822a6ee07c1423955abb465138d949dbaf6e2088 (diff) | |
download | perl-c51f309cf368f501b8590fd49c5bad910c416040.tar.gz |
Move Perl_get_db_sub() from pp_hot.c to util.c
p4raw-id: //depot/perl@29463
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -5571,6 +5571,42 @@ Perl_my_strlcpy(char *dst, const char *src, Size_t size) } #endif +void +Perl_get_db_sub(pTHX_ SV **svp, CV *cv) +{ + dVAR; + SV * const dbsv = GvSVn(PL_DBsub); + /* We do not care about using sv to call CV; + * it's for informational purposes only. + */ + + save_item(dbsv); + if (!PERLDB_SUB_NN) { + GV * const gv = CvGV(cv); + + if ( svp && ((CvFLAGS(cv) & (CVf_ANON | CVf_CLONED)) + || strEQ(GvNAME(gv), "END") + || ((GvCV(gv) != cv) && /* Could be imported, and old sub redefined. */ + !( (SvTYPE(*svp) == SVt_PVGV) && (GvCV((GV*)*svp) == cv) )))) { + /* Use GV from the stack as a fallback. */ + /* GV is potentially non-unique, or contain different CV. */ + SV * const tmp = newRV((SV*)cv); + sv_setsv(dbsv, tmp); + SvREFCNT_dec(tmp); + } + else { + gv_efullname3(dbsv, gv, NULL); + } + } + else { + const int type = SvTYPE(dbsv); + if (type < SVt_PVIV && type != SVt_IV) + sv_upgrade(dbsv, SVt_PVIV); + (void)SvIOK_on(dbsv); + SvIV_set(dbsv, PTR2IV(cv)); /* Do it the quickest way */ + } +} + /* * Local variables: * c-indentation-style: bsd |