/* fake up C<use attributes $pkg,$rv,@attrs> */
ENTER; /* need to protect against side-effects of 'use' */
SAVEINT(PL_expect);
- if (stash)
- stashsv = newSVpvn(HvNAME_get(stash), HvNAMELEN_get(stash));
- else
- stashsv = &PL_sv_no;
+ stashsv = stash ? newSVhek(HvNAME_HEK(stash)) : &PL_sv_no;
#define ATTRSMODULE "attributes"
#define ATTRSMODULE_PM "attributes.pm"
pack = newSVOP(OP_CONST, 0, newSVpvn(ATTRSMODULE, sizeof(ATTRSMODULE)-1));
/* Build up the real arg-list. */
- if (stash)
- stashsv = newSVpvn(HvNAME_get(stash), HvNAMELEN_get(stash));
- else
- stashsv = &PL_sv_no;
+ stashsv = stash ? newSVhek(HvNAME_HEK(stash)) : &PL_sv_no;
+
arg = newOP(OP_PADSV, 0);
arg->op_targ = target->op_targ;
arg = prepend_elem(OP_LIST,
break;
case 'P':
if (strEQ(elem2, "ACKAGE")) {
- const char *name = HvNAME_get(GvSTASH(gv));
- sv = newSVpvn(name ? name : "__ANON__",
- name ? HvNAMELEN_get(GvSTASH(gv)) : 8);
+ const HEK *hek = HvNAME_HEK(GvSTASH(gv));
+ sv = hek ? newSVhek(hek) : newSVpvn("__ANON__", 8);
}
break;
case 'S':
=for apidoc newSVpv_hek
Creates a new SV from the hash key structure. It will generate scalars that
-point to the shared string table where possible.
+point to the shared string table where possible. Returns a new (undefined)
+SV if the hek is NULL.
=cut
*/
SV *
Perl_newSVhek(pTHX_ const HEK *hek)
{
+ if (!hek) {
+ SV *sv;
+
+ new_SV(sv);
+ return sv;
+ }
+
if (HEK_LEN(hek) == HEf_SVKEY) {
return newSVsv(*(SV**)HEK_KEY(hek));
} else {
case KEY___PACKAGE__:
yylval.opval = (OP*)newSVOP(OP_CONST, 0,
(PL_curstash
- ? newSVpvn(HvNAME_get(PL_curstash),
- HvNAMELEN_get(PL_curstash))
+ ? newSVhek(HvNAME_HEK(PL_curstash))
: &PL_sv_undef));
TERM(THING);
/* build ops for a bareword */
HV *stash = PAD_COMPNAME_OURSTASH(tmp);
HEK *stashname = HvNAME_HEK(stash);
- SV *sym = stashname
- ? newSVpvn(HEK_KEY(stashname), HEK_LEN(stashname))
- : newSVpvn(0, 0);
+ SV *sym = newSVhek(stashname);
sv_catpvn(sym, "::", 2);
sv_catpv(sym, PL_tokenbuf+1);
yylval.opval = (OP*)newSVOP(OP_CONST, 0, sym);
if (PAD_COMPNAME_FLAGS(tmp) & SVpad_OUR) {
HV *stash = PAD_COMPNAME_OURSTASH(tmp);
HEK *stashname = HvNAME_HEK(stash);
- SV *sym = sv_2mortal(stashname
- ? newSVpvn(HEK_KEY(stashname),
- HEK_LEN(stashname))
- : newSVpvn(0, 0));
+ SV *sym = sv_2mortal(newSVhek(stashname));
sv_catpvn(sym, "::", 2);
sv_catpv(sym, d+1);
d = SvPVX(sym);