summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorDominic Dunlop <domo@computer.org>2000-08-16 00:20:52 +0200
committerJarkko Hietaniemi <jhi@iki.fi>2000-08-15 23:33:23 +0000
commitd764f01a54c0f82174c22184bb83b9dca8be1913 (patch)
tree8bbd5001c020c405b11f3c868d9926a21019b959 /sv.c
parent9d5a2765247106c08687386ac3cf275028b5a54a (diff)
downloadperl-d764f01a54c0f82174c22184bb83b9dca8be1913.tar.gz
(Retracted by #6660)
Subject: [PATCH perl-current] make s?printf() produce two exponent digits where possible Message-Id: <p04320403b5bf4c32d381@[192.168.1.4]> p4raw-id: //depot/perl@6645
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/sv.c b/sv.c
index ab4d6d55e7..80d94b53b0 100644
--- a/sv.c
+++ b/sv.c
@@ -6559,9 +6559,38 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
(void)sprintf(PL_efloatbuf, eptr, nv);
RESTORE_NUMERIC_LOCAL();
}
-
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 */
@@ -8343,4 +8372,3 @@ do_clean_all(pTHXo_ SV *sv)
SvFLAGS(sv) |= SVf_BREAK;
SvREFCNT_dec(sv);
}
-