Bug#601549: perl: sprintf ignores LC_NUMERIC with constants

Niko Tyni ntyni at debian.org
Wed Oct 27 08:28:42 UTC 2010


Package: perl
Version: 5.10.1-1
Tags: patch
Forwarded: http://rt.perl.org/rt3/Ticket/Display.html?id=78632

A regression in 5.10.1 breaks sprintf and LC_NUMERIC with numeric constants:

 perl -Mlocale -MPOSIX=locale_h -e 'setlocale(LC_NUMERIC, "fi_FI") or die; printf("%s should be %g\n", spr
intf("%g", 2.4), 2.4)'
 2.4 should be 2,4

(At least de_DE and sv_SE should also do for the locale.)

The bug is with constant folding, this works:

 perl -Mlocale -MPOSIX=locale_h -e 'setlocale(LC_NUMERIC, "fi_FI") or die; $in = 2.4; printf("%s should be
 %g\n", sprintf("%g", $in), 2.4)'
 2,4 should be 2,4

This is [perl #78632]. One line patch that disables sprintf() constant
folding when locales are involved:

diff --git a/op.c b/op.c
index dc9fd64..a2481af 100644
--- a/op.c
+++ b/op.c
@@ -2466,6 +2466,7 @@ Perl_fold_constants(pTHX_ register OP *o)
     case OP_SLE:
     case OP_SGE:
     case OP_SCMP:
+    case OP_SPRINTF:
 	/* XXX what about the numeric ops? */
 	if (PL_hints & HINT_LOCALE)
 	    goto nope;

I think this is a possible candidate for squeeze but may not worth an
upload by itself.
-- 
Niko Tyni   ntyni at debian.org






More information about the Perl-maintainers mailing list