New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version.pm blows away locale #11791
Comments
From @rjbsCreated by @rjbsLoading version.pm seems to blow away locale settings. Here's a program: use strict; This is worse than it seems. This came up when version was loaded by "use Perl Info
|
From @nwc10On Fri Dec 09 05:48:11 2011, rjbs wrote:
../perl/Porting/bisect.pl --start [explicit start is the commit that added version.pm, and it's needed produces HEAD is now at b5b5a8f A better version of change #28847 A better version of change #28847 p4raw-id: //depot/perl@28861 :100644 100644 7bbcbdbed9b8d2f447bd709966e5fd433bc8e6ab $ git show b5b5a8f A better version of change #28847 Inline Patchdiff --git a/universal.c b/universal.c
index 7bbcbdb..52395cc 100644
--- a/universal.c
+++ b/universal.c
@@ -688,7 +688,13 @@ XS(XS_version_qv)
if ( SvNOK(ver) ) /* may get too much accuracy */
{
char tbuf[64];
+#ifdef USE_LOCALE_NUMERIC
+ char *loc = setlocale(LC_NUMERIC, "C");
+#endif
const STRLEN len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVgf,
Inline Patchdiff --git a/util.c b/util.c
index 6be13df..dedd81a 100644
--- a/util.c
+++ b/util.c
@@ -4304,9 +4304,13 @@ Perl_upg_version(pTHX_ SV *ver)
{
char tbuf[64];
STRLEN len;
- SET_NUMERIC_STANDARD();
+#ifdef USE_LOCALE_NUMERIC
+ char *loc = setlocale(LC_NUMERIC, "C");
+#endif
len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver));
- SET_NUMERIC_LOCAL();
+#ifdef USE_LOCALE_NUMERIC
+ setlocale(LC_NUMERIC, loc);
+#endif
while (tbuf[len-1] == '0' && len > 0) len--;
version = savepvn(tbuf, len);
}
$ cat setlocale.c int C patch coming soon, but it would be useful for someone else to write Nicholas Clark |
The RT System itself - Status changed from 'new' to 'open' |
From @rjbsOn Fri Dec 09 05:48:11 2011, rjbs wrote:
../perl/Porting/bisect.pl --start [explicit start is the commit that added version.pm, and it's needed produces HEAD is now at b5b5a8f A better version of change #28847 A better version of change #28847 p4raw-id: //depot/perl@28861 :100644 100644 7bbcbdbed9b8d2f447bd709966e5fd433bc8e6ab $ git show b5b5a8f A better version of change #28847 Inline Patchdiff --git a/universal.c b/universal.c
index 7bbcbdb..52395cc 100644
--- a/universal.c
+++ b/universal.c
@@ -688,7 +688,13 @@ XS(XS_version_qv)
if ( SvNOK(ver) ) /* may get too much accuracy */
{
char tbuf[64];
+#ifdef USE_LOCALE_NUMERIC
+ char *loc = setlocale(LC_NUMERIC, "C");
+#endif
const STRLEN len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVgf,
Inline Patchdiff --git a/util.c b/util.c
index 6be13df..dedd81a 100644
--- a/util.c
+++ b/util.c
@@ -4304,9 +4304,13 @@ Perl_upg_version(pTHX_ SV *ver)
{
char tbuf[64];
STRLEN len;
- SET_NUMERIC_STANDARD();
+#ifdef USE_LOCALE_NUMERIC
+ char *loc = setlocale(LC_NUMERIC, "C");
+#endif
len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver));
- SET_NUMERIC_LOCAL();
+#ifdef USE_LOCALE_NUMERIC
+ setlocale(LC_NUMERIC, loc);
+#endif
while (tbuf[len-1] == '0' && len > 0) len--;
version = savepvn(tbuf, len);
}
$ cat setlocale.c int C patch coming soon, but it would be useful for someone else to write Nicholas Clark |
From @JohnPeacockOn 12/09/2011 12:47 PM, Ricardo Signes wrote:
I was actually working on this today. I will have a patch soon to move John |
From @JohnPeacockOn 12/09/2011 12:47 PM, Ricardo Signes wrote:
I have copied and modified a test from the CPAN version.pm release that --- a/util.c but A) this doesn't make the test pass and B) this code is not called by I'll keep digging, but if there was a proposed C patch (as described John |
From @nwc10On Sun, Dec 18, 2011 at 05:53:50AM -0500, John Peacock wrote:
"Coming soon" was because I tried the same "obvious" as you and it didn't
IIRC *that* code is called by the C<use 5.006;> in vars.pm which is used perl -Mlocale -MPOSIX -e 'my $i = 0.123; POSIX::setlocale(POSIX::LC_NUMERIC(),"de_DE"); $a = sprintf("%.2f", $i); eval "use v5.0.0"; $b = sprintf("%.2f", $i); die "$a $b" unless $a eq $b' (gdb) where Karl had independently done it correctly (save a copy of the return value Nicholas Clark |
From @JohnPeacockThis is interesting: $ LC_NUMERIC=da_DK.utf8 ./perl -Ilib -Mlocale -MPOSIX -e 'my $i = 0.123; $ LC_NUMERIC=da_DK.utf8 ./perl -Ilib -Mlocale -MPOSIX -e 'my $i = 0.123; So it has to do with the eval itself. The only thing that "use 5.0" I will note that this bug has been in every Perl release since 5.10.0... John |
From @khwilliamsonOn 12/18/2011 04:16 AM, Nicholas Clark wrote:
And Karl didn't do anything because he thought he saw Nicholas on irc |
From @nwc10On Sun, Dec 18, 2011 at 09:39:37AM -0700, Karl Williamson wrote:
Yes, sorry, forgot that bit. Nicholas Clark |
From @cpansproutOn Fri Dec 09 05:48:11 2011, rjbs wrote:
Did 909d378 fix this? -- Father Chrysostomos |
From @khwilliamsonOn 12/18/2011 09:30 PM, Father Chrysostomos via RT wrote:
It is my belief that it did. |
From @JohnPeacockOn 12/18/2011 11:30 PM, Father Chrysostomos via RT wrote:
Yes it did! Wow, that was subtle... John |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#105784 (status was 'resolved')
Searchable as RT105784$
The text was updated successfully, but these errors were encountered: