In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/ae807896a9a56884bd6bfdf7e5ac5b6214b0e766?hp=f88c7f62044e3b2357ce5c704f70862516afbbae>
- Log ----------------------------------------------------------------- commit ae807896a9a56884bd6bfdf7e5ac5b6214b0e766 Author: Jarkko Hietaniemi <[email protected]> Date: Sat Sep 13 13:02:49 2014 -0400 Use Perl_frexp, and cast arg to NV as appropriate. M sv.c commit c5bf4216baef0647f21a2c9cb2bed38077255014 Author: Jarkko Hietaniemi <[email protected]> Date: Sat Sep 13 11:54:57 2014 -0400 Warning about the va_arg vs long doubles. M sv.c commit b782b15af1ca1d6a80d661731448a42e12571efc Author: Jarkko Hietaniemi <[email protected]> Date: Fri Sep 12 21:55:58 2014 -0400 Untangle the fp value retrieval. M sv.c ----------------------------------------------------------------------- Summary of changes: sv.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/sv.c b/sv.c index 8b84680..556c68d 100644 --- a/sv.c +++ b/sv.c @@ -11066,17 +11066,13 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p * the time it is not (most compilers these days recognize * "long double", even if only as a synonym for "double"). */ -#if defined(HAS_LONG_DOUBLE) && \ - LONG_DOUBLESIZE > DOUBLESIZE && \ - defined(HAS_FREXPL) +#if defined(HAS_LONG_DOUBLE) && LONG_DOUBLESIZE > DOUBLESIZE long double fv; -# define FV_ISFINITE Perl_isfinitel -# define FV_FREXP frexpl +# define FV_ISFINITE(x) Perl_isfinitel(x) # define FV_GF PERL_PRIgldbl #else NV fv; -# define FV_ISFINITE Perl_isfinite -# define FV_FREXP Perl_frexp +# define FV_ISFINITE(x) Perl_isfinite((NV)(x)) # define FV_GF NVgf #endif STRLEN have; @@ -11794,23 +11790,33 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p goto unknown; } - /* now we need (long double) if intsize == 'q', else (double) */ - fv = (args) ? + /* Now we need (long double) if intsize == 'q', else (double). */ + if (args) { + /* Note: do not pull NVs off the va_list with va_arg() + * (pull doubles instead) because if you have a build + * with long doubles, you would always be pulling long + * doubles, which would badly break anyone using only + * doubles (i.e. the majority of builds). In other + * words, you cannot mix doubles and long doubles. + * The only case where you can pull off long doubles + * is when the format specifier explicitly asks so with + * e.g. "%Lg". */ #if LONG_DOUBLESIZE > DOUBLESIZE - intsize == 'q' ? - va_arg(*args, long double) : - va_arg(*args, double) + fv = intsize == 'q' ? + va_arg(*args, long double) : va_arg(*args, double); #else - va_arg(*args, double) + fv = va_arg(*args, double); #endif - : SvNV(argsv); + } + else + fv = SvNV(argsv); need = 0; /* frexp() (or frexpl) has some unspecified behaviour for * nan/inf/-inf, so let's avoid calling that on non-finites. */ if (isALPHA_FOLD_NE(c, 'e') && FV_ISFINITE(fv)) { i = PERL_INT_MIN; - (void)FV_FREXP(fv, &i); + (void)Perl_frexp((NV)fv, &i); if (i == PERL_INT_MIN) Perl_die(aTHX_ "panic: frexp: %"FV_GF, fv); /* Do not set hexfp earlier since we want to printf -- Perl5 Master Repository
