@@ -12421,6 +12421,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
12421
12421
int exponent = 0 ; /* exponent of the floating point input */
12422
12422
bool hexradix = FALSE; /* should we output the radix */
12423
12423
bool subnormal = FALSE; /* IEEE 754 subnormal/denormal */
12424
+ bool negative = FALSE;
12424
12425
12425
12426
/* XXX: NaN, Inf -- though they are printed as "NaN" and "Inf".
12426
12427
*
@@ -12448,9 +12449,8 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
12448
12449
# endif
12449
12450
#endif
12450
12451
12451
- if (fv < 0
12452
- || Perl_signbit (nv )
12453
- )
12452
+ negative = fv < 0 || Perl_signbit (nv );
12453
+ if (negative )
12454
12454
* p ++ = '-' ;
12455
12455
else if (plus )
12456
12456
* p ++ = plus ;
@@ -12628,12 +12628,18 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
12628
12628
memset (PL_efloatbuf + elen , ' ' , width - elen );
12629
12629
}
12630
12630
else if (fill == '0' ) {
12631
- /* Insert the zeros between the "0x" and
12632
- * the digits, otherwise we end up with
12633
- * "0000xHHH..." */
12631
+ /* Insert the zeros after the "0x" and the
12632
+ * the potential sign, but before the digits,
12633
+ * otherwise we end up with "0000xH.HHH...",
12634
+ * when we want "0x000H.HHH..." */
12634
12635
STRLEN nzero = width - elen ;
12635
12636
char * zerox = PL_efloatbuf + 2 ;
12636
- Move (zerox , zerox + nzero , elen - 2 , char );
12637
+ STRLEN nmove = elen - 2 ;
12638
+ if (negative || plus ) {
12639
+ zerox ++ ;
12640
+ nmove -- ;
12641
+ }
12642
+ Move (zerox , zerox + nzero , nmove , char );
12637
12643
memset (zerox , fill , nzero );
12638
12644
}
12639
12645
else {
0 commit comments