diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-01-26 16:16:29 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-01-26 16:16:29 +0000 |
commit | d9095cec1bba87df718f5a1d0a9ab42fe217cea4 (patch) | |
tree | c9fa8049db941c9278d890ee93ab5c93553b70d7 /gv.c | |
parent | abf8b121784743d34fc5407ef35129d1bbdffb2d (diff) | |
download | perl-d9095cec1bba87df718f5a1d0a9ab42fe217cea4.tar.gz |
Stop S_incline needing to temporarily write a '\0' into its passed-in
buffer. (Requires adding gv_fetchfile_flags(), savesharedpvn() and
CopFILE_setn() to provide pointer/length versions of APIs)
p4raw-id: //depot/perl@30015
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -104,31 +104,39 @@ Perl_gv_IOadd(pTHX_ register GV *gv) GV * Perl_gv_fetchfile(pTHX_ const char *name) { + return gv_fetchfile_flags(name, strlen(name), 0); +} + +GV * +Perl_gv_fetchfile_flags(pTHX_ const char *const name, const STRLEN namelen, + const U32 flags) +{ dVAR; char smallbuf[128]; char *tmpbuf; - STRLEN tmplen; + const STRLEN tmplen = namelen + 2; GV *gv; + PERL_UNUSED_ARG(flags); + if (!PL_defstash) return NULL; - tmplen = strlen(name); - if (tmplen + 2 <= sizeof smallbuf) + if (tmplen <= sizeof smallbuf) tmpbuf = smallbuf; else Newx(tmpbuf, tmplen, char); /* This is where the debugger's %{"::_<$filename"} hash is created */ tmpbuf[0] = '_'; tmpbuf[1] = '<'; - memcpy(tmpbuf + 2, name, tmplen); - gv = *(GV**)hv_fetch(PL_defstash, tmpbuf, tmplen + 2, TRUE); + memcpy(tmpbuf + 2, name, namelen); + gv = *(GV**)hv_fetch(PL_defstash, tmpbuf, tmplen, TRUE); if (!isGV(gv)) { - gv_init(gv, PL_defstash, tmpbuf, tmplen + 2, FALSE); + gv_init(gv, PL_defstash, tmpbuf, tmplen, FALSE); #ifdef PERL_DONT_CREATE_GVSV - GvSV(gv) = newSVpvn(name, tmplen); + GvSV(gv) = newSVpvn(name, namelen); #else - sv_setpvn(GvSV(gv), name, tmplen); + sv_setpvn(GvSV(gv), name, namelen); #endif if (PERLDB_LINE) hv_magic(GvHVn(gv_AVadd(gv)), NULL, PERL_MAGIC_dbfile); |