From: Jarkko Hietaniemi Date: Thu, 17 Aug 2000 00:04:32 +0000 (+0000) Subject: Retract #6645. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8af02333c93343b2ed2e522e4fa455023e6cc339;p=p5sagit%2Fp5-mst-13.2.git Retract #6645. p4raw-id: //depot/perl@6660 --- diff --git a/Configure b/Configure index 52b66cd..08a8886 100755 --- a/Configure +++ b/Configure @@ -20,7 +20,7 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Wed Aug 16 02:10:47 EET DST 2000 [metaconfig 3.0 PL70] +# Generated on Thu Aug 17 02:52:39 EET DST 2000 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.com) cat >/tmp/c1$$ <try.c <<'EOSC' -#include -int main() { - char b[10]; - exit(sprintf(b, "%0.1e", 1.2) - 5); -} -EOSC -set try -if eval $compile; then - ./try$_exe - case "$?" in - 2|3) d_printf_exp_digits=$? ;; - esac -fi -case "$d_printf_exp_digits" in -2|3) echo "Your sprintf seems to use $d_printf_exp_digits exponent digits." - ;; -*) cat <&4 -I do not understand what your sprintf is saying. -I'm guessing it uses at least 2 exponent digits. -EOM - d_printf_exp_digits=2 - ;; -esac -$rm -f try try.* - : see whether the various POSIXish _yields exist $cat >try.c < exists and * should be included. diff --git a/config_h.SH b/config_h.SH index 209c96f..e66e0c5 100644 --- a/config_h.SH +++ b/config_h.SH @@ -3156,13 +3156,6 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #define PERL_XS_APIVERSION "$xs_apiversion" #define PERL_PM_APIVERSION "$pm_apiversion" -/* PRINTF_EXP_DIGITS: - * This symbol's value is either 2 or 3, corresponding to the - * number of exponent digits produced by the system's sprintf %[FGfg] - * formats when the modulus of the exponent is 99 or less. - */ -#define PRINTF_EXP_DIGITS $d_printf_exp_digits - /* I_LIBUTIL: * This symbol, if defined, indicates that exists and * should be included. diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 45b2f8e..9afa44d 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -27,37 +27,6 @@ to be the case and the 'cc' does not seem to be the GNU C compiler =head1 Platform specific changes -=head2 printf() and sprintf() give two-digit exponent where possible - -Perl's printf() and sprintf() use the standard C library sprintf() -function to implement the floating point conversions provided by the -C<%e>, C<%f> and C<%g> formats (and their upper-case counterparts). C -library sprintf() functions vary in the number of exponent digits that -they produce in scientific notation when the modulus of the exponent -is less than one hundred: most platforms give two digits (for example, -C<1.234e-45>) while others, notably Microsoft's libraries for Windows, -give three (as in C<1.234e-045>). Previously, Perl's functions -produced results identical to the platform's underlying library -function, resulting in script portability problems. Now, on all -platforms, only two exponent digits are delivered unless more are -needed. - -Note that this change applies only to explicit conversions made by -printf() and sprintf(); implicit conversions still show the same -behavior as the underlying library function: - - print "native: ", 1234567e89, sprintf("; standardized: %e\n", 1234567e89) - -outputs - - native: 1.234567e+95; standardized: 1.234567e+95 - -on most platforms, and - - native: 1.234567e+095; standardized: 1.234567e+95 - -on the remainder. - =head1 Significant bug fixes =head1 New or Changed Diagnostics diff --git a/sv.c b/sv.c index 73704b7..2e59dce 100644 --- a/sv.c +++ b/sv.c @@ -6561,38 +6561,9 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV (void)sprintf(PL_efloatbuf, eptr, nv); 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 */ @@ -8374,3 +8345,4 @@ do_clean_all(pTHXo_ SV *sv) SvFLAGS(sv) |= SVf_BREAK; SvREFCNT_dec(sv); } + diff --git a/t/op/sprintf.t b/t/op/sprintf.t index e96c683..8bb7536 100755 --- a/t/op/sprintf.t +++ b/t/op/sprintf.t @@ -197,10 +197,8 @@ __END__ >%12.4e< >1234.875< > 1.2349e+03< >%+-12.4e< >1234.875< >+1.2349e+03 < >%+12.4e< >1234.875< > +1.2349e+03< ->%+012.4e< >1234.875< >+01.2349e+03< >%+-12.4e< >-1234.875< >-1.2349e+03 < >%+12.4e< >-1234.875< > -1.2349e+03< ->%+012.4e< >-1234.875< >-01.2349e+03< >%f< >1234.875< >1234.875000< >%+f< >1234.875< >+1234.875000< >%#f< >1234.875< >1234.875000< @@ -215,10 +213,8 @@ __END__ >%8.1f< >1234.875< > 1234.9< >%+-8.1f< >1234.875< >+1234.9 < >%+8.1f< >1234.875< > +1234.9< ->%+08.1f< >1234.875< >+01234.9< >%+-8.1f< >-1234.875< >-1234.9 < >%+8.1f< >-1234.875< > -1234.9< ->%+08.1f< >-1234.875< >-01234.9< >%*.*f< >[5, 2, 12.3456]< >12.35< >%f< >0< >0.000000< >%.0f< >0< >0< @@ -256,7 +252,6 @@ __END__ >%g< >0< >0< >%13g< >1234567.89< > 1.23457e+06< >%+13g< >1234567.89< > +1.23457e+06< ->%+013g< >1234567.89< >+01.23457e+06< >%013g< >1234567.89< >001.23457e+06< >%-13g< >1234567.89< >1.23457e+06 < >%h< >''< >%h INVALID<