From: David Mitchell Date: Sat, 8 May 2010 16:06:45 +0000 (+0100) Subject: add flags arg to sv_2nv (as sv_2nv_flags) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=39d5de13bc6d138baf12ad5224e3af8834356929;p=p5sagit%2Fp5-mst-13.2.git add flags arg to sv_2nv (as sv_2nv_flags) --- diff --git a/embed.fnc b/embed.fnc index 4f3ee7d..87143f0 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1093,7 +1093,7 @@ s |bool |glob_2number |NN GV* const gv Amb |IV |sv_2iv |NULLOK SV *sv Apd |IV |sv_2iv_flags |NULLOK SV *const sv|const I32 flags Apd |SV* |sv_2mortal |NULLOK SV *const sv -Apd |NV |sv_2nv |NULLOK SV *const sv +Apd |NV |sv_2nv_flags |NULLOK SV *const sv|const I32 flags : Used in pp.c, pp_hot.c, sv.c pMd |SV* |sv_2num |NN SV *const sv Amb |char* |sv_2pv |NULLOK SV *sv|NULLOK STRLEN *lp diff --git a/embed.h b/embed.h index af2350d..76352c6 100644 --- a/embed.h +++ b/embed.h @@ -912,7 +912,7 @@ #endif #define sv_2iv_flags Perl_sv_2iv_flags #define sv_2mortal Perl_sv_2mortal -#define sv_2nv Perl_sv_2nv +#define sv_2nv_flags Perl_sv_2nv_flags #ifdef PERL_CORE #define sv_2num Perl_sv_2num #endif @@ -3326,7 +3326,7 @@ #endif #define sv_2iv_flags(a,b) Perl_sv_2iv_flags(aTHX_ a,b) #define sv_2mortal(a) Perl_sv_2mortal(aTHX_ a) -#define sv_2nv(a) Perl_sv_2nv(aTHX_ a) +#define sv_2nv_flags(a,b) Perl_sv_2nv_flags(aTHX_ a,b) #ifdef PERL_CORE #define sv_2num(a) Perl_sv_2num(aTHX_ a) #endif diff --git a/global.sym b/global.sym index 4dd25e6..116fb19 100644 --- a/global.sym +++ b/global.sym @@ -519,7 +519,7 @@ Perl_sv_2io Perl_sv_2iv Perl_sv_2iv_flags Perl_sv_2mortal -Perl_sv_2nv +Perl_sv_2nv_flags Perl_sv_2pv Perl_sv_2pv_flags Perl_sv_2pvutf8 diff --git a/mathoms.c b/mathoms.c index aaae227..4322f66 100644 --- a/mathoms.c +++ b/mathoms.c @@ -42,6 +42,7 @@ PERL_CALLCONV void Perl_sv_unref(pTHX_ SV *sv); PERL_CALLCONV void Perl_sv_taint(pTHX_ SV *sv); PERL_CALLCONV IV Perl_sv_2iv(pTHX_ register SV *sv); PERL_CALLCONV UV Perl_sv_2uv(pTHX_ register SV *sv); +PERL_CALLCONV NV Perl_sv_2nv(pTHX_ register SV *sv); PERL_CALLCONV char * Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp); PERL_CALLCONV char * Perl_sv_2pv_nolen(pTHX_ register SV *sv); PERL_CALLCONV char * Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv); @@ -141,6 +142,17 @@ Perl_sv_2uv(pTHX_ register SV *sv) return sv_2uv_flags(sv, SV_GMAGIC); } +/* sv_2nv() is now a macro using Perl_sv_2nv_flags(); + * this function provided for binary compatibility only + */ + +NV +Perl_sv_2nv(pTHX_ register SV *sv) +{ + return sv_2nv_flags(sv, SV_GMAGIC); +} + + /* sv_2pv() is now a macro using Perl_sv_2pv_flags(); * this function provided for binary compatibility only */ diff --git a/proto.h b/proto.h index ce76039..22aad52 100644 --- a/proto.h +++ b/proto.h @@ -3176,7 +3176,7 @@ STATIC bool S_glob_2number(pTHX_ GV* const gv) /* PERL_CALLCONV IV Perl_sv_2iv(pTHX_ SV *sv); */ PERL_CALLCONV IV Perl_sv_2iv_flags(pTHX_ SV *const sv, const I32 flags); PERL_CALLCONV SV* Perl_sv_2mortal(pTHX_ SV *const sv); -PERL_CALLCONV NV Perl_sv_2nv(pTHX_ SV *const sv); +PERL_CALLCONV NV Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags); PERL_CALLCONV SV* Perl_sv_2num(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_2NUM \ diff --git a/sv.c b/sv.c index 4fd9445..5ac2730 100644 --- a/sv.c +++ b/sv.c @@ -2428,14 +2428,14 @@ Perl_sv_2uv_flags(pTHX_ register SV *const sv, const I32 flags) =for apidoc sv_2nv Return the num value of an SV, doing any necessary string or integer -conversion, magic etc. Normally used via the C and C -macros. +conversion. If flags includes SV_GMAGIC, does an mg_get() first. +Normally used via the C and C macros. =cut */ NV -Perl_sv_2nv(pTHX_ register SV *const sv) +Perl_sv_2nv_flags(pTHX_ register SV *const sv, const I32 flags) { dVAR; if (!sv) @@ -2443,7 +2443,8 @@ Perl_sv_2nv(pTHX_ register SV *const sv) if (SvGMAGICAL(sv) || (SvTYPE(sv) == SVt_PVGV && SvVALID(sv))) { /* FBMs use the same flag bit as SVf_IVisUV, so must let them cache IVs just in case. */ - mg_get(sv); + if (flags & SV_GMAGIC) + mg_get(sv); if (SvNOKp(sv)) return SvNVX(sv); if ((SvPOKp(sv) && SvLEN(sv)) && !SvIOKp(sv)) { diff --git a/sv.h b/sv.h index 815f109..807b482 100644 --- a/sv.h +++ b/sv.h @@ -1774,6 +1774,7 @@ mg.c:1024: warning: left-hand operand of comma expression has no effect #define sv_utf8_upgrade(sv) sv_utf8_upgrade_flags(sv, SV_GMAGIC) #define sv_2iv(sv) sv_2iv_flags(sv, SV_GMAGIC) #define sv_2uv(sv) sv_2uv_flags(sv, SV_GMAGIC) +#define sv_2nv(sv) sv_2nv_flags(sv, SV_GMAGIC) #define sv_insert(bigstr, offset, len, little, littlelen) \ Perl_sv_insert_flags(aTHX_ (bigstr),(offset), (len), (little), \ (littlelen), SV_GMAGIC)