Skip to content

Commit ebed084

Browse files
committed
vutil.c: Use new SvVSTRING() macro
1 parent f81d6dc commit ebed084

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

vutil.c

+7-9
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,9 @@ Perl_new_version(pTHX_ SV *ver)
544544
}
545545
#ifdef SvVOK
546546
{
547-
const MAGIC* const mg = SvVSTRING_mg(ver);
548-
if ( mg ) { /* already a v-string */
549-
const STRLEN len = mg->mg_len;
550-
const char * const version = (const char*)mg->mg_ptr;
547+
if (SvVOK(ver)) { /* already a v-string */
548+
STRLEN len;
549+
const char * const version = SvVSTRING(ver, len);
551550
char *raw, *under;
552551
static const char underscore[] = "_";
553552
sv_setpvn(rv,version,len);
@@ -618,9 +617,6 @@ Perl_upg_version(pTHX_ SV *ver, bool qv)
618617
#endif
619618
{
620619
const char *version, *s;
621-
#ifdef SvVOK
622-
const MAGIC *mg;
623-
#endif
624620

625621
#if PERL_VERSION_LT(5,19,8) && defined(USE_ITHREADS)
626622
ENTER;
@@ -820,8 +816,10 @@ Perl_upg_version(pTHX_ SV *ver, bool qv)
820816
SvREFCNT_dec(sv);
821817
}
822818
#ifdef SvVOK
823-
else if ( (mg = SvVSTRING_mg(ver)) ) { /* already a v-string */
824-
version = savepvn( (const char*)mg->mg_ptr,mg->mg_len );
819+
else if (SvVOK(ver)) { /* already a v-string */
820+
STRLEN len;
821+
const char *pv = SvVSTRING(ver, len);
822+
version = savepvn(pv, len);
825823
SAVEFREEPV(version);
826824
qv = TRUE;
827825
}

0 commit comments

Comments
 (0)