Skip to content

Commit 77b8928

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

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

dist/Data-Dumper/Dumper.xs

+14-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define NEED_my_sprintf
77
#define NEED_sv_2pv_flags
88
#define NEED_utf8_to_uvchr_buf
9+
#define NEED_sv_vstring_get
910
#include "ppport.h"
1011

1112
#ifndef strlcpy
@@ -1240,7 +1241,8 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
12401241
}
12411242
else {
12421243
STRLEN i;
1243-
const MAGIC *mg;
1244+
STRLEN vstr_len;
1245+
const char *vstr_pv;
12441246

12451247
if (namelen) {
12461248
id_buffer = PTR2UV(val);
@@ -1386,17 +1388,17 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv,
13861388
sv_catpvs(retval, "undef");
13871389
}
13881390
#ifdef SvVOK
1389-
else if (SvMAGICAL(val) && (mg = mg_find(val, PERL_MAGIC_vstring))) {
1391+
else if (SvVOK(val) && (vstr_pv = SvVSTRING(val, vstr_len))) {
13901392
# if !defined(PL_vtbl_vstring) && PERL_VERSION_LT(5,17,0)
13911393
SV * const vecsv = sv_newmortal();
13921394
# if PERL_VERSION_LT(5,10,0)
1393-
scan_vstring(mg->mg_ptr, vecsv);
1395+
scan_vstring(vstr_pv, vecsv);
13941396
# else
1395-
scan_vstring(mg->mg_ptr, mg->mg_ptr + mg->mg_len, vecsv);
1397+
scan_vstring(vstr_pv, vstr_pv + vstr_len, vecsv);
13961398
# endif
13971399
if (!sv_eq(vecsv, val)) goto integer_came_from_string;
13981400
# endif
1399-
sv_catpvn(retval, (const char *)mg->mg_ptr, mg->mg_len);
1401+
sv_catpvn(retval, vstr_pv, vstr_len);
14001402
}
14011403
#endif
14021404

@@ -1701,13 +1703,13 @@ Data_Dumper__vstring(sv)
17011703
CODE:
17021704
{
17031705
#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;
1706+
if(SvVOK(sv)) {
1707+
STRLEN vstr_len;
1708+
const char *vstr_pv = SvVSTRING(sv, vstr_len);
1709+
RETVAL = newSVpvn(vstr_pv, vstr_len);
1710+
}
1711+
else
17111712
#endif
1713+
RETVAL = &PL_sv_undef;
17121714
}
17131715
OUTPUT: RETVAL

0 commit comments

Comments
 (0)