This means that \0 bytes in symbolic references now work.
p4raw-id: //depot/perl@27028
}
else {
GV *thatgv;
- thatgv = gv_fetchpvn_flags(type, type-tend,
+ thatgv = gv_fetchpvn_flags(type, tend - type,
0, SVt_PVIO);
thatio = GvIO(thatgv);
}
register GV *gv = NULL;
GV**gvp;
I32 len;
- register const char *namend;
+ register const char *name_cursor;
HV *stash = NULL;
const I32 no_init = flags & (GV_NOADD_NOINIT | GV_NOINIT);
const I32 no_expand = flags & GV_NOEXPAND;
const I32 add = flags & ~SVf_UTF8 & ~GV_NOADD_NOINIT & ~GV_NOEXPAND;
-
- PERL_UNUSED_ARG(full_len);
+ const char *const name_end = nambeg + full_len;
+ const char *const name_em1 = name_end - 1;
if (*name == '*' && isALPHA(name[1])) /* accidental stringify on a GV? */
name++;
- for (namend = name; *namend; namend++) {
- if ((*namend == ':' && namend[1] == ':')
- || (*namend == '\'' && namend[1]))
+ for (name_cursor = name; name_cursor < name_end; name_cursor++) {
+ if ((*name_cursor == ':' && name_cursor < name_em1
+ && name_cursor[1] == ':')
+ || (*name_cursor == '\'' && name_cursor[1]))
{
if (!stash)
stash = PL_defstash;
if (!stash || !SvREFCNT(stash)) /* symbol table under destruction */
return Nullgv;
- len = namend - name;
+ len = name_cursor - name;
if (len > 0) {
char smallbuf[128];
char *tmpbuf;
stash = GvHV(gv) = newHV();
if (!HvNAME_get(stash))
- hv_name_set(stash, nambeg, namend - nambeg, 0);
+ hv_name_set(stash, nambeg, name_cursor - nambeg, 0);
}
- if (*namend == ':')
- namend++;
- namend++;
- name = namend;
+ if (*name_cursor == ':')
+ name_cursor++;
+ name_cursor++;
+ name = name_cursor;
if (!*name)
return gv ? gv : (GV*)*hv_fetchs(PL_defstash, "main::", TRUE);
}
}
- len = namend - name;
+ len = name_cursor - name;
/* No stash in name, so see how we can default */
break;
}
if ((s = strchr(argv[0], '='))) {
- *s = '\0';
- sv_setpv(GvSV(gv_fetchpv(argv[0] + 1, TRUE, SVt_PV)), s + 1);
- *s = '=';
+ const char *const start_name = argv[0] + 1;
+ sv_setpv(GvSV(gv_fetchpvn_flags(start_name, s - start_name,
+ TRUE, SVt_PV)), s + 1);
}
else
sv_setiv(GvSV(gv_fetchpv(argv[0]+1,TRUE, SVt_PV)),1);
is ($$name1, undef, 'Nothing before we start');
is ($$name2, undef, 'Nothing before we start');
- $$name2 = "Yummy";
+ $$name1 = "Yummy";
is ($$name1, "Yummy", 'Accessing via the correct name works');
- local $TODO = "NUL bytes truncate in symrefs";
is ($$name2, undef,
'Accessing via a different NUL-containing name gives nothing');
}
gvp = 0;
}
else {
- len = 0;
if (!gv) {
/* Mustn't actually add anything to a symbol table.
But also don't want to "initialise" any placeholder
gv = gv_fetchpvn_flags(PL_tokenbuf, len,
GV_NOADD_NOINIT, SVt_PVCV);
}
+ len = 0;
}
/* if we saw a global override before, get the right name */
/* Resolve to GV now. */
if (SvTYPE(gv) != SVt_PVGV) {
- gv = gv_fetchpvn_flags(PL_tokenbuf, len, 0, SVt_PVCV);
+ gv = gv_fetchpv(PL_tokenbuf, 0, SVt_PVCV);
assert (SvTYPE(gv) == SVt_PVGV);
/* cv must have been some sort of placeholder, so
now needs replacing with a real code reference. */