Skip to content

Commit aabd022

Browse files
committed
Dumper.xs: use new SvVSTRING API
Use the new abstraction API rather than direct access to the MAGIC structures.
1 parent df4834b commit aabd022

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

dist/Data-Dumper/Dumper.xs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,8 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
12401240
}
12411241
else {
12421242
STRLEN i;
1243-
const MAGIC *mg;
1243+
STRLEN vstr_len;
1244+
const char *vstr_pv;
12441245

12451246
if (namelen) {
12461247
id_buffer = PTR2UV(val);
@@ -1386,7 +1387,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
13861387
sv_catpvs(retval, "undef");
13871388
}
13881389
#ifdef SvVOK
1389-
else if (SvMAGICAL(val) && (mg = mg_find(val, PERL_MAGIC_vstring))) {
1390+
else if (SvVOK(val) && (vstr_pv = SvVSTRING(val, vstr_len))) {
13901391
# if !defined(PL_vtbl_vstring) && PERL_VERSION_LT(5,17,0)
13911392
SV * const vecsv = sv_newmortal();
13921393
# if PERL_VERSION_LT(5,10,0)
@@ -1396,7 +1397,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
13961397
# endif
13971398
if (!sv_eq(vecsv, val)) goto integer_came_from_string;
13981399
# endif
1399-
sv_catpvn(retval, (const char *)mg->mg_ptr, mg->mg_len);
1400+
sv_catpvn(retval, vstr_pv, vstr_len);
14001401
}
14011402
#endif
14021403

@@ -1701,13 +1702,13 @@ Data_Dumper__vstring(sv)
17011702
CODE:
17021703
{
17031704
#ifdef SvVOK
1704-
const MAGIC *mg;
1705-
RETVAL =
1706-
SvMAGICAL(sv) && (mg = mg_find(sv, PERL_MAGIC_vstring))
1707-
? newSVpvn((const char *)mg->mg_ptr, mg->mg_len)
1708-
: &PL_sv_undef;
1709-
#else
1710-
RETVAL = &PL_sv_undef;
1705+
if(SvVOK(sv)) {
1706+
STRLEN vstr_len;
1707+
const char *vstr_pv = SvVSTRING(sv, vstr_len);
1708+
RETVAL = newSVpvn(vstr_pv, vstr_len);
1709+
}
1710+
else
17111711
#endif
1712+
RETVAL = &PL_sv_undef;
17121713
}
17131714
OUTPUT: RETVAL

0 commit comments

Comments
 (0)