goto ret_iv_max;
}
}
- else if (numtype) {
- /* The NV may be reconstructed from IV - safe to cache IV,
- which may be calculated by atol(). */
- if (SvTYPE(sv) == SVt_PV)
- sv_upgrade(sv, SVt_PVIV);
- (void)SvIOK_on(sv);
- SvIVX(sv) = Atol(SvPVX(sv));
- }
- else { /* Not a number. Cache 0. */
- dTHR;
-
+ else { /* The NV may be reconstructed from IV - safe to cache IV,
+ which may be calculated by atol(). */
if (SvTYPE(sv) < SVt_PVIV)
sv_upgrade(sv, SVt_PVIV);
(void)SvIOK_on(sv);
- SvIVX(sv) = 0;
- if (ckWARN(WARN_NUMERIC))
+ SvIVX(sv) = Atol(SvPVX(sv));
+ if (! numtype && ckWARN(WARN_NUMERIC))
not_a_number(sv);
}
}
sv_upgrade(sv, SVt_NV);
#if defined(USE_LONG_DOUBLE)
DEBUG_c({
- RESTORE_NUMERIC_STANDARD();
+ STORE_NUMERIC_LOCAL_SET_STANDARD();
PerlIO_printf(Perl_debug_log,
"0x%"UVxf" num(%" PERL_PRIgldbl ")\n",
PTR2UV(sv), SvNVX(sv));
});
#else
DEBUG_c({
- RESTORE_NUMERIC_STANDARD();
+ STORE_NUMERIC_LOCAL_SET_STANDARD();
PerlIO_printf(Perl_debug_log, "0x%"UVxf" num(%g)\n",
PTR2UV(sv), SvNVX(sv));
RESTORE_NUMERIC_LOCAL();
SvNOK_on(sv);
#if defined(USE_LONG_DOUBLE)
DEBUG_c({
- RESTORE_NUMERIC_STANDARD();
+ STORE_NUMERIC_LOCAL_SET_STANDARD();
PerlIO_printf(Perl_debug_log, "0x%"UVxf" 2nv(%" PERL_PRIgldbl ")\n",
PTR2UV(sv), SvNVX(sv));
RESTORE_NUMERIC_LOCAL();
});
#else
DEBUG_c({
- RESTORE_NUMERIC_STANDARD();
+ STORE_NUMERIC_LOCAL_SET_STANDARD();
PerlIO_printf(Perl_debug_log, "0x%"UVxf" 1nv(%g)\n",
PTR2UV(sv), SvNVX(sv));
RESTORE_NUMERIC_LOCAL();
case SVt_PV:
case SVt_PVIV:
case SVt_PVNV:
- case SVt_PVBM: s = "SCALAR"; break;
+ case SVt_PVBM: if (SvROK(sv))
+ s = "REF";
+ else
+ s = "SCALAR"; break;
case SVt_PVLV: s = "LVALUE"; break;
case SVt_PVAV: s = "ARRAY"; break;
case SVt_PVHV: s = "HASH"; break;
*--eptr = '%';
{
- RESTORE_NUMERIC_STANDARD();
+ STORE_NUMERIC_STANDARD_SET_LOCAL();
+ if (!was_standard && maybe_tainted)
+ *maybe_tainted = TRUE;
(void)sprintf(PL_efloatbuf, eptr, nv);
- RESTORE_NUMERIC_LOCAL();
+ RESTORE_NUMERIC_STANDARD();
}
-
eptr = PL_efloatbuf;
elen = strlen(PL_efloatbuf);
+
+#if PRINTF_EXP_DIGITS == 3 /* Shorten exponent */
+ if (((p = index(eptr, 'e')) || (p = index(eptr, 'E'))) &&
+ (*++p == '+' || *p == '-') && /* Is there exponent */
+ *++p == '0') { /* with leading zero? */
+ DEBUG_c(PerlIO_printf(Perl_debug_log,
+ ">%s<: '0' at %d from start; "
+ "elen == %d, width == %d\n",
+ eptr, p-eptr, elen, width));
+ Move(p+1, p, 3, char); /* Suppress leading zero */
+ if (elen == width && /* Fix up padding if */
+ *(p+2) == '\0') { /* necessary */
+ if (!left) {
+ if (fill == '0') {
+ Move(eptr+1, eptr+2, elen-1, char);
+ *(eptr+1) = '0';
+ }
+ else {
+ Move(eptr, eptr+1, elen, char);
+ *eptr = ' ';
+ }
+ }
+ else {
+ *(p+2) == ' '; *(p+3) = '\0';
+ }
+ }
+ else if (elen > width)
+ elen--;
+ }
+# endif
break;
/* SPECIAL */
SvFLAGS(sv) |= SVf_BREAK;
SvREFCNT_dec(sv);
}
-